BashSwiftScriptTests: end-to-end verify Subprocess.run hits bash builtins#22
Merged
Conversation
…tins
Closes the verification loop on the polyglot subprocess unification:
- ShellKit#1 — `Shell.processLauncher` primitive
- SwiftBash#19 — `BashProcessLauncher` resolves against the bash
command registry
- SwiftScript#5 — `import Subprocess` bridge routes through
`Shell.current.processLauncher`
A SwiftScript script under SwiftBash that does
`Subprocess.run(Executable.name("echo"), ...)` should NOT reach
`posix_spawn`; it should hit `EchoCommand` (the pure-Swift bash
builtin). Two tests confirm this in practice — they're the
script-author-visible payoff for the layered work above.
* `subprocessRunRoutesThroughBashCommandRegistry` — script calls
`Subprocess.run(Executable.name("echo"), arguments: ["hello-..."], ...)`,
the bridge calls `Shell.current.processLauncher.launch(...)`,
`BashProcessLauncher` resolves `"echo"` to the registered
`EchoCommand`, the captured `standardOutput` round-trips back
to the script and prints. No `posix_spawn`, no host `/bin/echo`
involvement.
* `subprocessRunWithCanonicalPathHitsBashBuiltin` — same flow with
`Executable.path("/bin/echo")`. Verifies the canonical-bin-path
resolution rule (PR #19's P2 fix): `/bin/echo` matches
`BinCatalog.knownPaths["echo"]`, so the launcher dispatches to
the registered builtin.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b306a51687
ℹ️ 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".
P2 from the automated review on #22: The original tests asserted on `echo` output, which is identical whether produced by `EchoCommand` (the bash builtin) or `/bin/echo` (the host). A regression that routed `Subprocess.run` through real exec instead of `BashProcessLauncher` would still pass on Unix- likes — the test didn't actually verify the routing claim. Fix: use a signal that differs between dispatch paths. - `subprocessRunRoutesThroughBashCommandRegistry` registers a sentinel command name (`swiftbash-only-marker`) that exists only in the shell's command table — nothing matches on the host's PATH. A regression that fell through to real exec would fail with "executable not found." The test asserts on a `REGISTRY-OK:` prefix produced by the registered closure. - `subprocessRunWithCanonicalPathHitsBashBuiltin` overrides the registry's `echo` with a closure that prepends `BUILTIN:`. The canonical-path resolution rule (`BinCatalog.knownPaths["echo"] == "/bin/echo"`) routes the call through `BashProcessLauncher` to the override; a regression that invoked real `/bin/echo` would miss the prefix. Both pass locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the verification loop on the polyglot subprocess unification:
Shell.processLauncherprimitive ✅ mergedBashProcessLauncherresolves against the bash command registry ✅ mergedimport Subprocessbridge routes throughShell.current.processLauncher✅ mergedA SwiftScript script under SwiftBash that does
Subprocess.run(Executable.name(\"echo\"), ...)should not reachposix_spawn; it should hitEchoCommand(the pure-Swift bash builtin). Two tests confirm this end-to-end — they're the script-author-visible payoff for the layered work above.Tests
subprocessRunRoutesThroughBashCommandRegistry— script:Bridge calls
Shell.current.processLauncher.launch(...),BashProcessLauncherresolves\"echo\"to the registeredEchoCommand, the capturedstandardOutputround-trips back to the script and printsgot=hello-from-bash-builtin\\n. Noposix_spawn, no host/bin/echoinvolvement.subprocessRunWithCanonicalPathHitsBashBuiltin— same flow withExecutable.path(\"/bin/echo\"). Verifies the canonical-bin-path resolution rule (PR #19's P2 fix):/bin/echomatchesBinCatalog.knownPaths[\"echo\"], so the launcher dispatches to the registered builtin instead of throwingProcessLaunchUnresolved.Both pass locally.
Test plan
🤖 Generated with Claude Code