diff --git a/cli/flags.rs b/cli/flags.rs index 86a5405b2f..8236d63db1 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -101,7 +101,7 @@ pub enum DenoSubcommand { Test { doc: bool, no_run: bool, - fail_fast: Option, + fail_fast: Option, quiet: bool, allow_none: bool, include: Option>, @@ -1047,16 +1047,9 @@ fn test_subcommand<'a, 'b>() -> App<'a, 'b> { .takes_value(true) .require_equals(true) .value_name("N") - .validator(|val: String| match val.parse::() { - Ok(val) => { - if val == 0 { - return Err( - "fail-fast should be an number greater than 0".to_string(), - ); - } - Ok(()) - } - Err(_) => Err("fail-fast should be a number".to_string()), + .validator(|val: String| match val.parse::() { + Ok(_) => Ok(()), + Err(_) => Err("fail-fast should be a non zero integer".to_string()), }), ) .arg( @@ -1786,7 +1779,7 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) { if let Some(value) = matches.value_of("fail-fast") { Some(value.parse().unwrap()) } else { - Some(1) + Some(NonZeroUsize::new(1).unwrap()) } } else { None @@ -3663,7 +3656,7 @@ mod tests { subcommand: DenoSubcommand::Test { no_run: false, doc: false, - fail_fast: Some(3), + fail_fast: Some(NonZeroUsize::new(3).unwrap()), filter: None, allow_none: false, quiet: false, @@ -3674,6 +3667,9 @@ mod tests { ..Flags::default() } ); + + let r = flags_from_vec(svec!["deno", "test", "--fail-fast=0"]); + assert!(r.is_err()); } #[test] diff --git a/cli/main.rs b/cli/main.rs index 0c758e6316..45afd03298 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -77,6 +77,7 @@ use std::env; use std::io::Read; use std::io::Write; use std::iter::once; +use std::num::NonZeroUsize; use std::path::PathBuf; use std::pin::Pin; use std::rc::Rc; @@ -1004,7 +1005,7 @@ async fn test_command( include: Option>, no_run: bool, doc: bool, - fail_fast: Option, + fail_fast: Option, quiet: bool, allow_none: bool, filter: Option, diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs index d2612e59dc..a4bc998226 100644 --- a/cli/tools/test_runner.rs +++ b/cli/tools/test_runner.rs @@ -469,7 +469,7 @@ pub async fn run_tests( doc_modules: Vec, test_modules: Vec, no_run: bool, - fail_fast: Option, + fail_fast: Option, quiet: bool, allow_none: bool, filter: Option, @@ -621,7 +621,7 @@ pub async fn run_tests( } if let Some(x) = fail_fast { - if summary.failed >= x { + if summary.failed >= x.get() { break; } }