From 63bd8470110a85b755dd4bcb71f0d1454065d2d0 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 29 Oct 2025 10:45:39 +0100 Subject: [PATCH 1/7] Added bin/infection-config.php `--timeout` option --- bin/infection-config.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/infection-config.php b/bin/infection-config.php index e7a6e3a..906855f 100644 --- a/bin/infection-config.php +++ b/bin/infection-config.php @@ -4,13 +4,14 @@ error_reporting(E_ALL & ~E_DEPRECATED); ini_set('display_errors', 'stderr'); -$opts = getopt('', ['source-directory::', 'mutator-class::']); +$opts = getopt('', ['source-directory::', 'mutator-class::', 'timeout::']); if ($argc < 1) { - echo "Usage: php ". $argv[0] ." [--source-directory='another/path'] [--mutator-class='Infection\Mutator\Removal\MethodCallRemoval]'\n"; + echo "Usage: php ". $argv[0] ." [--source-directory='another/path'] [--mutator-class='Infection\Mutator\Removal\MethodCallRemoval] [--timeout=60]'\n"; exit(1); } $addSourceDirectories = (array) ($opts['source-directory'] ?? []); $addMutatorClasses = (array) ($opts['mutator-class'] ?? []); +$timeout = $opts['timeout'] ?? null; $decoded = json_decode(file_get_contents(__DIR__.'/../resources/infection.json5')); foreach($addSourceDirectories as $path) { @@ -20,6 +21,10 @@ $decoded->mutators->$mutatorclass = true; } +if ($timeout !== null) { + $decoded->timeout = $timeout; +} + echo json_encode($decoded); exit(0); From 5b77561b833ed7900a29110ae2d964e97bfadf58 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 29 Oct 2025 10:59:07 +0100 Subject: [PATCH 2/7] tests --- phpunit.xml | 30 +++++++++++++++++------------- tests/phpt/infection-config.phpt | 27 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 tests/phpt/infection-config.phpt diff --git a/phpunit.xml b/phpunit.xml index 4674938..c2392f8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,19 +1,23 @@ - - - tests - - + + + tests + - + + tests/phpt + + + + diff --git a/tests/phpt/infection-config.phpt b/tests/phpt/infection-config.phpt new file mode 100644 index 0000000..79bd2ea --- /dev/null +++ b/tests/phpt/infection-config.phpt @@ -0,0 +1,27 @@ +--TEST-- +The right events are emitted in the right order for a test that fails because of assert() +--FILE-- + Date: Wed, 29 Oct 2025 11:00:01 +0100 Subject: [PATCH 3/7] Update infection-config.phpt --- tests/phpt/infection-config.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpt/infection-config.phpt b/tests/phpt/infection-config.phpt index 79bd2ea..8350be0 100644 --- a/tests/phpt/infection-config.phpt +++ b/tests/phpt/infection-config.phpt @@ -1,5 +1,5 @@ --TEST-- -The right events are emitted in the right order for a test that fails because of assert() +infection-config.php renders proper json --FILE-- Date: Wed, 29 Oct 2025 11:01:09 +0100 Subject: [PATCH 4/7] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8c11203..010104c 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ tests: .PHONY: lint lint: php vendor/bin/parallel-lint --colors \ - --exclude tests/Rules/DeadCode/data/bug-383.php \ + --exclude tests/phpt/infection-config.phpt \ src tests .PHONY: cs-install From 2de42fe259f608ddb7b31e3c47e8a4b9003aff50 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 29 Oct 2025 11:04:21 +0100 Subject: [PATCH 5/7] fix --- Makefile | 1 + bin/infection-config.php | 2 +- tests/phpt/infection-config-default.phpt | 25 ++++++++++++++++++++++++ tests/phpt/infection-config.phpt | 6 +++--- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tests/phpt/infection-config-default.phpt diff --git a/Makefile b/Makefile index 010104c..e1ffc2c 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ tests: .PHONY: lint lint: php vendor/bin/parallel-lint --colors \ + --exclude tests/phpt/infection-config-default.phpt \ --exclude tests/phpt/infection-config.phpt \ src tests diff --git a/bin/infection-config.php b/bin/infection-config.php index 906855f..214c4d3 100644 --- a/bin/infection-config.php +++ b/bin/infection-config.php @@ -22,7 +22,7 @@ } if ($timeout !== null) { - $decoded->timeout = $timeout; + $decoded->timeout = (int) $timeout; } echo json_encode($decoded); diff --git a/tests/phpt/infection-config-default.phpt b/tests/phpt/infection-config-default.phpt new file mode 100644 index 0000000..78d75bf --- /dev/null +++ b/tests/phpt/infection-config-default.phpt @@ -0,0 +1,25 @@ +--TEST-- +infection-config.php renders proper json defaults +--FILE-- + Date: Wed, 29 Oct 2025 11:10:25 +0100 Subject: [PATCH 6/7] cover with phpstan --- bin/infection-config.php | 12 +++++++----- phpstan.neon | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/infection-config.php b/bin/infection-config.php index 214c4d3..bfcffff 100644 --- a/bin/infection-config.php +++ b/bin/infection-config.php @@ -1,19 +1,21 @@ #!/usr/bin/env php source->directories[] = $path; } diff --git a/phpstan.neon b/phpstan.neon index 6d7c0fd..834f007 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: level: 8 paths: + - bin - src - tests From d09fd3bd41c400606ac352ccf635dd4d25e35f9e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 29 Oct 2025 11:11:07 +0100 Subject: [PATCH 7/7] Update infection-config.php --- bin/infection-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/infection-config.php b/bin/infection-config.php index bfcffff..2697a32 100644 --- a/bin/infection-config.php +++ b/bin/infection-config.php @@ -16,13 +16,13 @@ throw new RuntimeException('Unable to read infection.json5'); } $decoded = json_decode($defaults); + foreach($addSourceDirectories as $path) { $decoded->source->directories[] = $path; } foreach($addMutatorClasses as $mutatorclass) { $decoded->mutators->$mutatorclass = true; } - if ($timeout !== null) { $decoded->timeout = (int) $timeout; }