Skip to content

Commit

Permalink
Add Infection
Browse files Browse the repository at this point in the history
  • Loading branch information
radek-bruha committed Oct 18, 2018
1 parent 33ad99b commit 9cb5c09
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,6 +1,8 @@
.idea/*
code-coverage/*
docker/*
log/*
temp/*
vendor/*
build.ps1
clean.ps1
Expand Down
22 changes: 21 additions & 1 deletion README.md
Expand Up @@ -9,6 +9,7 @@
- [**PHPStan**](https://github.com/phpstan/phpstan)
- [**PHPUnit**](https://github.com/sebastianbergmann/phpunit)
- [**PHPParaTest**](https://github.com/paratestphp/paratest)
- [**PHPInfection**](https://github.com/infection/infection)

```
==================================================
Expand Down Expand Up @@ -51,6 +52,25 @@
==================================================
==================================================
| 00:10:00.0000000 |
| RUNNING INFECTION TEST |
==================================================
.................................................. 50 / 500 ( 10%)
.................................................. 100 / 500 ( 20%)
.................................................. 150 / 500 ( 30%)
.................................................. 200 / 500 ( 40%)
.................................................. 250 / 500 ( 50%)
.................................................. 300 / 500 ( 60%)
.................................................. 350 / 500 ( 70%)
.................................................. 400 / 500 ( 80%)
.................................................. 450 / 500 ( 90%)
.................................................. 500 / 500 (100%)
==================================================
| 00:10:00.0000000 | | 00:20:00.0000000 |
==================================================
==================================================
| 00:20:00.0000000 |
==================================================
```
12 changes: 12 additions & 0 deletions composer.json
Expand Up @@ -17,6 +17,7 @@
"brianium/paratest": "^2.1",
"consistence/coding-standard": "^3.5",
"cweagans/composer-patches": "^1.6",
"infection/infection": "^0.10",
"php-mock/php-mock-phpunit": "^2.1",
"phpstan/phpstan": "^0.10",
"phpstan/phpstan-nette": "^0.10",
Expand All @@ -39,6 +40,17 @@
"brianium/paratest": {
"Cleaning": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPParaTest.patch"
},
"infection/infection": {
"Cleaning": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionOne.patch",
"Cleaning II": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionTwo.patch",
"Cleaning III": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionThree.patch",
"Cleaning IV": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionFour.patch",
"Cleaning V": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionFive.patch",
"Cleaning VI": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionSix.patch",
"Cleaning VII": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionSeven.patch",
"Cleaning VIII": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionEight.patch",
"Cleaning IX": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPInfectionNine.patch"
},
"phpstan/phpstan": {
"Cleaning": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPStanOne.patch",
"Cleaning II": "vendor/radek-bruha/coding-standard/src/CustomPatches/PHPStanTwo.patch"
Expand Down
12 changes: 12 additions & 0 deletions infection.json
@@ -0,0 +1,12 @@
{
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "log/infection.log"
},
"timeout": 60,
"tmpDir": "temp/cache/Tests"
}
12 changes: 12 additions & 0 deletions phpunit.xml
@@ -0,0 +1,12 @@
<phpunit>
<testsuites>
<testsuite name="Tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
</phpunit>
13 changes: 13 additions & 0 deletions src/CustomPatches/PHPInfectionEight.patch
@@ -0,0 +1,13 @@
--- backend/vendor/infection/infection/src/Process/Listener/MutationTestingResultsLoggerSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Process/Listener/MutationTestingResultsLoggerSubscriber.php (date 1286705410000)
@@ -77,9 +77,7 @@

public function getSubscribedEvents(): array
{
- return [
- MutationTestingFinished::class => [$this, 'onMutationTestingFinished'],
- ];
+ return [];
}

public function onMutationTestingFinished(MutationTestingFinished $event): void
15 changes: 15 additions & 0 deletions src/CustomPatches/PHPInfectionFive.patch
@@ -0,0 +1,15 @@
--- backend/vendor/infection/infection/src/Process/Listener/MutantCreatingConsoleLoggerSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Process/Listener/MutantCreatingConsoleLoggerSubscriber.php (date 1286705410000)
@@ -41,11 +41,7 @@

public function getSubscribedEvents(): array
{
- return [
- MutantsCreatingStarted::class => [$this, 'onMutantsCreatingStarted'],
- MutantCreated::class => [$this, 'onMutantCreated'],
- MutantsCreatingFinished::class => [$this, 'onMutantsCreatingFinished'],
- ];
+ return [];
}

public function onMutantsCreatingStarted(MutantsCreatingStarted $event): void
15 changes: 15 additions & 0 deletions src/CustomPatches/PHPInfectionFour.patch
@@ -0,0 +1,15 @@
--- backend/vendor/infection/infection/src/Process/Listener/InitialTestsConsoleLoggerSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Process/Listener/InitialTestsConsoleLoggerSubscriber.php (date 1286705410000)
@@ -48,11 +48,7 @@

public function getSubscribedEvents(): array
{
- return [
- InitialTestSuiteStarted::class => [$this, 'onInitialTestSuiteStarted'],
- InitialTestSuiteFinished::class => [$this, 'onInitialTestSuiteFinished'],
- InitialTestCaseCompleted::class => [$this, 'onInitialTestCaseCompleted'],
- ];
+ return [];
}

public function onInitialTestSuiteStarted(InitialTestSuiteStarted $event): void
20 changes: 20 additions & 0 deletions src/CustomPatches/PHPInfectionNine.patch
@@ -0,0 +1,20 @@
--- backend/vendor/infection/infection/src/Performance/Listener/PerformanceLoggerSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Performance/Listener/PerformanceLoggerSubscriber.php (date 1286705410000)
@@ -69,15 +69,8 @@

public function onApplicationExecutionFinished(): void
{
- $time = $this->timer->stop();
+ $this->timer->stop();

- $this->output->writeln([
- '',
- sprintf(
- 'Time: %s. Memory: %s',
- $this->timeFormatter->toHumanReadableString($time),
- $this->memoryFormatter->toHumanReadableString(memory_get_peak_usage(true))
- ),
- ]);
+ $this->output->writeln('');
}
}
19 changes: 19 additions & 0 deletions src/CustomPatches/PHPInfectionOne.patch
@@ -0,0 +1,19 @@
--- backend/vendor/infection/infection/src/Console/Application.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Console/Application.php (date 1286705410000)
@@ -75,8 +75,6 @@
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
}

- $this->logRunningWithDebugger();
-
if (!$this->isAutoExitEnabled()) {
// When we're not in control of exit codes, that means it's the caller
// responsibility to disable xdebug if it isn't needed. As of writing
@@ -113,8 +111,6 @@
{
$this->getContainer()->buildDynamicDependencies($input);

- $output->writeln(self::LOGO);
-
return parent::doRun($input, $output);
}
15 changes: 15 additions & 0 deletions src/CustomPatches/PHPInfectionSix.patch
@@ -0,0 +1,15 @@
--- backend/vendor/infection/infection/src/Process/Listener/MutationGeneratingConsoleLoggerSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Process/Listener/MutationGeneratingConsoleLoggerSubscriber.php (date 1286705410000)
@@ -41,11 +41,7 @@

public function getSubscribedEvents(): array
{
- return [
- MutationGeneratingStarted::class => [$this, 'onMutationGeneratingStarted'],
- MutableFileProcessed::class => [$this, 'onMutableFileProcessed'],
- MutationGeneratingFinished::class => [$this, 'onMutationGeneratingFinished'],
- ];
+ return [];
}

public function onMutationGeneratingStarted(MutationGeneratingStarted $event): void
13 changes: 13 additions & 0 deletions src/CustomPatches/PHPInfectionThree.patch
@@ -0,0 +1,13 @@
--- backend/vendor/infection/infection/src/Process/Listener/CleanUpAfterMutationTestingFinishedSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Process/Listener/CleanUpAfterMutationTestingFinishedSubscriber.php (date 1286705410000)
@@ -36,9 +36,7 @@

public function getSubscribedEvents(): array
{
- return [
- MutationTestingFinished::class => [$this, 'onMutationTestingFinished'],
- ];
+ return [];
}

public function onMutationTestingFinished(MutationTestingFinished $event): void
45 changes: 45 additions & 0 deletions src/CustomPatches/PHPInfectionTwo.patch
@@ -0,0 +1,45 @@
--- backend/vendor/infection/infection/src/Console/OutputFormatter/DotFormatter.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Console/OutputFormatter/DotFormatter.php (date 1286705410000)
@@ -30,21 +30,6 @@
$this->output = $output;
}

- public function start(int $mutationCount): void
- {
- parent::start($mutationCount);
-
- $this->output->writeln([
- '',
- '<killed>.</killed>: killed, '
- . '<escaped>M</escaped>: escaped, '
- . '<uncovered>S</uncovered>: uncovered, '
- . '<with-error>E</with-error>: fatal error, '
- . '<timeout>T</timeout>: timed out',
- '',
- ]);
- }
-
public function advance(MutantProcessInterface $mutantProcess, int $mutationCount): void
{
parent::advance($mutantProcess, $mutationCount);
@@ -59,7 +44,7 @@

break;
case MutantProcess::CODE_ESCAPED:
- $this->output->write('<escaped>M</escaped>');
+ $this->output->write('<escaped>F</escaped>');

break;
case MutantProcess::CODE_TIMED_OUT:
@@ -82,9 +67,9 @@

if ($lastDot || $endOfRow) {
$length = \strlen((string) $mutationCount);
- $format = sprintf(' (%%%dd / %%%dd)', $length, $length);
+ $format = sprintf(' %%%dd / %%%dd (%%3d%%%%)', $length, $length);

- $this->output->write(sprintf($format, $this->callsCount, $mutationCount));
+ $this->output->write(sprintf($format, $this->callsCount, $mutationCount, ($this->callsCount / $mutationCount) * 100));

if ($this->callsCount !== $mutationCount) {
$this->output->writeln('');
19 changes: 19 additions & 0 deletions src/CustomPatches/PHPInflectionSeven.patch
@@ -0,0 +1,19 @@
--- backend/vendor/infection/infection/src/Process/Listener/MutationTestingConsoleLoggerSubscriber.php (date 1286705410000)
+++ backend/vendor/infection/infection/src/Process/Listener/MutationTestingConsoleLoggerSubscriber.php (date 1286705410000)
@@ -102,16 +102,6 @@
public function onMutationTestingFinished(MutationTestingFinished $event): void
{
$this->outputFormatter->finish();
-
- if ($this->showMutations) {
- $this->showMutations($this->metricsCalculator->getEscapedMutantProcesses(), 'Escaped');
-
- if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
- $this->showMutations($this->metricsCalculator->getNotCoveredMutantProcesses(), 'Not covered');
- }
- }
-
- $this->showMetrics();
}

/**

0 comments on commit 9cb5c09

Please sign in to comment.