tools: make cmuxTests wiring deterministic
Reviewer summary
Makes cmuxTests wiring repeatable and visible. New tests are added to the right Xcode target, incomplete entries are repaired, and --check catches drift before CI can report that zero tests ran.
What changed
Add a repo-owned ./scripts/sync-test-wiring authoring path for direct cmuxTests/*.swift files so a newly created test cannot silently miss the Xcode unit-test target.
- deterministically reconciles PBXFileReference, PBXBuildFile, the
cmuxTestsgroup child, and thecmuxTestsSources phase - preserves existing identifiers where possible and derives stable SHA-256-based 24-character identifiers for new objects
- repairs incomplete same-target wiring and same-target duplicates
- rejects membership in
cmux,cmuxUITests, or any other Sources target with an explicit diagnostic - treats only direct
cmuxTests/*.swiftentries as managed, preserving intentional nested/SOURCE_ROOT references - supports
--checkand--dry-run; reruns are byte-for-byte idempotent - keeps
lint-pbxproj-test-wiring.shas the defensive Sources-phase guard
The live project also had three inconsistencies that the stronger sync model exposed: two test Sources entries were missing their PBXBuildFile objects, and one test had duplicate same-target file/build membership. This PR repairs those entries without changing target scope.
Tests
python3 -m py_compile scripts/sync_test_wiring.py tests/test_sync_test_wiring.pybash -n scripts/sync-test-wiring scripts/lint-pbxproj-test-wiring.shpython3 tests/test_sync_test_wiring.py— 14 fixture tests pass- verified current project wiring across 974 direct
cmuxTests/*.swiftfiles: zero missing/duplicate/wrong-target/stale entries after reconciliation - fixture coverage proves add, idempotent rerun, incomplete repair, wrong-target rejection, deletion detection/pruning, deterministic output, pbxproj normalization compatibility, and agreement with the existing lint
- review hardening covers OpenStep quoting for
+filenames, multiline file references, stale display-comment repair by object identity, and duplicate same-path references in foreign targets
Tact #79, Lane R.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes Tact #79 by adding ./scripts/sync-test-wiring, so a new cmuxTests/*.swift file can no longer silently miss Xcode wiring and pass CI with “Executed 0 tests.”
Behavior
- Reconciles
PBXFileReference,PBXBuildFile, thecmuxTestsgroup child, and thecmuxTestsSources phase, preserving existing identifiers where possible. - New objects get stable SHA-256-based 24-character IDs, making reruns byte-for-byte idempotent; supports
--checkand--dry-run. - Repairs incomplete wiring, collapses same-target duplicates, prunes deleted files, and rejects membership in any other Sources target.
- Handles hand-edited layouts with multiple pbxproj objects on one line or multiline file references; only direct
cmuxTests/*.swiftfiles are managed. - Keeps build-phase blank lines where
normalize-pbxproj.pyputs them so synced output passescheck-pbxproj.sh. - Fixes three current inconsistencies: two test Sources entries missing
PBXBuildFileobjects and one duplicate file/build membership. - Updates
CLAUDE.mdand thecmux-testingskill; the existing lint stays as the defensive guard.
Validation
- Adds fixture tests for add, repair, deletion, wrong-target rejection, duplicate collapse, stale comment repair, multiline parsing, deterministic output, idempotence,
normalize-pbxproj.pycompatibility, and lint agreement. test_ci_pbxproj_test_wiring.shnow requires both the lint andsync-test-wiring --checkto pass.- Verified the reconciled project across all 974 direct
cmuxTests/*.swiftfiles with zero stale entries.
Summary by CodeRabbit
-
New Features
- Added a command-line tool to synchronize Swift test files with the Xcode test target.
- Added read-only validation and dry-run modes to verify or preview project wiring changes.
- Added clear diagnostics for ambiguous or incorrectly targeted test files.
-
Bug Fixes
- Corrected test-target inclusion for notification delivery and event tests.
- Removed stale test references from the Xcode project.
-
Documentation
- Updated testing guidance to use the synchronization tool after adding, renaming, or deleting tests.