diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-06-06 08:37:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-06 08:37:13 -0400 |
commit | e5b2c5ebb89b962faec2937b3befa01ced90c579 (patch) | |
tree | e7e06f1391ddb71da97b5c6910ea2eeab0fe20ea /tests/specs/mod.rs | |
parent | 4d531bf229069f28b96c53c7c0f30f068b410382 (diff) |
chore: support `-- --nocapture` in the spec tests (#24113)
Diffstat (limited to 'tests/specs/mod.rs')
-rw-r--r-- | tests/specs/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index 3a52ab29e..c46969f4e 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -19,6 +19,7 @@ use file_test_runner::collection::CollectedTest; use file_test_runner::collection::CollectedTestCategory; use file_test_runner::SubTestResult; use file_test_runner::TestResult; +use once_cell::sync::Lazy; use serde::Deserialize; use test_util::tests_path; use test_util::PathRef; @@ -26,6 +27,9 @@ use test_util::TestContextBuilder; const MANIFEST_FILE_NAME: &str = "__test__.jsonc"; +static NO_CAPTURE: Lazy<bool> = + Lazy::new(|| std::env::args().any(|arg| arg == "--nocapture")); + #[derive(Clone, Deserialize)] #[serde(untagged)] enum VecOrString { @@ -178,7 +182,9 @@ pub fn main() { let _http_guard = test_util::http_server(); file_test_runner::run_tests( &root_category, - file_test_runner::RunOptions { parallel: true }, + file_test_runner::RunOptions { + parallel: !*NO_CAPTURE, + }, run_test, ); } @@ -373,6 +379,12 @@ fn run_step( Some(command_name) => command.name(command_name), None => command, }; + let command = match *NO_CAPTURE { + // deprecated is only to prevent use, so this is fine here + #[allow(deprecated)] + true => command.show_output(), + false => command, + }; let output = command.run(); if step.output.ends_with(".out") { let test_output_path = cwd.join(&step.output); |