Skip to content

Commit

Permalink
Merge pull request #122 from ltratt/ignore_if_dir
Browse files Browse the repository at this point in the history
Document and enforce that `ignore-if` cmds are run in `CARGO_MANIFEST_DIR`.
  • Loading branch information
jacob-hughes committed Feb 20, 2024
2 parents 27a7ffb + b7cf0cd commit 4403381
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions examples/rust_lang_tester/lang_tests/ignore2.rs
Original file line number Diff line number Diff line change
@@ -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.");
}
2 changes: 1 addition & 1 deletion examples/rust_lang_tester/lang_tests/no_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
//!
//! * `ignore-if: <cmd>` defines a shell command that will be run to determine whether to ignore
//! this test or not. If `<cmd>` returns 0 the test will be ignored, otherwise it will be run.
//! `<cmd>` 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:
Expand Down
1 change: 1 addition & 0 deletions src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 4403381

Please sign in to comment.