From 32855f2c853b7f30a92d4cb95549cba8abfd44e5 Mon Sep 17 00:00:00 2001 From: "Yasser A.Idrissi" Date: Mon, 12 Jul 2021 11:55:42 +0100 Subject: feat: Add support for "deno test --fail-fast=N" (#11316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cli/tools/test_runner.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cli/tools/test_runner.rs') 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, test_modules: Vec, no_run: bool, - fail_fast: bool, + fail_fast: Option, quiet: bool, allow_none: bool, filter: Option, @@ -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; + } } } -- cgit v1.2.3