Skip to content

fix: reject JUnit testcases without a name instead of merging them into one check

Choose a tag to compare

@noteflowai noteflowai released this 07 Nov 18:48
· 10 commits to main since this release
c5d3e9d

evalarc diff now rejects JUnit XML that contains a whose name attribute is missing, empty or whitespace-only. Before this fix, the JUnit loader (_junit in src/evalarc/results_diff.py) built IDs such as corpus::None or corpus:: for these testcases and merged every unnamed testcase in a suite into one check. A swapped failure ([fail, pass] in the baseline, [pass, fail] in the current run) then tallied 1/2 on both sides, was classified as unchanged, and the gate exited 0. Loading now raises a ValueError that names the suite and the testcase's 0-based position among the suite's direct testcase children. A suite without a name is shown as (unnamed suite). evalarc diff exits 2 through its existing unusable-input path and prints the message on stderr, whichever input contains the unnamed testcase. Named testcases keep their exact IDs, and identical classname::name entries still load as repeated attempts of one check. docs/ci-gate.md and docs/ci-gate.zh-CN.md list this case among the exit-2 causes. Controller results: the controller ran tests/test_feature_5e40b6f9743a.py in a run labeled acceptance-before. That run had 4 failures and 2 passes. The failures show the old behavior: the swapped-failure diff returned 0 and printed 'Unchanged: 1', and the blank-name and unnamed-suite cases did not raise. On candidate commit 5fa8973 the controller ran the acceptance file, the full pytest suite, ruff check, ruff format --check, scripts/build_site.py and scripts/check_site.cjs, and all of them exited 0. I wrote this metadata from those receipts and ran nothing myself.

Use it

Prerequisites: a POSIX shell and an EvalArc install that includes commit 5fa8973, with evalarc on PATH. All files below are SYNTHETIC, hand-written examples.

  1. Unnamed testcases are rejected:
    cat > baseline.xml <<'EOF'
EOF cat > current.xml <<'EOF' EOF evalarc diff baseline.xml current.xml; echo "exit=$?" Expected: exit=2, and stderr contains: JUnit testcase at position 0 in suite 'corpus' has no name attribute; each testcase needs a name to be compared. Re-export the results with test names or fix the XML.
  1. To recover, re-export from the runner with test names, or edit the XML by hand. Each testcase needs a name that is unique within its suite and the same for that test in both runs:
    cat > baseline.xml <<'EOF'
EOF cat > current.xml <<'EOF' EOF evalarc diff baseline.xml current.xml; echo "exit=$?" Expected: exit=1, with corpus::test_b regressed and corpus::test_a improved.

Do not give both testcases the same name. Identical classname::name entries load as repeated attempts of one check, so the swapped failure would again read as unchanged.

These expected results match what the acceptance tests assert for equivalent synthetic XML. The controller did not run these exact shell commands. To run the controller-verified tests: python -m pytest -q tests/test_feature_5e40b6f9743a.py

Scope and upgrade

Scope: the change is one validation in the JUnit loader, its exit-2 behavior through evalarc diff, the two ci-gate docs and one acceptance file. Non-goals: named testcases with the same classname and name are still treated as repeated attempts, with no new duplicate detection. Inspect, promptfoo, report rendering and gate classification are unchanged. Unnamed testcases are not named or repaired automatically. Only the first unnamed testcase in document order is reported. Compatibility: JUnit files with unnamed testcases used to load with merged, misleading results. They now exit 2. Evidence: all test inputs are hand-written synthetic XML. The passing tests show the specified behavior on those inputs only. They do not show which real exporters emit unnamed testcases, or how often. The bundled examples/results-diff/junit fixtures were not read. The claim that they contain only named testcases is an inference from the IDs the tests assert, and the passing full suite is consistent with it. The claim that the acceptance-before run used pre-fix code is an inference from the run label and the failure output. The usage warning that identically named swapped testcases read as unchanged is an inference from the documented repeated-attempt behavior. The acceptance tests assert only that such testcases load as one check with two attempts. Browser evidence: the controller's site check ran the existing showcase browser regression checks at widths 1440, 390 and 320 and in offline modes, and they passed. Those checks cover existing showcase pages, not this change. This CLI change has no UI, so no visual review applies. The CHANGELOG.md formatting that an earlier review flagged ( without backticks) was not inspected for this metadata, and this delivery makes no claim that it was fixed.

To upgrade, install the EvalArc release that contains commit 5fa8973. Stored data, schemas and report formats are unchanged. If a pipeline starts exiting 2 with the 'has no name attribute' message, re-export the results from the test runner with test names, or add name attributes to the elements. Each name must be unique within its suite and the same for that test in the baseline and current runs. Then rerun evalarc diff. To roll back, pin the previous EvalArc version. Rolling back restores the old behavior of merging unnamed testcases into one check, which can hide swapped failures. Files written by either version need no migration.

Verification

  • Source: #97
  • Version: 0.23.1
  • Verified source commit: c5d3e9d284ab11d8bb231bca5860af5b7f48af6c
  • Behavioral acceptance and the repository's release checks passed.

Authored and reviewed with agent assistance; no human review is claimed.