Skip to content

[Bug] --mutate fails with "Cannot traverse an already closed generator" on Windows #1614

@Rolliboy

Description

@Rolliboy

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

  1. Have a working Pest test suite on Windows
  2. Add covers(SomeClass::class) to a test file
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions