tools: make cmuxTests wiring deterministic

Merged
TE
2mo ago
+2040-159

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 cmuxTests group child, and the cmuxTests Sources 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/*.swift entries as managed, preserving intentional nested/SOURCE_ROOT references
  • supports --check and --dry-run; reruns are byte-for-byte idempotent
  • keeps lint-pbxproj-test-wiring.sh as 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.py
  • bash -n scripts/sync-test-wiring scripts/lint-pbxproj-test-wiring.sh
  • python3 tests/test_sync_test_wiring.py: 14 fixture tests pass
  • verified current project wiring across 974 direct cmuxTests/*.swift files: 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.

Replaces https://github.com/manaflow-ai/cmux/pull/13053 (same commits, head branch moved into the org so it gets the build cache and can be kept current with main).

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Makes direct cmuxTests/*.swift wiring deterministic for Tact #79. Instead of silently skipping files with "Executed 0 tests," ./scripts/sync-test-wiring now reconciles their Xcode project entries and rejects foreign-target membership with an explicit diagnostic.

  • Repairs missing, duplicate, stale, and deleted entries while preserving object identities, neighboring objects, shared sources owned by other groups, nested references, and SOURCE_ROOT references.
  • --check and --dry-run are read-only; reruns are idempotent, and output matches normalize-pbxproj.py ordering, including blank-line placement in the cmuxTests Sources phase.
  • CI runs sync-test-wiring --check alongside lint-pbxproj-test-wiring.sh, with fixtures covering repairs, deletion, duplicates, target safety, normalization, and stale comments.
  • Repairs the live project by restoring section markers main dropped, adding Sources entries for two cloud notification tests, migrating those tests to current owners, and removing duplicate CmuxTuiSurfaceProviderRegistryPollingTests wiring.

Summary by CodeRabbit

  • New Features

    • Added automated synchronization for Swift test files and Xcode project test-target wiring.
    • Added validation and preview modes to check for inconsistencies without modifying files.
    • Added clearer guidance when test files are missing from the test target.
  • Documentation

    • Updated testing guidance to recommend the synchronization workflow after adding, renaming, or deleting tests.
  • Tests

    • Added comprehensive coverage for synchronization, validation, duplicate entries, deleted files, and invalid target membership.
    • Registered new notification-related test files in the test target.