|
25 | 25 | # Real JUnit report with the 3 tests. One test passed, but there is an error at test teardown. |
26 | 26 | # Note that pytest incorrectly reports 4 tests instead of 3. |
27 | 27 | # https://github.com/intel/intel-xpu-backend-for-triton/issues/4341. |
28 | | -JUNIT_XML_REPORT = """\ |
| 28 | +JUNIT_XML_REPORT1 = """\ |
29 | 29 | <?xml version="1.0" encoding="utf-8"?> |
30 | 30 | <testsuites> |
31 | 31 | <testsuite name="pytest" errors="1" failures="0" skipped="2" tests="4" time="31.615" timestamp="2025-05-28T15:26:42.685704+00:00" hostname="example"> |
|
36 | 36 | </testsuites> |
37 | 37 | """ |
38 | 38 |
|
| 39 | +# JUnit report with the same test reported twice: one for test failure, another for error at teardown |
| 40 | +# https://github.com/intel/intel-xpu-backend-for-triton/issues/4331. |
| 41 | +JUNIT_XML_REPORT2 = """\ |
| 42 | +<?xml version="1.0" encoding="utf-8"?> |
| 43 | +<testsuites> |
| 44 | + <testsuite> |
| 45 | + <testcase classname="python.test.unit.runtime.test_compilation_listener" name="test_compile_stats"> |
| 46 | + <failure/> |
| 47 | + </testcase> |
| 48 | + <testcase classname="python.test.unit.runtime.test_compilation_listener" name="test_compile_stats"> |
| 49 | + <error/> |
| 50 | + </testcase> |
| 51 | + </testsuite> |
| 52 | +</testsuites> |
| 53 | +""" |
| 54 | + |
39 | 55 |
|
40 | 56 | def test_get_warnings_empty_file(tmp_path): |
41 | 57 | warnings_path = tmp_path / 'suite-warnings.json' |
@@ -86,12 +102,23 @@ def test_generate_junit_report(tmp_path): |
86 | 102 | assert stats[0].total == 3 |
87 | 103 |
|
88 | 104 |
|
89 | | -def test_parse_report(tmp_path): |
| 105 | +def test_parse_report_ignore_tests_attribute(tmp_path): |
90 | 106 | report_path = tmp_path / 'suite.xml' |
91 | | - report_path.write_text(JUNIT_XML_REPORT) |
| 107 | + report_path.write_text(JUNIT_XML_REPORT1) |
92 | 108 | stats = pass_rate.parse_report(report_path) |
93 | 109 | assert stats.passed == 0 |
94 | 110 | assert stats.xfailed == 2 |
95 | 111 | assert stats.failed == 1 |
96 | 112 | assert stats.skipped == 0 |
97 | 113 | assert stats.total == 3 |
| 114 | + |
| 115 | + |
| 116 | +def test_parse_report_duplicate_test(tmp_path): |
| 117 | + report_path = tmp_path / 'suite.xml' |
| 118 | + report_path.write_text(JUNIT_XML_REPORT2) |
| 119 | + stats = pass_rate.parse_report(report_path) |
| 120 | + assert stats.passed == 0 |
| 121 | + assert stats.xfailed == 0 |
| 122 | + assert stats.failed == 1 |
| 123 | + assert stats.skipped == 0 |
| 124 | + assert stats.total == 1 |
0 commit comments