Skip to content
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

Document and enforce that ignore-if cmds are run in CARGO_MANIFEST_DIR. #122

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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