From 8de4a05f2a93f194f71b959f4d47a1b4fc61aa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 19 Mar 2020 14:26:47 +0100 Subject: fix: std/testing/runner.ts and deno test (#4392) After splitting "failFast" and "exitOnFail" arguments, there was a situation where failing tests did not exit with code 1. * fixed argument value passed to Deno.runTests() in deno test * fixed argument value passed to Deno.runTests() in std/testing/runner.ts * added integration tests for deno test to ensure failFast and exitOnFail work as expected * don't write test file to file system, but keep it in memory --- cli/tests/deno_test.out | 25 +++++++++++++++++++++++++ cli/tests/deno_test_fail_fast.out | 14 ++++++++++++++ cli/tests/integration_tests.rs | 12 ++++++++++++ cli/tests/test_runner_test.ts | 19 +++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 cli/tests/deno_test.out create mode 100644 cli/tests/deno_test_fail_fast.out create mode 100644 cli/tests/test_runner_test.ts (limited to 'cli/tests') diff --git a/cli/tests/deno_test.out b/cli/tests/deno_test.out new file mode 100644 index 000000000..8fe589613 --- /dev/null +++ b/cli/tests/deno_test.out @@ -0,0 +1,25 @@ +running 4 tests +test fail1 ... FAILED [WILDCARD] +test fail2 ... FAILED [WILDCARD] +test success1 ... ok [WILDCARD] +test fail3 ... FAILED [WILDCARD] + +failures: + +fail1 +AssertionError: fail1 assertion +[WILDCARD] + +fail2 +AssertionError: fail2 assertion +[WILDCARD] + +fail3 +AssertionError: fail3 assertion +[WILDCARD] + +failures: +[WILDCARD] + +test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] + diff --git a/cli/tests/deno_test_fail_fast.out b/cli/tests/deno_test_fail_fast.out new file mode 100644 index 000000000..f4d111bcc --- /dev/null +++ b/cli/tests/deno_test_fail_fast.out @@ -0,0 +1,14 @@ +running 4 tests +test fail1 ... FAILED [WILDCARD] + +failures: + +fail1 +AssertionError: fail1 assertion +[WILDCARD] + +failures: +[WILDCARD] + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] + diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 29203d411..51f849ff6 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -899,6 +899,18 @@ itest!(_026_redirect_javascript { http_server: true, }); +itest!(deno_test_fail_fast { + args: "test --failfast test_runner_test.ts", + exit_code: 1, + output: "deno_test_fail_fast.out", +}); + +itest!(deno_test { + args: "test test_runner_test.ts", + exit_code: 1, + output: "deno_test.out", +}); + itest!(workers { args: "test --reload --allow-net workers_test.ts", http_server: true, diff --git a/cli/tests/test_runner_test.ts b/cli/tests/test_runner_test.ts new file mode 100644 index 000000000..006eca07c --- /dev/null +++ b/cli/tests/test_runner_test.ts @@ -0,0 +1,19 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +import { assert } from "../../std/testing/asserts.ts"; + +Deno.test(function fail1() { + assert(false, "fail1 assertion"); +}); + +Deno.test(function fail2() { + assert(false, "fail2 assertion"); +}); + +Deno.test(function success1() { + assert(true); +}); + +Deno.test(function fail3() { + assert(false, "fail3 assertion"); +}); -- cgit v1.2.3