Skip to content

test: keep the porter abort case from passing without an abort - #943

Open
brahyam wants to merge 1 commit into
yc-software:mainfrom
brahyam:test-porter-abort-signal-guard
Open

test: keep the porter abort case from passing without an abort#943
brahyam wants to merge 1 commit into
yc-software:mainfrom
brahyam:test-porter-abort-signal-guard

Conversation

@brahyam

@brahyam brahyam commented Sep 4, 2026

Copy link
Copy Markdown

test/porter-sandbox.test.ts's "abort signal kills an in-flight exec" has no
honest outcome on a host without a working setsid.

killableScript wraps the command as exec setsid sh -c …, has the inner
shell record $$ as a process group id, and killScript cancels with
kill -KILL -"$pgid". That is only correct when setsid starts a new session,
which is what makes the inner shell a group leader so pid == pgid.

Where setsid is missing, the wrapper never starts: the exec returns 127
instantly, which satisfies both of the test's assertions — fast, and non-zero.
The case reports green without launching the command, let alone aborting one.

Where a setsid exists that does not create a session (a #!/bin/sh /
exec "$@" shim on PATH is enough), the recorded pid is not a group id, the
group kill matches nothing, and the command runs to completion — failing the
case for a reason unrelated to the code under test.

This probes for the property the mechanism needs, that setsid makes a
command its own process group leader, and skips with that reason when it does
not hold. It then asserts the command started and did not finish, so an exec
that never ran cannot satisfy the case.

Verified in all three states: setsid absent → skips with the reason; a
non-session shim on PATH → skips with the reason; a genuine setsid → runs and
passes in ~0.5s, with the two new assertions holding. Linux CI is the third
state, so coverage there is unchanged apart from the added assertions.


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

The exec-kill path makes a command its own session leader with setsid, records
that pid as a process group id, and cancels by killing the group. Where setsid
is missing the wrapper fails to start at all and the exec returns 127
immediately, which satisfies both of this test's assertions — fast, and
non-zero — so the case reported green without ever launching the command, let
alone aborting one. Where setsid exists but does not create a session, the
recorded pid is not a group id, the group kill finds nothing and the command
runs to completion, failing the case for a reason that has nothing to do with
the code under test.

Probe for the property the mechanism actually needs, that setsid makes the
command its own process group leader, and skip with that reason when it does
not hold. Then assert the command started and did not finish, so an exec that
never ran cannot satisfy the case.
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