1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

fix(test): JUnit reporter includes file, line and column attributes (#20174)

Closes #20156
This commit is contained in:
Alexander Michaud 2023-08-17 17:41:29 -04:00 committed by GitHub
parent f343391a9f
commit b5839eefcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 6 deletions

View file

@ -267,6 +267,11 @@ itest!(exit_sanitizer {
exit_code: 1,
});
itest!(junit {
args: "test --reporter junit test/pass.ts",
output: "test/pass.junit.out",
});
itest!(clear_timeout {
args: "test test/clear_timeout.ts",
exit_code: 0,

38
cli/tests/testdata/test/pass.junit.out vendored Normal file
View file

@ -0,0 +1,38 @@
Check [WILDCARD]/testdata/test/pass.ts
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="deno test" tests="16" failures="0" errors="0" time="[WILDCARD]">
<testsuite name="[WILDCARD]/testdata/test/pass.ts" tests="16" disabled="0" errors="0" failures="0">
<testcase name="test 0" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="1" col="6">
</testcase>
<testcase name="test 1" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="2" col="6">
</testcase>
<testcase name="test 2" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="3" col="6">
</testcase>
<testcase name="test 3" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="4" col="6">
</testcase>
<testcase name="test 4" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="5" col="6">
</testcase>
<testcase name="test 5" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="6" col="6">
</testcase>
<testcase name="test 6" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="7" col="6">
</testcase>
<testcase name="test 7" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="8" col="6">
</testcase>
<testcase name="test 8" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="9" col="6">
</testcase>
<testcase name="test 9" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="12" col="6">
</testcase>
<testcase name="test\b" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="16" col="6">
</testcase>
<testcase name="test\f" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="19" col="6">
</testcase>
<testcase name="test\t" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="23" col="6">
</testcase>
<testcase name="test\n" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="27" col="6">
</testcase>
<testcase name="test\r" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="31" col="6">
</testcase>
<testcase name="test\v" time="[WILDCARD]" filename="[WILDCARD]/testdata/test/pass.ts" line="35" col="6">
</testcase>
</testsuite>
</testsuites>

View file

@ -40,13 +40,24 @@ impl JunitTestReporter {
impl TestReporter for JunitTestReporter {
fn report_register(&mut self, description: &TestDescription) {
self.cases.insert(
description.id,
quick_junit::TestCase::new(
description.name.clone(),
quick_junit::TestCaseStatus::skipped(),
),
let mut case = quick_junit::TestCase::new(
description.name.clone(),
quick_junit::TestCaseStatus::skipped(),
);
let file_name = description.location.file_name.clone();
let file_name = file_name.strip_prefix("file://").unwrap_or(&file_name);
case
.extra
.insert(String::from("filename"), String::from(file_name));
case.extra.insert(
String::from("line"),
description.location.line_number.to_string(),
);
case.extra.insert(
String::from("col"),
description.location.column_number.to_string(),
);
self.cases.insert(description.id, case);
}
fn report_plan(&mut self, _plan: &TestPlan) {}