mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
feat(test): add quiet flag (#4894)
This commit is contained in:
parent
e10ee045ed
commit
fe5b151755
3 changed files with 13 additions and 6 deletions
|
@ -65,6 +65,7 @@ pub enum DenoSubcommand {
|
|||
},
|
||||
Test {
|
||||
fail_fast: bool,
|
||||
quiet: bool,
|
||||
allow_none: bool,
|
||||
include: Option<Vec<String>>,
|
||||
filter: Option<String>,
|
||||
|
@ -546,6 +547,7 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
|
||||
let failfast = matches.is_present("failfast");
|
||||
let allow_none = matches.is_present("allow_none");
|
||||
let quiet = matches.is_present("quiet");
|
||||
let filter = matches.value_of("filter").map(String::from);
|
||||
let include = if matches.is_present("files") {
|
||||
let files: Vec<String> = matches
|
||||
|
@ -560,6 +562,7 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
|
||||
flags.subcommand = DenoSubcommand::Test {
|
||||
fail_fast: failfast,
|
||||
quiet,
|
||||
include,
|
||||
filter,
|
||||
allow_none,
|
||||
|
@ -2312,6 +2315,7 @@ mod tests {
|
|||
fail_fast: false,
|
||||
filter: None,
|
||||
allow_none: true,
|
||||
quiet: false,
|
||||
include: Some(svec!["dir1/", "dir2/"]),
|
||||
},
|
||||
allow_read: true,
|
||||
|
@ -2330,6 +2334,7 @@ mod tests {
|
|||
subcommand: DenoSubcommand::Test {
|
||||
fail_fast: false,
|
||||
allow_none: false,
|
||||
quiet: false,
|
||||
filter: Some("foo".to_string()),
|
||||
include: Some(svec!["dir1"]),
|
||||
},
|
||||
|
|
|
@ -481,6 +481,7 @@ async fn test_command(
|
|||
flags: Flags,
|
||||
include: Option<Vec<String>>,
|
||||
fail_fast: bool,
|
||||
quiet: bool,
|
||||
allow_none: bool,
|
||||
filter: Option<String>,
|
||||
) -> Result<(), ErrBox> {
|
||||
|
@ -501,7 +502,7 @@ async fn test_command(
|
|||
let test_file_url =
|
||||
Url::from_file_path(&test_file_path).expect("Should be valid file url");
|
||||
let test_file =
|
||||
test_runner::render_test_file(test_modules, fail_fast, filter);
|
||||
test_runner::render_test_file(test_modules, fail_fast, quiet, filter);
|
||||
let main_module =
|
||||
ModuleSpecifier::resolve_url(&test_file_url.to_string()).unwrap();
|
||||
let mut worker =
|
||||
|
@ -582,12 +583,12 @@ pub fn main() {
|
|||
DenoSubcommand::Run { script } => run_command(flags, script).boxed_local(),
|
||||
DenoSubcommand::Test {
|
||||
fail_fast,
|
||||
quiet,
|
||||
include,
|
||||
allow_none,
|
||||
filter,
|
||||
} => {
|
||||
test_command(flags, include, fail_fast, allow_none, filter).boxed_local()
|
||||
}
|
||||
} => test_command(flags, include, fail_fast, quiet, allow_none, filter)
|
||||
.boxed_local(),
|
||||
DenoSubcommand::Completions { buf } => {
|
||||
if let Err(e) = write_to_stdout_ignore_sigpipe(&buf) {
|
||||
eprintln!("{}", e);
|
||||
|
|
|
@ -63,6 +63,7 @@ pub fn prepare_test_modules_urls(
|
|||
pub fn render_test_file(
|
||||
modules: Vec<Url>,
|
||||
fail_fast: bool,
|
||||
quiet: bool,
|
||||
filter: Option<String>,
|
||||
) -> String {
|
||||
let mut test_file = "".to_string();
|
||||
|
@ -72,9 +73,9 @@ pub fn render_test_file(
|
|||
}
|
||||
|
||||
let options = if let Some(filter) = filter {
|
||||
json!({ "failFast": fail_fast, "filter": filter })
|
||||
json!({ "failFast": fail_fast, "reportToConsole": !quiet, "disableLog": quiet, "filter": filter })
|
||||
} else {
|
||||
json!({ "failFast": fail_fast })
|
||||
json!({ "failFast": fail_fast, "reportToConsole": !quiet, "disableLog": quiet })
|
||||
};
|
||||
|
||||
let run_tests_cmd = format!("Deno.runTests({});\n", options);
|
||||
|
|
Loading…
Reference in a new issue