Skip to content

Add xcprojformatter end-to-end contract tests - #2

Open
Hokila wants to merge 1 commit into
apple:mainfrom
Hokila:test/xcprojformatter-e2e
Open

Hokila wants to merge 1 commit into
apple:mainfrom
Hokila:test/xcprojformatter-e2e

Conversation

@Hokila

@Hokila Hokila commented Sep 17, 2026

Copy link
Copy Markdown

Type of change

  • Test addition

Summary

Add end-to-end tests for the compiled xcprojformatter executable to catch regressions in CLI input/output handling, formatting, and in-place updates. A malformed update must fail without changing the original file.

Related issue

Standalone coverage of existing functionality; no related issue.

Changes

  • Add XcodeProjectToolTests with seven CLI tests covering help, stdin/stdout, positional input, inner and outer project paths, file output, and successful and failed in-place updates.
  • Check formatting against a minimal checked-in golden fixture and verify successful output can be decoded.
  • Locate the executable in the active test build's products directory, using BUILT_PRODUCTS_DIR or the test/resource bundle location. XCPROJFORMATTER_PATH can explicitly select an executable. Missing executables fail with the attempted path; discovery does not recursively scan directories or fall back to other builds.
  • Use temporary files for subprocess input/output and a 30-second timeout. On timeout, terminate the process, force termination after a one-second grace period if needed, and include captured output in the error.
  • Add three helper regression tests for missing-executable isolation, output larger than pipe capacity, and cleanup of a process that ignores termination.

No production code, CLI behavior, public API, or schema changes. Full CLI error-matrix coverage is outside this PR.

Testing

Validated locally on macOS with Xcode 27.2 beta:

  • swift test
  • swift test -c release
  • Native SwiftPM build with a fresh scratch directory: swift test --build-system native --scratch-path <temporary-directory> --filter 'XcodeProjectToolTests|ToolTestSupportTests'
  • Xcode clean package tests with fresh DerivedData: xcodebuild -scheme xcode-project-format-Package -destination 'platform=macOS' -derivedDataPath <temporary-directory> clean test
  • git diff --check

All 10 new tests pass. Existing performance tests are cancelled by the repository's performance-test guard in the tested configurations; these runs do not claim performance-test coverage. Other platforms were not validated.

Checklist

  • I have read CONTRIBUTING.md.
  • The change is in scope: tests for existing functionality.
  • Code follows the project's existing testing conventions.
  • Changes have been reviewed, including executable selection and subprocess cleanup.
  • Test configuration and validation are documented above; no public documentation changes are needed.

@Hokila

Hokila commented Sep 17, 2026

Copy link
Copy Markdown
Author

Two integration questions for maintainer guidance:

  1. Executable location: The tests use BUILT_PRODUCTS_DIR or the active test/resource bundle's adjacent products directory. XCPROJFORMATTER_PATH provides an explicit override. Missing executables fail without searching other builds. Does this fit the repository's internal test setup?
  2. CI coverage: Is CI maintained outside this repository, and will it include the new XcodeProjectToolTests target?

Local validation passes with Xcode 27.2 beta: full SwiftPM Debug and Release runs, focused tests with the native SwiftPM build system and fresh scratch directory, and Xcode clean package tests with fresh DerivedData. The 10 new tests include executable-discovery isolation, large-output capture, and timeout cleanup. Existing performance tests are cancelled by the repository's guard in the tested configurations.

@Hokila
Hokila requested a review from owenv as a code owner September 17, 2026 15:47
Cover CLI input/output and in-place updates with golden fixtures. Resolve the executable from the current build and bound subprocess execution, with regression tests for discovery isolation, large output, and timeout cleanup.
@Hokila
Hokila force-pushed the test/xcprojformatter-e2e branch from d404017 to 3fdc001 Compare September 17, 2026 16:13
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.

1 participant