From a526cff0a9888a475d5b542efda443fe720a93d0 Mon Sep 17 00:00:00 2001 From: Valentin Anger Date: Sat, 26 Aug 2023 01:19:23 +0200 Subject: feat(cli/tools): add TAP test reporter (#14390) (#20073) This PR adds a test reporter for the [Test Anything Protocol](https://testanything.org). It makes the following implementation decisions: - No TODO pragma, as there is no such marker in `Deno.test` - SKIP pragma for `ignore`d tests - Test steps are treated as TAP14 subtests - Support for this in consumers seems spotty - Some consumers will incorrectly interpret these markers, resulting in unexpected output - Considering the lack of support, and to avoid implementation complexity, subtests are at most one level deep (all test steps are in the same subtest) - To accommodate consumers that use comments to indicate test-suites (unspecced) - The test module path is output as a comment - This is disabled for `--parallel` testing - Failure diagnostics are output as JSON, which is also valid YAML - The structure is not specified, so the format roughly follows the spec example: ``` --- message: "Failed with error 'hostname peebles.example.com not found'" severity: fail found: hostname: 'peebles.example.com' address: ~ wanted: hostname: 'peebles.example.com' address: '85.193.201.85' at: file: test/dns-resolve.c line: 142 ... ``` --- cli/tests/integration/test_tests.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cli/tests/integration/test_tests.rs') diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 04465dd53..030da05e1 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -356,6 +356,25 @@ itest!(steps_dot_ignored_steps { output: "test/steps/ignored_steps.dot.out", }); +itest!(steps_tap_passing_steps { + args: "test --reporter=tap test/steps/passing_steps.ts", + exit_code: 0, + output: "test/steps/passing_steps.tap.out", +}); + +itest!(steps_tap_failing_steps { + args: "test --reporter=tap test/steps/failing_steps.ts", + exit_code: 1, + envs: vec![("NO_COLOR".to_owned(), "1".to_owned())], + output: "test/steps/failing_steps.tap.out", +}); + +itest!(steps_tap_ignored_steps { + args: "test --reporter=tap test/steps/ignored_steps.ts", + exit_code: 0, + output: "test/steps/ignored_steps.tap.out", +}); + itest!(steps_invalid_usage { args: "test test/steps/invalid_usage.ts", exit_code: 1, -- cgit v1.2.3