-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support no_std
Usage
#47
Comments
Possibly a dumb question (as I have no I'm not sure about the possibility of supporting running without heap allocation. There's certainly a subset of the API that could work there, but I'm not sure how useful it'd be. As for
The last one seems like a possibly big deal, since it means that proptest can't really do its job on a test that can fail in any way other than returning a failure code normally. But I guess it could still be useful. In any case, thanks for being willing to assist with this! |
Thank you for the encouragement, @AltSysrq . Yep, it is often possible to arrange a project such that the tests are run with access to the standard library (e.g. whilst running on a local linux/windows/osx dev machine), even though the main project is geared for an embedded use case. However, this is not always the case -- sometimes the capabilities that need to be exercised are only truly available when being run in a context without access to the standard library at all. For example, when running on an esoteric device with custom (sometimes black-box) features and no prayer of a full stdlib in sight. That sort of "in-vivo" testing is what I'm hoping to cover with this effort. I think persistence can be handled conventionally enough by being made optional -- perhaps factoring it into a trait with a few implementations (noop, filesystem, manual piping, etc), the present filesystem-based variant of which could be made std-only. As for panics, you're right that we'd be pushed into a returned-failure-signifying style. There is an alternative available, which utest uses, that overrides |
Related issue rust-embedded/wg#47 |
|
@ZackPierce can you add an example or more documentation on setting up proptest in a #![no_std] environment. I don't want to disrail this bug for support but adding -Jon |
@jparris A couple pointers to get you started:
I think there may be a bit more fiddling necessary for actually writing the tests, and unfortunately I don't have any examples handy. |
Definitely an example is needed for how to no_std the crate. I also attempted to use it: proptest = { version = "0.8", defatult-features = false, features = [] } but then it pulled in many std using things. There should just be an example of every dependency you have to list out with default-features off |
[dev-dependencies.proptest]
version = "0.8"
default-features = false
features = ["alloc", "unstable"] This works for me, assuming I'm testing it correctly. I will add documenting this to my to do list for the next release. |
When using that configuration, I get a problem with the transitive lazy_static dependency:
|
Oh, we have a separate Do you know of a way to ensure nothing brings |
I don't. In my particularly strange use case, I don't need proptest to run on the device, I just need it for tests that run on the local machine. However, [dev-dependences] is for both tests and examples, so if I want my examples to target the device I can't have proptest as a dev-dependency :/ |
@AltSysrq to test that |
@AltSysrq It fails to compile in my case as well. This is my configuration:
and the error:
|
@goral09 as mentioned previously you also need the
|
Thanks @nivkner but this doesn't solve my problem. Still getting the same errors. |
@nivkner Thanks for that |
@goral09 I'm not entirely sure what's going on in your case. The error message itself suggests you're trying to use a regex-based |
Also, there's now documentation on using |
It would be excellent to be able to use proptest in
no_std
environments like embedded development and wasm-land. Some features of proptest are not likely to be viable inno_std
, but a meaningful subset should be possible.In the long run, this would likely stratify into three tiers of capability:
std
,no_std
+alloc
, and finallyno_std
without access to a heap allocator. Feature flags should be sufficient to provide users a means of selecting the features available in their environment. Default feature flags would allow a no-effort transition for extant users.Accomplishing this would likely require us to:
quick-error
) .no_std
related feature flag options for crates that support such (e.g.lazy_static
) .std
library bits with core-based alternatives or convert into optional capabilities.core
-flavored variants of thearbitrary/_std
submodules where the types in question are simple re-exposures ofcore
types.I'm sure there's more to do that I haven't yet pointed out, or mistakes in the above analysis.
From a practical standpoint, in order to show good faith and "skin in the game", I've started working on getting to the first additional tier of capability (
no_std
+alloc
) working, beginning with adding or exposingno_std
modes for dependencies ( see: contain-rs/bit-vec#49 and contain-rs/bit-set#15).I'd be very happy to receive any guidance or corrections possible.
The text was updated successfully, but these errors were encountered: