You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...
// Write "hello world" to stdout.
match write_mode {
WriteMode::Macro => {println!("hello world");},
WriteMode::C => {
let buf = "hello world".as_bytes();
let hello = std::ffi::CString::new(buf).unwrap();
let bufptr = hello.as_ptr() as *const libc::c_void;
check_cint!(libc::write(1, bufptr, buf.len()));
}
}
....
This code is run in a child process. When it is invoked by running it after cargo build, it works fine regardless of whether Macro or C mode is used. When it is invoked by cargo test, C mode works but Macro mode fails with an empty string. When it is invoked by cargo test -- --nocapture, both modes work again. Here's a transcript:
$ cargo build
Compiling libc v0.2.14
Compiling piperef v0.1.0 (file:///usr/local/src/ptyknot/misc/piperef-rs)
$ target/debug/piperef
$ cargo test
Compiling piperef v0.1.0 (file:///usr/local/src/ptyknot/misc/piperef-rs)
Running target/debug/piperef-80efeb997239b2ac
running 2 tests
test write_macro_test ... FAILED$<2>
test write_c_test ... ok$<2>
failures:
---- write_macro_test stdout ----
thread 'write_macro_test' panicked at 'assertion failed: `(left == right)` (left: `""`, right: `"hello world"`)', piperef.rs:60
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
write_macro_test
test result: FAILED$<2>. 1 passed; 1 failed; 0 ignored; 0 measured
error: test failed
$ cargo test -- --nocapture
Running target/debug/piperef-80efeb997239b2ac
running 2 tests
test write_macro_test ... ok
test write_c_test ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
$
It looks like the test runner is fouling up the environment somehow, but I can't figure out how by looking at stuff.
The text was updated successfully, but these errors were encountered:
Thanks for the report! I think that this actually has to do with the test harness in the standard library rather than Cargo itself, could you open up a bug against rust-lang/rust with these contents?
Consider the code at https://gitlab.com/BartMassey/ptyknot/tree/pipes-direct/misc/piperef-rs . The relevant portion is in piperef.rs:
This code is run in a child process. When it is invoked by running it after
cargo build
, it works fine regardless of whether Macro or C mode is used. When it is invoked bycargo test
, C mode works but Macro mode fails with an empty string. When it is invoked bycargo test -- --nocapture
, both modes work again. Here's a transcript:It looks like the test runner is fouling up the environment somehow, but I can't figure out how by looking at stuff.
The text was updated successfully, but these errors were encountered: