diff options
author | Yasser A.Idrissi <getspookydev@gmail.com> | 2021-07-12 11:55:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 12:55:42 +0200 |
commit | 32855f2c853b7f30a92d4cb95549cba8abfd44e5 (patch) | |
tree | ec2b9dbcd7f023ee6be6d941599221276d4275e9 /cli/tools/test_runner.rs | |
parent | 0bc54a0099c70dc05326a2b4a7aa5b0273b1bf1c (diff) |
feat: Add support for "deno test --fail-fast=N" (#11316)
This commit adds support for specifying threshold in the "--fail-fast"
flag for "deno test" subcommand. Previously using "--fail-fast" stopped
running the test suite after first failure and with this change users
may specify number of failed tests that will cause the suite to be interrupted.
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tools/test_runner.rs')
-rw-r--r-- | cli/tools/test_runner.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs index 432935aef..733a3edd5 100644 --- a/cli/tools/test_runner.rs +++ b/cli/tools/test_runner.rs @@ -340,7 +340,7 @@ pub async fn run_tests( doc_modules: Vec<ModuleSpecifier>, test_modules: Vec<ModuleSpecifier>, no_run: bool, - fail_fast: bool, + fail_fast: Option<usize>, quiet: bool, allow_none: bool, filter: Option<String>, @@ -515,6 +515,7 @@ pub async fn run_tests( let mut has_error = false; let mut planned = 0; let mut reported = 0; + let mut failed = 0; for event in receiver.iter() { match event.message.clone() { @@ -538,6 +539,7 @@ pub async fn run_tests( if let TestResult::Failed(_) = result { has_error = true; + failed += 1; } } _ => {} @@ -545,8 +547,10 @@ pub async fn run_tests( reporter.visit_event(event); - if has_error && fail_fast { - break; + if let Some(x) = fail_fast { + if failed >= x { + break; + } } } |