summaryrefslogtreecommitdiff
path: root/cli/args/flags.rs
diff options
context:
space:
mode:
authorValentin Anger <syrupthinker@gryphno.de>2023-08-26 01:19:23 +0200
committerGitHub <noreply@github.com>2023-08-26 01:19:23 +0200
commita526cff0a9888a475d5b542efda443fe720a93d0 (patch)
tree9e6245c6ce5af9c25bd9cac11bd591d609edd504 /cli/args/flags.rs
parent8bb4e10881730576bbb82e54ede1ebf5931194c3 (diff)
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 ... ```
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r--cli/args/flags.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 544123887..773c95fec 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -225,6 +225,7 @@ pub enum TestReporterConfig {
Pretty,
Dot,
Junit,
+ Tap,
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
@@ -1980,7 +1981,7 @@ Directory arguments are expanded to all contained files matching the glob
Arg::new("reporter")
.long("reporter")
.help("Select reporter to use. Default to 'pretty'.")
- .value_parser(["pretty", "dot", "junit"])
+ .value_parser(["pretty", "dot", "junit", "tap"])
)
)
}
@@ -3369,13 +3370,14 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
"pretty" => TestReporterConfig::Pretty,
"junit" => TestReporterConfig::Junit,
"dot" => TestReporterConfig::Dot,
+ "tap" => TestReporterConfig::Tap,
_ => unreachable!(),
}
} else {
TestReporterConfig::Pretty
};
- if matches!(reporter, TestReporterConfig::Dot) {
+ if matches!(reporter, TestReporterConfig::Dot | TestReporterConfig::Tap) {
flags.log_level = Some(Level::Error);
}
@@ -6839,6 +6841,21 @@ mod tests {
}
);
+ let r = flags_from_vec(svec!["deno", "test", "--reporter=tap"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Test(TestFlags {
+ reporter: TestReporterConfig::Tap,
+ ..Default::default()
+ }),
+ no_prompt: true,
+ type_check_mode: TypeCheckMode::Local,
+ log_level: Some(Level::Error),
+ ..Flags::default()
+ }
+ );
+
let r = flags_from_vec(svec![
"deno",
"test",