Skip to content

Commit cd0e24b

Browse files
authored
Fix for empty <system-out> and <system-err> (#667)
Fixes #663.
1 parent c541e2e commit cd0e24b

File tree

7 files changed

+149
-15
lines changed

7 files changed

+149
-15
lines changed

python/publish/junit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def get_leaf_suites(suite: TestSuite) -> List[TestSuite]:
259259

260260
def get_text(elem, tag):
261261
child = elem.find(tag)
262-
if child is not None:
262+
if child is not None and child.text is not None:
263263
text = child.text.strip()
264264
return text if text else None
265265
return None
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
'name': 'Test Results',
4+
'head_sha': 'commit sha',
5+
'status': 'completed',
6+
'conclusion': 'success',
7+
'output': {
8+
'title': 'All 1 tests pass in 1s',
9+
'summary':
10+
'1 tests\u2002\u2003\u20031 ✅\u2003\u20031s ⏱️\n1 suites\u2003\u20030 '
11+
'💤\n1 files\u2004\u2002\u2003\u20030 ❌\n\nResults for commit commit '
12+
's.\n\n'
13+
'[test-results]:data:application/gzip;base64,H4sIAAAAAAAC/1WMOw6AIBAFr'
14+
'0KoLbT1MoYgxI18zC5UxruLiAjdm3nJnFyDUcRnNg2MU4RQYY0oAnhXMB2B2r1QlLIXOx'
15+
'xJjFVoAaYTCtFjMRjd13tmm3v5r2VuYpnblvTWQkhQFqNN8OsG6gUbdt0AAAA=\n',
16+
'annotations': [
17+
{
18+
'path': '.github',
19+
'start_line': 0,
20+
'end_line': 0,
21+
'annotation_level': 'notice',
22+
'message': 'There is 1 test, see "Raw output" for the name of the test.',
23+
'title': '1 test found',
24+
'raw_details': 'Suite ‑ test'
25+
}
26+
]
27+
}
28+
}
29+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<testsuite errors="0" failures="0" name="Suite" tests="1" time="1.234" timestamp="2020-09-10T13:34:55">
3+
<testcase name="test" classname="Suite" time="1.234">
4+
</testcase>
5+
<system-out/>
6+
<system-err/>
7+
</testsuite>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
publish.unittestresults.ParsedUnitTestResults(
2+
files=1,
3+
errors=[],
4+
suites=1,
5+
suite_tests=1,
6+
suite_skipped=0,
7+
suite_failures=0,
8+
suite_errors=0,
9+
suite_time=1,
10+
suite_details=[
11+
publish.unittestresults.UnitTestSuite(
12+
name='Suite',
13+
tests=1,
14+
skipped=0,
15+
failures=0,
16+
errors=0,
17+
stdout=None,
18+
stderr=None
19+
)
20+
],
21+
cases=[
22+
publish.unittestresults.UnitTestCase(
23+
result_file='empty-system-out-err.xml',
24+
test_file=None,
25+
line=None,
26+
class_name='Suite',
27+
test_name='test',
28+
result='success',
29+
message=None,
30+
content=None,
31+
stdout=None,
32+
stderr=None,
33+
time=1.234
34+
)
35+
]
36+
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"title": "All 1 tests pass in 1s",
3+
"summary": "1 tests   1 ✅  1s ⏱️\n1 suites  0 💤\n1 files    0 ❌\n\nResults for commit commit s.\n",
4+
"conclusion": "success",
5+
"stats": {
6+
"files": 1,
7+
"errors": [],
8+
"suites": 1,
9+
"duration": 1,
10+
"tests": 1,
11+
"tests_succ": 1,
12+
"tests_skip": 0,
13+
"tests_fail": 0,
14+
"tests_error": 0,
15+
"runs": 1,
16+
"runs_succ": 1,
17+
"runs_skip": 0,
18+
"runs_fail": 0,
19+
"runs_error": 0,
20+
"commit": "commit sha"
21+
},
22+
"annotations": [
23+
{
24+
"path": ".github",
25+
"start_line": 0,
26+
"end_line": 0,
27+
"annotation_level": "notice",
28+
"message": "There is 1 test, see \"Raw output\" for the name of the test.",
29+
"title": "1 test found",
30+
"raw_details": "Suite ‑ test"
31+
}
32+
],
33+
"check_url": "html",
34+
"formatted": {
35+
"stats": {
36+
"files": "1",
37+
"errors": [],
38+
"suites": "1",
39+
"duration": "1",
40+
"tests": "1",
41+
"tests_succ": "1",
42+
"tests_skip": "0",
43+
"tests_fail": "0",
44+
"tests_error": "0",
45+
"runs": "1",
46+
"runs_succ": "1",
47+
"runs_skip": "0",
48+
"runs_fail": "0",
49+
"runs_error": "0",
50+
"commit": "commit sha"
51+
}
52+
}
53+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<testsuite
3+
errors="0" failures="0" name="Suite" tests="1" time="1.234" timestamp="2020-09-10T13:34:55">
4+
<testcase
5+
name="test" classname="Suite" time="1.234">
6+
</testcase>
7+
<system-out></system-out>
8+
<system-err></system-err>
9+
</testsuite>

python/test/test_action_script.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,12 +1010,12 @@ def test_parse_files(self):
10101010
print(call.args[0])
10111011

10121012
self.assertEqual(17, len(l.info.call_args_list))
1013-
self.assertTrue(any([call.args[0].startswith(f"Reading files {prettify_glob_pattern(settings.files_glob)} (76 files, ") for call in l.info.call_args_list]))
1014-
self.assertTrue(any([call.args[0].startswith(f'Reading JUnit XML files {prettify_glob_pattern(settings.junit_files_glob)} (28 files, ') for call in l.info.call_args_list]))
1013+
self.assertTrue(any([call.args[0].startswith(f"Reading files {prettify_glob_pattern(settings.files_glob)} (77 files, ") for call in l.info.call_args_list]))
1014+
self.assertTrue(any([call.args[0].startswith(f'Reading JUnit XML files {prettify_glob_pattern(settings.junit_files_glob)} (29 files, ') for call in l.info.call_args_list]))
10151015
self.assertTrue(any([call.args[0].startswith(f'Reading NUnit XML files {prettify_glob_pattern(settings.nunit_files_glob)} (24 files, ') for call in l.info.call_args_list]))
10161016
self.assertTrue(any([call.args[0].startswith(f'Reading XUnit XML files {prettify_glob_pattern(settings.xunit_files_glob)} (8 files, ') for call in l.info.call_args_list]))
10171017
self.assertTrue(any([call.args[0].startswith(f'Reading TRX files {prettify_glob_pattern(settings.trx_files_glob)} (9 files, ') for call in l.info.call_args_list]))
1018-
self.assertTrue(any([call.args[0].startswith(f'Detected 27 JUnit XML files (') for call in l.info.call_args_list]))
1018+
self.assertTrue(any([call.args[0].startswith(f'Detected 28 JUnit XML files (') for call in l.info.call_args_list]))
10191019
self.assertTrue(any([call.args[0].startswith(f'Detected 24 NUnit XML files (') for call in l.info.call_args_list]))
10201020
self.assertTrue(any([call.args[0].startswith(f'Detected 8 XUnit XML files (') for call in l.info.call_args_list]))
10211021
self.assertTrue(any([call.args[0].startswith(f'Detected 9 TRX files (') for call in l.info.call_args_list]))
@@ -1027,7 +1027,7 @@ def test_parse_files(self):
10271027
self.assertTrue(any([call.args[0].endswith(f'python{os.sep}test{os.sep}files{os.sep}junit-xml{os.sep}non-junit.xml') for call in l.info.call_args_list]))
10281028
self.assertTrue(any([call.args[0].endswith(f'python{os.sep}test{os.sep}files{os.sep}json{os.sep}non-json.json') for call in l.info.call_args_list]))
10291029
self.assertTrue(any([call.args[0].endswith(f'python{os.sep}test{os.sep}files{os.sep}json{os.sep}malformed-json.json') for call in l.info.call_args_list]))
1030-
self.assertTrue(any([call.args[0].startswith(f'Finished reading 145 files in ') for call in l.info.call_args_list]))
1030+
self.assertTrue(any([call.args[0].startswith(f'Finished reading 147 files in ') for call in l.info.call_args_list]))
10311031

10321032
for call in l.debug.call_args_list:
10331033
print(call.args[0])
@@ -1047,16 +1047,16 @@ def test_parse_files(self):
10471047

10481048
self.assertEqual([], gha.method_calls)
10491049

1050-
self.assertEqual(145, actual.files)
1050+
self.assertEqual(147, actual.files)
10511051
self.assertEqual(17, len(actual.errors))
1052-
self.assertEqual(731, actual.suites)
1053-
self.assertEqual(4109, actual.suite_tests)
1052+
self.assertEqual(733, actual.suites)
1053+
self.assertEqual(4111, actual.suite_tests)
10541054
self.assertEqual(214, actual.suite_skipped)
10551055
self.assertEqual(450, actual.suite_failures)
10561056
self.assertEqual(21, actual.suite_errors)
1057-
self.assertEqual(7956, actual.suite_time)
1057+
self.assertEqual(7959, actual.suite_time)
10581058
self.assertEqual(0, len(actual.suite_details))
1059-
self.assertEqual(4085, len(actual.cases))
1059+
self.assertEqual(4087, len(actual.cases))
10601060
self.assertEqual('commit', actual.commit)
10611061

10621062
with io.StringIO() as string:
@@ -1115,7 +1115,7 @@ def test_parse_files_with_suite_details(self):
11151115
**options)
11161116
actual = parse_files(settings, gha)
11171117

1118-
self.assertEqual(363, len(actual.suite_details))
1118+
self.assertEqual(364, len(actual.suite_details))
11191119

11201120
def test_parse_files_no_matches(self):
11211121
gha = mock.MagicMock()
@@ -1202,10 +1202,10 @@ def test_main(self):
12021202

12031203
# Publisher.publish is expected to have been called with these arguments
12041204
results, cases, conclusion = m.call_args_list[0].args
1205-
self.assertEqual(145, results.files)
1206-
self.assertEqual(731, results.suites)
1207-
self.assertEqual(731, len(results.suite_details))
1208-
self.assertEqual(1811, len(cases))
1205+
self.assertEqual(147, results.files)
1206+
self.assertEqual(733, results.suites)
1207+
self.assertEqual(733, len(results.suite_details))
1208+
self.assertEqual(1812, len(cases))
12091209
self.assertEqual('failure', conclusion)
12101210

12111211
def test_main_fork_pr_check_wo_summary(self):

0 commit comments

Comments
 (0)