mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
chore: support -- --nocapture
in the spec tests (#24113)
This commit is contained in:
parent
4d531bf229
commit
e5b2c5ebb8
4 changed files with 31 additions and 9 deletions
|
@ -26,6 +26,13 @@ Or just the following, though it might run other tests:
|
||||||
cargo test test_name
|
cargo test test_name
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To run showing the output of every test use `-- --nocapture` (note: this will
|
||||||
|
cause tests to run sequentially instead of in parallel):
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo test test_name -- --nocapture
|
||||||
|
```
|
||||||
|
|
||||||
## `__test__.json` file
|
## `__test__.json` file
|
||||||
|
|
||||||
This file describes the test(s) to execute and the steps to execute. A basic
|
This file describes the test(s) to execute and the steps to execute. A basic
|
||||||
|
|
|
@ -19,6 +19,7 @@ use file_test_runner::collection::CollectedTest;
|
||||||
use file_test_runner::collection::CollectedTestCategory;
|
use file_test_runner::collection::CollectedTestCategory;
|
||||||
use file_test_runner::SubTestResult;
|
use file_test_runner::SubTestResult;
|
||||||
use file_test_runner::TestResult;
|
use file_test_runner::TestResult;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use test_util::tests_path;
|
use test_util::tests_path;
|
||||||
use test_util::PathRef;
|
use test_util::PathRef;
|
||||||
|
@ -26,6 +27,9 @@ use test_util::TestContextBuilder;
|
||||||
|
|
||||||
const MANIFEST_FILE_NAME: &str = "__test__.jsonc";
|
const MANIFEST_FILE_NAME: &str = "__test__.jsonc";
|
||||||
|
|
||||||
|
static NO_CAPTURE: Lazy<bool> =
|
||||||
|
Lazy::new(|| std::env::args().any(|arg| arg == "--nocapture"));
|
||||||
|
|
||||||
#[derive(Clone, Deserialize)]
|
#[derive(Clone, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
enum VecOrString {
|
enum VecOrString {
|
||||||
|
@ -178,7 +182,9 @@ pub fn main() {
|
||||||
let _http_guard = test_util::http_server();
|
let _http_guard = test_util::http_server();
|
||||||
file_test_runner::run_tests(
|
file_test_runner::run_tests(
|
||||||
&root_category,
|
&root_category,
|
||||||
file_test_runner::RunOptions { parallel: true },
|
file_test_runner::RunOptions {
|
||||||
|
parallel: !*NO_CAPTURE,
|
||||||
|
},
|
||||||
run_test,
|
run_test,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -373,6 +379,12 @@ fn run_step(
|
||||||
Some(command_name) => command.name(command_name),
|
Some(command_name) => command.name(command_name),
|
||||||
None => command,
|
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();
|
let output = command.run();
|
||||||
if step.output.ends_with(".out") {
|
if step.output.ends_with(".out") {
|
||||||
let test_output_path = cwd.join(&step.output);
|
let test_output_path = cwd.join(&step.output);
|
||||||
|
|
|
@ -93,6 +93,9 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"repeat": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -387,7 +387,7 @@ pub struct TestCommandBuilder {
|
||||||
args_text: String,
|
args_text: String,
|
||||||
args_vec: Vec<String>,
|
args_vec: Vec<String>,
|
||||||
split_output: bool,
|
split_output: bool,
|
||||||
debug_output: bool,
|
show_output: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestCommandBuilder {
|
impl TestCommandBuilder {
|
||||||
|
@ -407,7 +407,7 @@ impl TestCommandBuilder {
|
||||||
command_name: "deno".to_string(),
|
command_name: "deno".to_string(),
|
||||||
args_text: "".to_string(),
|
args_text: "".to_string(),
|
||||||
args_vec: Default::default(),
|
args_vec: Default::default(),
|
||||||
debug_output: false,
|
show_output: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,8 +489,8 @@ impl TestCommandBuilder {
|
||||||
/// Not deprecated, this is just here so you don't accidentally
|
/// Not deprecated, this is just here so you don't accidentally
|
||||||
/// commit code with this enabled.
|
/// commit code with this enabled.
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
pub fn debug_output(mut self) -> Self {
|
pub fn show_output(mut self) -> Self {
|
||||||
self.debug_output = true;
|
self.show_output = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,15 +662,15 @@ impl TestCommandBuilder {
|
||||||
let (stderr_reader, stderr_writer) = pipe().unwrap();
|
let (stderr_reader, stderr_writer) = pipe().unwrap();
|
||||||
command.stdout(stdout_writer);
|
command.stdout(stdout_writer);
|
||||||
command.stderr(stderr_writer);
|
command.stderr(stderr_writer);
|
||||||
let debug_output = self.debug_output;
|
let show_output = self.show_output;
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
Some((
|
Some((
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
read_pipe_to_string(stdout_reader, debug_output)
|
read_pipe_to_string(stdout_reader, show_output)
|
||||||
}),
|
}),
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
read_pipe_to_string(stderr_reader, debug_output)
|
read_pipe_to_string(stderr_reader, show_output)
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
|
@ -695,7 +695,7 @@ impl TestCommandBuilder {
|
||||||
drop(command);
|
drop(command);
|
||||||
|
|
||||||
let combined = combined_reader.map(|pipe| {
|
let combined = combined_reader.map(|pipe| {
|
||||||
sanitize_output(read_pipe_to_string(pipe, self.debug_output), &args)
|
sanitize_output(read_pipe_to_string(pipe, self.show_output), &args)
|
||||||
});
|
});
|
||||||
|
|
||||||
let status = process.wait().unwrap();
|
let status = process.wait().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue