Skip to content

fix: prevent random test runner deadlock with one job - #10729

Open
MohamedRF wants to merge 2 commits into
codeigniter4:developfrom
MohamedRF:fix/random-tests-single-job
Open

MohamedRF wants to merge 2 commits into
codeigniter4:developfrom
MohamedRF:fix/random-tests-single-job

Conversation

@MohamedRF

@MohamedRF MohamedRF commented Nov 5, 2026 •

Copy link
Copy Markdown

Description
Running .github/scripts/run-random-tests.sh --max-jobs 1 hangs before starting PHPUnit. When no child processes remain, cleanup_finished_pids() assigns ("${active[@]:-}"), creating an array with one empty element. The scheduler counts that element as an active job and waits indefinitely.

Keep the process list empty when there are no active PIDs. Add RunRandomTestsTest to tests/system/AutoReview/, following the existing script-test convention. Each case builds an isolated temporary project with two stub components and calls the runner through exec(), checking its exit code, success output, and two executions per component. The data provider covers job limits of one and two. A five-second timeout with a one-second kill grace prevents a regression from hanging PHPUnit; the temporary project is removed in teardown. The existing AutoReview workflow discovers the test without workflow changes.

Refs #9968. This fixes the runner rather than completing the component migration tracked by that issue.

Validation

  • vendor/bin/phpunit tests/system/AutoReview/RunRandomTestsTest.php --no-coverage: 2 tests, 12 assertions pass.
  • With the original runner restored temporarily, the one-job test fails on timeout; with the fix restored, both cases pass.
  • File-scoped PHP CS Fixer, Rector dry run, and PHPStan checks pass.
  • git diff --check passes.
  • Tested locally with PHP 8.5.12, PHPUnit 11.5.57, Bash 3.2, and GNU coreutils on macOS. Full platform validation is left to CI.

Checklist:

  • Securely signed commits
  • Regression testing
  • Conforms to style guide
  • PHPDoc and user guide changes: not applicable; no framework API or application behavior changes.

@carson-codeigniter4 carson-codeigniter4 Bot added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 5, 2026
@carson-codeigniter4

Copy link
Copy Markdown

Hi there, @MohamedRF! 👋

Thank you for sending this PR!

We expect the following in all Pull Requests (PRs).

Important

We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works.

If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work
on the framework than you do. Please make it as painless for your contributions to be included as possible.

See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants