[Bug] --mutate fails with "Cannot traverse an already closed generator" on Windows
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.7k
- Forks
- 538
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 8
Description
Pest Version
4.3.1 (also tested with 3.8.4)
PHP Version
8.3.16 (ZTS Visual C++ 2019 x64)
Operating System
Windows 10/11 (MSYS_NT-10.0-26200)
Description
Running --mutate fails with "Cannot traverse an already closed generator" error on Windows. The tests pass successfully, but mutation testing crashes when it tries to iterate over files.
Steps To Reproduce
- Have a working Pest test suite on Windows
- Add
covers(SomeClass::class)to a test file - Run any of these commands:
./vendor/bin/pest --mutate./vendor/bin/pest --mutate --path=src/Domain./vendor/bin/pest tests/SomeTest.php --mutate
Expected Behavior
Mutation testing should run and report mutants.
Actual Behavior
Tests: 48 passed (150 assertions)
Duration: 6.56s
Mutating application files...
Exception
Cannot traverse an already closed generator
at vendor\pestphp\pest-plugin-mutate\src\Tester\MutationTestRunner.php:124
120▕
121▕ /** @var MutationGenerator $generator */
122▕ $generator = Container::getInstance()->get(MutationGenerator::class);
123▕
➜ 124▕ foreach ($files as $file) {
1 vendor\pestphp\pest-plugin-mutate\src\Tester\MutationTestRunner.php:124
AppendIterator::rewind()
2 vendor\pestphp\pest-plugin-mutate\src\Plugins\Mutate.php:191
Pest\Mutate\Tester\MutationTestRunner::run()
Notes
- Xdebug 3.5.0 is enabled
- Issue occurs with both Pest 3.x and 4.x
- Tests run correctly without
--mutate - Tried with
--parallel,--no-parallel,--no-coverage- same result
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at vendor\pestphp\pest-plugin-mutate\src\Tester\MutationTestRunner.php:124 and trace how $files is built before AppendIterator::rewind(), comparing Windows and non-Windows behavior. Reproduce with --mutate on Windows using a covered test and verify mutation testing reports mutants without the closed-generator exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100