Skip to content

fix: isolate mid-sweep reload signal from the test runner - #1131

Open
rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:fix-20261101-mid-sweep-reload-signal
Open

rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:fix-20261101-mid-sweep-reload-signal

Conversation

@rootsiemen

Copy link
Copy Markdown
Contributor

Closes #1126

Problem

When the polling watcher detects a change it calls
FileMonitorWatcher::reload() → Utils::reload(true), which sends
SIGUSR1 to the parent process. The mid-sweep fixture only ignored SIGUSR1
in itself, so the signal still hit the fixture's parent (PHPUnit, or any
shell running the fixture) and could terminate it with the default signal
action.

Fix

tests/Fixtures/polling_watcher_mid_sweep_runner.php now supervises the
sweep in a forked child process:

  • The supervisor installs a counting SIGUSR1 handler; the reload signal
    from the watcher lands on the supervisor, never on the test runner.
  • The child resets SIGUSR1 to SIG_IGN and runs the sweep unchanged.
  • The supervisor propagates the child's exit code, and additionally fails
    (exit 3) unless exactly one reload signal arrived — one file changes,
    so one reload is expected. The existing exit-code contract (0/1/2/3)
    is preserved.
  • Without pcntl the sweep runs inline, as before.

Files changed

  • tests/Fixtures/polling_watcher_mid_sweep_runner.php — sweep body moved
    into runMidSweepCheck() (same checks, exit() → return), plus the
    fork supervisor with the reload-signal count check.
  • tests/PollingMonitorWatcherTest.php — new
    testMidSweepReloadSignalDoesNotReachTestRunner regression test: it runs
    the fixture and asserts exit 0, which now also proves the parent
    survived and the signal stayed inside the fixture.

Tests run

  • Both changed PHP files validated with a PHP parser (syntax OK).
  • PHPUnit could not run in this environment (no PHP installed here), so
    please rely on CI for the full suite, including the two existing
    mid-sweep tests and the new regression test.

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: isolate parent from polling fixture reload signal

1 participant