From ec85b6fd3fc004cd94e3fada5c8e5fe2714fd629 Mon Sep 17 00:00:00 2001 From: amtoine Date: Sun, 19 Mar 2023 10:15:02 +0100 Subject: [PATCH] catch any test error and throw an error this allows the test runner to stop whenever there is a failing test and throw an `$env.LAST_EXIT_CODE` to `1`. --- crates/nu-utils/standard_library/tests.nu | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/nu-utils/standard_library/tests.nu b/crates/nu-utils/standard_library/tests.nu index 4d37a056c..965636e86 100644 --- a/crates/nu-utils/standard_library/tests.nu +++ b/crates/nu-utils/standard_library/tests.nu @@ -15,7 +15,14 @@ def main [] { for test_case in $tests { log debug $"Run test ($module_name) ($test_case)" - nu -c $'use ($test_file) ($test_case); ($test_case)' + try { + nu -c $'use ($test_file) ($test_case); ($test_case)' + } catch { error make { + msg: $"(ansi red)std::tests::test_failed(ansi reset)" + label: { + text: $"($module_name)::($test_case) failed." + } + }} } } }