Skip to content

Commit d1a72f4

Browse files
authored
Merge pull request #1160 from jose-ba/v2.x
Adds 'skip_initial_tests' and 'coverage' options support to infection…
2 parents 1411718 + 28b74bb commit d1a72f4

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

doc/tasks/infection.md

+15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ grumphp:
2828
mutators: []
2929
ignore_patterns: []
3030
triggered_by: [php]
31+
skip_initial_tests: false
32+
coverage: ~
3133
```
3234
3335
**threads**
@@ -112,3 +114,16 @@ With this option you can skip files like tests. Leave this option blank to run a
112114
This option will specify which file extensions will trigger the infection task.
113115
By default, infection will be triggered by altering a php file.
114116
You can overwrite this option to whatever file you want to use!
117+
118+
**skip_initial_tests**
119+
120+
*Default: false*
121+
122+
Skip running the initial tests. If set to `true`, it is necessary to set `coverage` to the
123+
path where `coverage-xml` and `log-junit` is written by `phpunit` task.
124+
125+
**coverage**
126+
127+
*Default: ~*
128+
129+
Path where `coverage-xml` and `log-junit` is written by `phpunit` task.

src/Task/Infection.php

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
3434
'mutators' => [],
3535
'ignore_patterns' => [],
3636
'triggered_by' => ['php'],
37+
'skip_initial_tests' => false,
38+
'coverage' => null,
3739
]);
3840

3941
$resolver->addAllowedTypes('threads', ['null', 'int']);
@@ -47,6 +49,8 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
4749
$resolver->addAllowedTypes('mutators', ['array']);
4850
$resolver->addAllowedTypes('ignore_patterns', ['array']);
4951
$resolver->addAllowedTypes('triggered_by', ['array']);
52+
$resolver->addAllowedTypes('skip_initial_tests', ['bool']);
53+
$resolver->addAllowedTypes('coverage', ['null', 'string']);
5054

5155
return ConfigOptionsResolver::fromOptionsResolver($resolver);
5256
}
@@ -84,6 +88,8 @@ public function run(ContextInterface $context): TaskResultInterface
8488
$arguments->addOptionalArgument('--configuration=%s', $config['configuration']);
8589
$arguments->addOptionalArgument('--min-msi=%s', $config['min_msi']);
8690
$arguments->addOptionalArgument('--min-covered-msi=%s', $config['min_covered_msi']);
91+
$arguments->addOptionalArgument('--coverage=%s', $config['coverage']);
92+
$arguments->addOptionalArgument('--skip-initial-tests', $config['skip_initial_tests']);
8793
$arguments->addOptionalCommaSeparatedArgument('--mutators=%s', $config['mutators']);
8894

8995
if ($context instanceof GitPreCommitContext) {

test/Unit/Task/InfectionTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function provideConfigurableOptions(): iterable
3636
'mutators' => [],
3737
'ignore_patterns' => [],
3838
'triggered_by' => ['php'],
39+
'skip_initial_tests' => false,
40+
'coverage' => null
3941
]
4042
];
4143
}
@@ -233,5 +235,29 @@ public function provideExternalTaskRuns(): iterable
233235
'--filter=hello.php,hello2.php'
234236
]
235237
];
238+
yield 'skip-initial-tests' => [
239+
[
240+
'skip_initial_tests' => true,
241+
],
242+
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
243+
'infection',
244+
[
245+
'--no-interaction',
246+
'--ignore-msi-with-no-mutations',
247+
'--skip-initial-tests'
248+
]
249+
];
250+
yield 'coverage' => [
251+
[
252+
'coverage' => '/path/to/coverage',
253+
],
254+
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
255+
'infection',
256+
[
257+
'--no-interaction',
258+
'--ignore-msi-with-no-mutations',
259+
'--coverage=/path/to/coverage'
260+
]
261+
];
236262
}
237263
}

0 commit comments

Comments
 (0)