Skip to content

Commit

Permalink
Merge pull request #125 from mikepenz/feature/105_2
Browse files Browse the repository at this point in the history
Improved test suite name recovery
  • Loading branch information
mikepenz authored Apr 16, 2021
2 parents 1f3f85c + 684a18d commit f74a8de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
20 changes: 10 additions & 10 deletions __tests__/testParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
"start_column": 0,
"end_column": 0,
"annotation_level": "failure",
"title": "A.TestA/A",
"title": "A.All tests/tests/packet/TestA/A",
"message": "failure",
"raw_details": ""
}, {
Expand All @@ -285,7 +285,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
"start_column": 0,
"end_column": 0,
"annotation_level": "failure",
"title": "B.TestB/B",
"title": "B.All tests/tests/packet/TestB/B",
"message": "failure",
"raw_details": ""
}, {
Expand All @@ -295,14 +295,14 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
"start_column": 0,
"end_column": 0,
"annotation_level": "failure",
"title": "A.A",
"title": "A.All tests/tests/packet/A",
"message": "failure",
"raw_details": ""
}]);
});

it('should parse disabled tests', async () => {
const { count, skipped, annotations } = await parseFile('test_results/issues/testDisabled.xml');
const { count, skipped, annotations } = await parseFile('test_results/issues/testDisabled.xml', '*');

expect(count).toBe(22);
expect(skipped).toBe(10);
Expand All @@ -313,7 +313,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "factorial_of_value_from_fixture.factorial_of_value_from_fixture",
title: "factorial_of_value_from_fixture.factorial/factorial_of_value_from_fixture",
message: "tests/failed/main.cpp:58: error: check_eq(3628800, 3628801)",
raw_details: "",
}, {
Expand All @@ -323,7 +323,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "factorial_of_value_from_fixture[0].factorial_of_value_from_fixture[0]",
title: "factorial_of_value_from_fixture[0].factorial/factorial_of_value_from_fixture[0]",
message: "tests/failed/main.cpp:97: error: condition was false",
raw_details: "",
}, {
Expand All @@ -333,7 +333,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "positive_arguments_must_produce_expected_result.positive_arguments_must_produce_expected_result",
title: "positive_arguments_must_produce_expected_result.factorial/positive_arguments_must_produce_expected_result",
message: "uncaught std::exception: thrown by test",
raw_details: "",
}, {
Expand All @@ -343,7 +343,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "positive_arguments_must_produce_expected_result[2].positive_arguments_must_produce_expected_result[2]",
title: "positive_arguments_must_produce_expected_result[2].factorial/positive_arguments_must_produce_expected_result[2]",
message: "tests/failed/main.cpp:73: error: condition was false",
raw_details: "",
}, {
Expand All @@ -353,7 +353,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "test_which_fails_check_eq_with_custom_message.test_which_fails_check_eq_with_custom_message",
title: "test_which_fails_check_eq_with_custom_message.factorial/test_which_fails_check_eq_with_custom_message",
message: "tests/failed/main.cpp:49: error: check_eq(6, 7): hello world!",
raw_details: "",
}, {
Expand All @@ -363,7 +363,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "test_which_throws_unknown_exception.test_which_throws_unknown_exception",
title: "test_which_throws_unknown_exception.factorial/test_which_throws_unknown_exception",
message: "uncaught unknown exception",
raw_details: "",
}]);
Expand Down
19 changes: 12 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,17 @@ async function parseSuite(
return {count, skipped, annotations}
}

const suiteName = suiteRegex
? parentName
? `${parentName}/${testsuite._attributes.name}`
: testsuite._attributes.name.match(suiteRegex)
? testsuite._attributes.name
: ''
: ''
let suiteName = ''
if (suiteRegex) {
if (parentName) {
suiteName = `${parentName}/${testsuite._attributes.name}`
} else if (suiteRegex !== '*') {
suiteName = testsuite._attributes.name.match(suiteRegex)
}
if (!suiteName) {
suiteName = testsuite._attributes.name
}
}

const res = await parseSuite(testsuite, suiteName, suiteRegex)
count += res.count
Expand Down

0 comments on commit f74a8de

Please sign in to comment.