Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Mutant #1209

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c5fca90
Remove Mutant::isCoveredByTests() and rename Mutation::isCoveredByTes…
theofidry Mar 24, 2020
2980168
Remove redundant method
theofidry Mar 24, 2020
5d3835b
PoC: move mutant into mutation
theofidry Mar 24, 2020
ed88454
Fix most of the direct tests
theofidry Mar 24, 2020
18549c9
Merge remote-tracking branch 'upstream/master' into refactor/mutant-less
theofidry Mar 25, 2020
8ea638a
Remove occurrences of mutants
theofidry Mar 25, 2020
581b6a2
Fix CS
theofidry Mar 25, 2020
c163e11
Simplify FQCN
theofidry Mar 25, 2020
7c41456
Merge remote-tracking branch 'upstream/master' into refactor/mutant-less
theofidry Mar 25, 2020
c8f4c86
Fix some tests
theofidry Mar 25, 2020
a6993c5
Fix more tests
theofidry Mar 25, 2020
56e8026
Fix more tests
theofidry Mar 25, 2020
9e3bb0e
Fix SimpleMutation
theofidry Mar 25, 2020
cd8d203
Fix autoreview
theofidry Mar 25, 2020
57eb6ba
Fix
theofidry Mar 25, 2020
5a8428a
Merge remote-tracking branch 'upstream/master' into refactor/mutant-less
theofidry Mar 26, 2020
32a4908
Fix merge
theofidry Mar 26, 2020
0655692
Remove the Mutation laziness
theofidry Mar 27, 2020
6830cd6
Fix CS
theofidry Mar 27, 2020
e00f078
Merge remote-tracking branch 'upstream/master' into refactor/mutant-less
theofidry Mar 29, 2020
4437597
Revert ConfigurationFactory change
theofidry Apr 3, 2020
d73602d
Revert name changes
theofidry Apr 3, 2020
b28b7d8
More revert
theofidry Apr 3, 2020
0880fe7
Merge remote-tracking branch 'upstream/master' into refactor/mutant-less
theofidry Apr 3, 2020
84c0707
Polishing
theofidry Apr 3, 2020
5e1cdc6
Merge remote-tracking branch 'upstream/master' into refactor/mutant-less
theofidry Apr 13, 2020
b7b93ef
Revert undesired renaming
theofidry Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 58 additions & 2 deletions doc/nomenclature.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,58 @@

## Table of Contents

- [A](#a)
- [AST][ast]
- [M](#m)
- [Mutagenesis][mutagenesis]
- [Mutant][mutant]
- [Mutation][mutation]
- [Mutator][mutator]
- [S](#s)
- [Subject][subject]
- [T](#t)
- [Tracer][tracer]
- [Trace][trace]
- [Tracer][tracer]
- [Trace][trace]


## A

### AST

Acronym for [Abstract Syntax Tree][ast-definition]. It is a tree representation of the abstract
syntactic structure of code. It is what Infection parses the code into in order to operate on it.


## M

### Mutagenesis

Process of creating a mutant from the original program.


### Mutant

New program that differs from the original by applying a mutation.


### Mutation

The result of applying a mutator to the AST of a subject and represents a change to be applied.


### Mutator

Define a possible transformation, which applied to the AST of a subject will result in a mutation.

In the Mutation Testing literature, mutators are also known as "mutant operator",
"mutagenic operator", "mutagen" and "mutation rule".


## S

### Subject

An addressable piece of code to be targeted for mutation testing.


## T
Expand All @@ -23,5 +72,12 @@ Artifact produced by a tracer: provides the piece of source code and its associa

<hr />

[ast]: #ast
[ast-definition]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
[mutagenesis]: #mutagenesis
[mutant]: #mutant
[mutation]: #mutation
[mutator]: #mutator
[subject]: #subject
[tracer]: #tracer
[trace]: #trace
2 changes: 1 addition & 1 deletion src/Config/ValueProvider/ExcludeDirsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function get(InputInterface $input, OutputInterface $output, array $dirsI
{
$output->writeln([
'',
'There can be situations when you want to exclude some folders from generating mutants.',
'There can be situations when you want to exclude some folders from generating mutations.',
'You can use glob pattern (<comment>*Bundle/**/*/Tests</comment>) for them or just regular dir path.',
'It should be <comment>relative</comment> to the source directory.',
'<comment>You should not mutate test suite files.</comment>',
Expand Down
4 changes: 2 additions & 2 deletions src/Console/OutputFormatter/AbstractOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace Infection\Console\OutputFormatter;

use Infection\Mutant\MutantExecutionResult;
use Infection\Mutation\MutationExecutionResult;

/**
* @internal
Expand All @@ -59,7 +59,7 @@ public function start(int $mutationCount): void
$this->callsCount = 0;
}

public function advance(MutantExecutionResult $executionResult, int $mutationCount): void
public function advance(MutationExecutionResult $executionResult, int $mutationCount): void
{
++$this->callsCount;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Console/OutputFormatter/DotFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

namespace Infection\Console\OutputFormatter;

use Infection\Mutant\DetectionStatus;
use Infection\Mutant\MutantExecutionResult;
use Infection\Mutation\DetectionStatus;
use Infection\Mutation\MutationExecutionResult;
use function Safe\sprintf;
use function str_repeat;
use function strlen;
Expand Down Expand Up @@ -71,7 +71,7 @@ public function start(int $mutationCount): void
]);
}

public function advance(MutantExecutionResult $executionResult, int $mutationCount): void
public function advance(MutationExecutionResult $executionResult, int $mutationCount): void
{
parent::advance($executionResult, $mutationCount);

Expand Down
4 changes: 2 additions & 2 deletions src/Console/OutputFormatter/OutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace Infection\Console\OutputFormatter;

use Infection\Mutant\MutantExecutionResult;
use Infection\Mutation\MutationExecutionResult;

interface OutputFormatter
{
Expand All @@ -47,7 +47,7 @@ public function start(int $mutationCount): void;
/**
* Triggered each time mutation process is finished for one Mutant
*/
public function advance(MutantExecutionResult $executionResult, int $mutationCount): void;
public function advance(MutationExecutionResult $executionResult, int $mutationCount): void;

/**
* Triggered when mutation testing is finished
Expand Down
4 changes: 2 additions & 2 deletions src/Console/OutputFormatter/ProgressFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace Infection\Console\OutputFormatter;

use Infection\Mutant\MutantExecutionResult;
use Infection\Mutation\MutationExecutionResult;
use Symfony\Component\Console\Helper\ProgressBar;

/**
Expand All @@ -57,7 +57,7 @@ public function start(int $mutationCount): void
$this->progressBar->start($mutationCount);
}

public function advance(MutantExecutionResult $executionResult, int $mutationCount): void
public function advance(MutationExecutionResult $executionResult, int $mutationCount): void
{
parent::advance($executionResult, $mutationCount);

Expand Down
48 changes: 24 additions & 24 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@
use Infection\Logger\LoggerFactory;
use Infection\Metrics\MetricsCalculator;
use Infection\Metrics\MinMsiChecker;
use Infection\Mutant\MutantCodeFactory;
use Infection\Mutant\MutantExecutionResultFactory;
use Infection\Mutant\MutantFactory;
use Infection\Mutation\FileMutationGenerator;
use Infection\Mutation\Mutation;
use Infection\Mutation\MutationCodeFactory;
use Infection\Mutation\MutationExecutionResultFactory;
use Infection\Mutation\MutationFactory;
use Infection\Mutation\MutationGenerator;
use Infection\Mutator\MutatorFactory;
use Infection\Mutator\MutatorParser;
use Infection\Mutator\MutatorResolver;
use Infection\PhpParser\FileParser;
use Infection\PhpParser\NodeTraverserFactory;
use Infection\Process\Builder\InitialTestRunProcessBuilder;
use Infection\Process\Builder\MutantProcessFactory;
use Infection\Process\Builder\MutationProcessFactory;
use Infection\Process\Builder\SubscriberBuilder;
use Infection\Process\Runner\DryProcessRunner;
use Infection\Process\Runner\InitialTestsRunner;
Expand Down Expand Up @@ -222,15 +222,15 @@ public static function create(): self
GeneratedExtensionsConfig::EXTENSIONS
);
},
MutantCodeFactory::class => static function (self $container): MutantCodeFactory {
return new MutantCodeFactory($container->getPrinter());
MutationCodeFactory::class => static function (self $container): MutationCodeFactory {
return new MutationCodeFactory($container->getPrinter());
},
MutantFactory::class => static function (self $container): MutantFactory {
return new MutantFactory(
MutationFactory::class => static function (self $container): MutationFactory {
return new MutationFactory(
$container->getConfiguration()->getTmpDir(),
$container->getDiffer(),
$container->getPrinter(),
$container->getMutantCodeFactory()
$container->getMutationCodeFactory()
);
},
Differ::class => static function (): Differ {
Expand Down Expand Up @@ -428,12 +428,12 @@ public static function create(): self
$container->getEventDispatcher()
);
},
MutantProcessFactory::class => static function (self $container): MutantProcessFactory {
return new MutantProcessFactory(
MutationProcessFactory::class => static function (self $container): MutationProcessFactory {
return new MutationProcessFactory(
$container->getTestFrameworkAdapter(),
$container->getConfiguration()->getProcessTimeout(),
$container->getEventDispatcher(),
$container->getMutantExecutionResultFactory()
$container->getMutationExecutionResultFactory()
);
},
MutationGenerator::class => static function (self $container): MutationGenerator {
Expand All @@ -449,8 +449,8 @@ public static function create(): self
},
MutationTestingRunner::class => static function (self $container): MutationTestingRunner {
return new MutationTestingRunner(
$container->getMutantProcessFactory(),
$container->getMutantFactory(),
$container->getMutationProcessFactory(),
$container->getMutationFactory(),
$container->getProcessRunner(),
$container->getEventDispatcher(),
$container->getConfiguration()->isDryRun()
Expand All @@ -474,8 +474,8 @@ public static function create(): self
AdapterInstaller::class => static function (): AdapterInstaller {
return new AdapterInstaller(new ComposerExecutableFinder());
},
MutantExecutionResultFactory::class => static function (self $container): MutantExecutionResultFactory {
return new MutantExecutionResultFactory($container->getTestFrameworkAdapter());
MutationExecutionResultFactory::class => static function (self $container): MutationExecutionResultFactory {
return new MutationExecutionResultFactory($container->getTestFrameworkAdapter());
},
]);
}
Expand Down Expand Up @@ -643,14 +643,14 @@ public function getFactory(): Factory
return $this->get(Factory::class);
}

public function getMutantCodeFactory(): MutantCodeFactory
public function getMutationCodeFactory(): MutationCodeFactory
{
return $this->get(MutantCodeFactory::class);
return $this->get(MutationCodeFactory::class);
}

public function getMutantFactory(): MutantFactory
public function getMutationFactory(): MutationFactory
{
return $this->get(MutantFactory::class);
return $this->get(MutationFactory::class);
}

public function getDiffer(): Differ
Expand Down Expand Up @@ -828,9 +828,9 @@ public function getInitialTestsRunner(): InitialTestsRunner
return $this->get(InitialTestsRunner::class);
}

public function getMutantProcessFactory(): MutantProcessFactory
public function getMutationProcessFactory(): MutationProcessFactory
{
return $this->get(MutantProcessFactory::class);
return $this->get(MutationProcessFactory::class);
}

public function getMutationGenerator(): MutationGenerator
Expand Down Expand Up @@ -878,9 +878,9 @@ public function getAdapterInstaller(): AdapterInstaller
return $this->get(AdapterInstaller::class);
}

public function getMutantExecutionResultFactory(): MutantExecutionResultFactory
public function getMutationExecutionResultFactory(): MutationExecutionResultFactory
{
return $this->get(MutantExecutionResultFactory::class);
return $this->get(MutationExecutionResultFactory::class);
}

/**
Expand Down
15 changes: 9 additions & 6 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function execute(): void
$this->runMutationAnalysis();

$this->minMsiChecker->checkMetrics(
$this->metricsCalculator->getTotalMutantsCount(),
$this->metricsCalculator->getTotalMutationsCount(),
$this->metricsCalculator->getMutationScoreIndicator(),
$this->metricsCalculator->getCoveredCodeMutationScoreIndicator(),
$this->consoleOutput
Expand Down Expand Up @@ -155,12 +155,15 @@ private function runMutationAnalysis(): void
: []
);

$actualExtraOptions = $this->config->getTestFrameworkExtraOptions();
$extraOptions = $this->config->getTestFrameworkExtraOptions();

$filteredExtraOptionsForMutant = $this->adapter instanceof ProvidesInitialRunOnlyOptions
? $this->testFrameworkExtraOptionsFilter->filterForMutantProcess($actualExtraOptions, $this->adapter->getInitialRunOnlyOptions())
: $actualExtraOptions;
$mutationExtraOptions = $this->adapter instanceof ProvidesInitialRunOnlyOptions
? $this->testFrameworkExtraOptionsFilter->filterForMutationProcess(
$extraOptions,
$this->adapter->getInitialRunOnlyOptions()
)
: $extraOptions;

$this->mutationTestingRunner->run($mutations, $filteredExtraOptionsForMutant);
$this->mutationTestingRunner->run($mutations, $mutationExtraOptions);
theofidry marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@

namespace Infection\Event;

use Infection\Mutant\MutantExecutionResult;
use Infection\Mutation\MutationExecutionResult;

/**
* @internal
*/
final class MutantProcessWasFinished
final class MutationProcessWasFinished
{
private $executionResult;

public function __construct(MutantExecutionResult $executionResult)
public function __construct(MutationExecutionResult $executionResult)
{
$this->executionResult = $executionResult;
}

public function getExecutionResult(): MutantExecutionResult
public function getExecutionResult(): MutationExecutionResult
{
return $this->executionResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function onMutationGenerationWasStarted(MutationGenerationWasStarted $eve
{
$this->output->writeln([
'',
'Generate mutants...',
'Generate mutations...',
'',
sprintf('Processing source code files: %s', $event->getMutableFilesCount()),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(OutputInterface $output)

public function onMutationGenerationWasStarted(MutationGenerationWasStarted $event): void
{
$this->output->writeln(['', '', 'Generate mutants...', '']);
$this->output->writeln(['', '', 'Generate mutations...', '']);
$this->progressBar->start($event->getMutableFilesCount());
}

Expand Down