From e92048f79889782063e7261acf45d0817e4d0311 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Tue, 20 Feb 2024 12:45:04 +0000 Subject: [PATCH 1/2] rustc has slightly changed its output. --- examples/rust_lang_tester/lang_tests/no_main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rust_lang_tester/lang_tests/no_main.rs b/examples/rust_lang_tester/lang_tests/no_main.rs index 50eb9be..aacc239 100644 --- a/examples/rust_lang_tester/lang_tests/no_main.rs +++ b/examples/rust_lang_tester/lang_tests/no_main.rs @@ -3,6 +3,6 @@ // stderr: // error[E0601]: `main` function not found in crate `no_main` // ... -// error: aborting due to previous error +// error: aborting due to 1 previous error // // For more information about this error, try `rustc --explain E0601`. From b7cf0cdfda94e0c296cf4acb255505768fa6f98a Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Tue, 20 Feb 2024 12:45:29 +0000 Subject: [PATCH 2/2] Document and enforce that `ignore-if` cmds are run in `CARGO_MANIFEST_DIR`. This happened implicitly before (unless you did something odd): this change makes sure this is the actual behaviour. --- examples/rust_lang_tester/lang_tests/ignore2.rs | 8 ++++++++ src/lib.rs | 1 + src/tester.rs | 1 + 3 files changed, 10 insertions(+) create mode 100644 examples/rust_lang_tester/lang_tests/ignore2.rs diff --git a/examples/rust_lang_tester/lang_tests/ignore2.rs b/examples/rust_lang_tester/lang_tests/ignore2.rs new file mode 100644 index 0000000..18dbd85 --- /dev/null +++ b/examples/rust_lang_tester/lang_tests/ignore2.rs @@ -0,0 +1,8 @@ +// # Always ignore this test +// ignore-if: cat examples/rust_lang_tester/lang_tests/ignore.rs +// Compiler: +// status: success + +fn main() { + panic!("Shouldn't happen."); +} diff --git a/src/lib.rs b/src/lib.rs index 08475df..ffd6033 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,6 +165,7 @@ //! //! * `ignore-if: ` defines a shell command that will be run to determine whether to ignore //! this test or not. If `` returns 0 the test will be ignored, otherwise it will be run. +//! `` will have its directory set to `CARGO_MANIFEST_DIR`. //! //! `lang_tester`'s output is deliberately similar to Rust's normal testing output. Running the //! example `rust_lang_tester` in this crate produces the following output: diff --git a/src/tester.rs b/src/tester.rs index 88d9f43..066305a 100644 --- a/src/tester.rs +++ b/src/tester.rs @@ -659,6 +659,7 @@ fn test_file( let ignore = if let Some(ignore_if) = tests.ignore_if { Command::new(env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_owned())) .args(["-c", &ignore_if]) + .current_dir(env::var("CARGO_MANIFEST_DIR").unwrap()) .stdin(process::Stdio::piped()) .stderr(process::Stdio::piped()) .stdout(process::Stdio::piped())