Skip to content

fix: count XCTest suite totals once per run - #84

Merged
alexey1312 merged 1 commit into
masterfrom
claude/xcsift-issue-83-cec408
Aug 18, 2026
Merged

fix: count XCTest suite totals once per run#84
alexey1312 merged 1 commit into
masterfrom
claude/xcsift-issue-83-cec408

Conversation

@alexey1312

Copy link
Copy Markdown
Collaborator

Problem

XCTest prints the same Executed N tests line at each suite level: the nested suite, the .xctest bundle, and the Selected tests/All tests wrapper.

StreamingOutputParser added the wrapper count to the bundle count. += is correct for two .xctest bundles, because their tests are disjoint. The wrapper is not a sibling bundle — it contains the bundles, so the same tests were counted twice:

swift test --filter PluginFilesTests 2>&1 | xcsift -f toon
# passed_tests: 8   <- XCTest ran 4

A full run prints All tests, which failed the same condition and fell into the ignored fallback. This hid the defect outside of --filter.

The parser also added the duration of every summary line, so test_time counted each level again.

Fix

  • Count the .xctest bundles only. The wrapper falls into the fallback slot, which the parser reads only when no bundle line exists — and there the wrapper is the last summary line, so the count stays correct.
  • Read the run duration from the same suite level as the counts (resolvedXCTestDuration()).
  • Rename testTimeAccumulator to swiftTestingTimeAccumulator, because it now holds the Swift Testing time only.
  • Remove the selectedTestsSuite constant, which lost its last reference.

Result

Command Before After Actual
swift test --filter … (2 tests) passed_tests: 4, test_time: 0.006s 2, 0.003s 2, 0.003s
swift test (full) 435, ~45s 435, 15.157s 435, 15.157s

A filtered run with failures reported twice the failures. It now reports the true count.

Tests

Four regression cases in Tests/XCSiftCoreTests/ParsingTests.swift:

  • passed count with the three repeated summary lines
  • failure count with the same repetition
  • test_time across suite levels
  • durations of two separate .xctest bundles still add up (guards the disjoint case)

Full suite: 435 tests, 0 failures.

Fixes #83

XCTest prints the same "Executed N tests" line at each suite level: the
nested suite, the .xctest bundle, and the "Selected tests"/"All tests"
wrapper. The parser added the wrapper count to the bundle count. A
filtered run thus reported twice the tests and twice the failures.

The parser also added every duration line. It reported three times the
real test time.

Count the .xctest bundles only. Read the run duration from the same
suite level as the counts.

Fixes #83
@alexey1312
alexey1312 merged commit 542a6e9 into master Aug 18, 2026
2 checks passed
@alexey1312
alexey1312 deleted the claude/xcsift-issue-83-cec408 branch August 18, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xcsift doubles passed_tests when swift test runs with --filter

1 participant