Skip to content

Test CLI generation through the process runner instead of per-step closures - #195

Merged
lynnswap merged 5 commits into
mainfrom
refactor/cli-process-boundary-tests
Nov 20, 2026
Merged

lynnswap merged 5 commits into
mainfrom
refactor/cli-process-boundary-tests

Conversation

@lynnswap

@lynnswap lynnswap commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

runPrivateHeaderKitCommand and the functions below it take one CommandRunning in place of the closures for the generation client, Simulator resolution and cleanup, helper resolution, release metadata, and source discovery. The CLI tests that replaced those steps now run the real code against a recorded process runner and temporary directories. Command-line syntax, output text, and exit codes do not change.

Details

  • The migrated tests use a GenerationHost fixture: a temporary directory with installed helpers, a macOS system root, and an iOS Simulator runtime, plus a RecordingCommandRunner that answers simctl, sw_vers, and the helper commands. Helper resolution, Simulator sessions, target discovery, the generation executor, the state database, and publication all run for real in these tests.
  • Tests that inspected a captured request now assert on what the run does: the helper commands, the published files, and the output. --resume and --fresh are covered by a new test that leaves an unfinished all-target run and reruns it each way.
  • Source discovery always reads the release metadata of / for the macOS source, so the tests that list sources take the expected seed flag from the Mac they run on.
  • Coverage that was dropped: cancellation thrown from the release-metadata read, which a file read cannot produce (the catch for it is removed), and assertions on values that never leave the process on a macOS run, such as the Simulator helper URL in the request.
  • GenerationLease now unlocks with flock(LOCK_UN) before closing its descriptor. A process spawned while the lease is held keeps a copy of the descriptor until it execs, so closing alone could leave the lock held for a moment and make an immediate re-acquisition fail with "generation lease is already held". The wizard takes the lease twice in a row for an all-target run, and the test process spawns real processes from other tests in parallel, which made the migrated tests fail about once in a hundred runs. The CLI itself does not spawn anything between the two leases.
  • PrivateHeaderKitGenerationClient is removed. The file keeps its name and the functions stay free functions until Move the CLI commands into types that own their dependencies #193 moves them into command types.

Testing

  • swift test: all six test bundles pass. The CLI bundle passed 100 consecutive runs after the lease change.
  • With origin/main merged in (Build the device helper without the generation engine #194), the full test scheme passes on the M6 mini XcodeRunnerKit host. The pull request was merged on that result and the local Codex review, without waiting for GitHub CI on the last head.
  • Lease race: 20,000 acquisitions in a row while another task spawned /usr/bin/true failed 37 times before the change and 0 times after it, in two runs. The race cannot be staged deterministically, so no test was added for it.
  • Reverting --fresh to the default continuation, or skipping the deletion of the temporary Simulator device, each fails the migrated tests.
  • A Foundation dump on macOS 27.2.1 is identical to the output before this change (1,023 files).
  • Local Codex review: three findings in two rounds, all in tests and all fixed (two tests that would wait forever if the command exited early, and an inventory stub that accepted any device and helper path).
  • Not verified locally: Simulator and SSH generation against a real device.

🤖 Generated with Claude Code

lynnswap and others added 3 commits November 20, 2026 09:39
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…on starts

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…on early exit

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T04:11:24.860215Z 4a10316 Manual request
🔒 Security Review ✅ Completed 2026-11-20T00:51:12.983275Z c25441c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lynnswap lynnswap left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 4a10316d23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lynnswap
lynnswap merged commit acb3ce2 into main Nov 20, 2026
4 checks passed
@lynnswap
lynnswap deleted the refactor/cli-process-boundary-tests branch November 20, 2026 04:28
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.

Test CLI generation through the process runner instead of per-step closures

1 participant