-
Notifications
You must be signed in to change notification settings - Fork 8
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
Figure out how to deal with cargo test
with a no_std target
#72
Comments
build-std
feature: results in "add #![feature(restricted_std)]" messages without effectcargo test
with build-std
feature: results in "add #![feature(restricted_std)]" messages without effect
cargo test
with build-std
feature: results in "add #![feature(restricted_std)]" messages without effectcargo test
with build-std
feature: results in add #![feature(restricted_std)]
messages without effect
cargo test
with build-std
feature: results in add #![feature(restricted_std)]
messages without effectcargo test
with build-std
feature: results in add #![feature(restricted_std)]
messages (which don't have any effect)
cargo test
with build-std
feature: results in add #![feature(restricted_std)]
messages (which don't have any effect)cargo test
with build-std
feature: results in add #![feature(restricted_std)]
messages (which doesn't has any effect)
Thanks for the report! When filing an issue about an error, it can be helpful to include the entire output, as it can include important information. In this case, I think it is failing while building In general, running tests in a no_std environment may not work at all. Tests require threads, allocation, and other things that may not be available. I don't recall what |
#69 could be related as well |
cargo test
with build-std
feature: results in add #![feature(restricted_std)]
messages (which doesn't has any effect)cargo test
with a no_std target
Transferred this to wg-cargo-std-aware for tracking purposes. |
I ran into the same problem. If you add |
Here is the error output from building
but adding the feature doesn't actually help here, because cargo doesn't know to build
when I pass
presumably because cargo is trying to execute these natively instead of through QEMU. If I use QEMU to run the binary it ends up ... hanging forever, probably because something is panicking. So just adding restricted-std doesn't seem like it's a fix, and I'm not sure it makes sense to land without other changes to cargo or libtest; the first step here would be to investigate the panic when using QEMU to run the test binary. commands I had to install
|
I've made a short (working) example of what I have in mind based on blog_os post #04 This can be run with a nightly toolchain with the llvm-preview-tools and rust-src installed with Additionally, the rust source code must be edited to include this patch. The compiler doesn't need to be rebuilt since Anyway, this allows us to successfully build |
You could also use a proc macro to define your own |
It's probably possibly, but it seems to be a bit tricky to add test cases across |
I mean having a different static for every test, not a single static for the whole crate. So for example #[test_case]
static FOO: TestDescAndFn = TestDescAndFn {
func: foo,
ignore: false,
}
fn foo() {}
mod bar {
#[test_case]
static BAZ: TestDescAndFn = TestDescAndFn {
func: baz,
ignore: true,
}
fn baz() {}
} All items annotated with |
Ah, thanks that makes sense! I'll be sure to try this out once I get the chance. |
I think that figuring out this issue is also worthwhile for embedded target simulators (perhaps via See Patryk27/avr-tester#5 where I'm trying to use plain |
@ehuss: This is just a general issue on figuring out what
cargo test
should do with a no_std target.This bug originates from a stack overflow thread in that my minimal project, that is building an application for the
x86_64-unknown-uefi
target, cannot executecargo test
. The crate itself uses thebuild-std
feature in.config/cargo.toml
. When tests are executed, the compiler complains aboutcan't find crate for 'test'
. If I addtest
to thebuild-std
-array, therefore,the compiler tells I should add
#![feature(restricted_std)]
. If I do so, nothing changes. I found the bug with Rust/Cargo 1.55-nightlyExpected Behaviour
One should be able to execute tests when
build-std
is used.The text was updated successfully, but these errors were encountered: