From 55eedb46179f288df03247acfea88475e2617a65 Mon Sep 17 00:00:00 2001 From: zombieli Date: Fri, 16 Oct 2026 22:07:12 +0800 Subject: [PATCH] Fix verify exit status for skipped testcases with failures or errors --- src/junitparser/cli.py | 2 +- tests/test_cli.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/junitparser/cli.py b/src/junitparser/cli.py index 0695a93..3639586 100644 --- a/src/junitparser/cli.py +++ b/src/junitparser/cli.py @@ -28,7 +28,7 @@ def verify(paths): xml = JUnitXml.fromfile(path) for suite in xml: for case in suite: - if not case.is_passed and not case.is_skipped: + if case.is_failure or case.is_error: return 1 return 0 diff --git a/tests/test_cli.py b/tests/test_cli.py index 86de610..56e1073 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -15,6 +15,28 @@ def test_verify(file: str, expected_exitcode: int): assert cli.verify([path]) == expected_exitcode +@pytest.mark.parametrize( + "results, expected_exitcode", + [ + ("", 0), + ("", 0), + ("", 1), + ("", 1), + ("", 1), + ("", 1), + ("", 1), + ("", 1), + ], +) +def test_verify_mixed_results(tmp_path, results, expected_exitcode): + path = tmp_path / "report.xml" + path.write_text( + f'{results}' + ) + + assert cli.main(["verify", str(path)]) == expected_exitcode + + def test_merge(tmp_path: Path): files = [DATA_DIR / "jenkins.xml", DATA_DIR / "pytest_success.xml"] suites = ["JUnitXmlReporter", "JUnitXmlReporter.constructor", "pytest"]