Skip to content

Reduce "Initial Tests Run" stage time by running only covering test files #1044

Reduce "Initial Tests Run" stage time by running only covering test files

Reduce "Initial Tests Run" stage time by running only covering test files #1044

Triggered via pull request March 19, 2024 21:53
Status Success
Total duration 5m 14s
Artifacts

mt-annotations.yaml

on: pull_request
Matrix: tests
Annotations Status
1s
Annotations Status
Fit to window
Zoom out
Zoom in

Annotations

5 warnings
Mutation Testing Code Review Annotations 8.1
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/cache@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
Mutation Testing Code Review Annotations 8.1: src/Command/RunCommand.php#L289
Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ private const OPTION_DRY_RUN = 'dry-run'; protected function configure() : void { - $this->setName('run')->setDescription('Runs the mutation testing.')->addOption(self::OPTION_TEST_FRAMEWORK, null, InputOption::VALUE_REQUIRED, sprintf('Name of the Test framework to use ("%s")', implode('", "', TestFrameworkTypes::getTypes())), Container::DEFAULT_TEST_FRAMEWORK)->addOption(self::OPTION_TEST_FRAMEWORK_OPTIONS, null, InputOption::VALUE_REQUIRED, 'Options to be passed to the test framework', Container::DEFAULT_TEST_FRAMEWORK_EXTRA_OPTIONS)->addOption(self::OPTION_THREADS, 'j', InputOption::VALUE_REQUIRED, 'Number of threads to use by the runner when executing the mutations. Use "max" to auto calculate it.', Container::DEFAULT_THREAD_COUNT)->addOption(self::OPTION_ONLY_COVERED, null, InputOption::VALUE_NONE, 'Mutate only covered by tests lines of code')->addOption(self::OPTION_SHOW_MUTATIONS, 's', InputOption::VALUE_NONE, 'Show escaped (and non-covered in verbose mode) mutations to the console')->addOption(self::OPTION_NO_PROGRESS, null, InputOption::VALUE_NONE, 'Do not output progress bars and mutation count during progress. Automatically enabled if a CI is detected')->addOption(self::OPTION_FORCE_PROGRESS, null, InputOption::VALUE_NONE, 'Output progress bars and mutation count during progress even if a CI is detected')->addOption(self::OPTION_CONFIGURATION, 'c', InputOption::VALUE_REQUIRED, 'Path to the configuration file to use', Container::DEFAULT_CONFIG_FILE)->addOption(self::OPTION_COVERAGE, null, InputOption::VALUE_REQUIRED, 'Path to existing coverage directory', Container::DEFAULT_EXISTING_COVERAGE_PATH)->addOption(self::OPTION_MUTATORS, null, InputOption::VALUE_REQUIRED, sprintf('Specify particular mutators, e.g. <comment>"--%s=Plus,PublicVisibility"</comment>', self::OPTION_MUTATORS), Container::DEFAULT_MUTATORS_INPUT)->addOption(self::OPTION_FILTER, null, InputOption::VALUE_REQUIRED, 'Filter which files to mutate', Container::DEFAULT_FILTER)->addOption(self::OPTION_FORMATTER, null, InputOption::VALUE_REQUIRED, sprintf('Name of the formatter to use ("%s")', implode('", "', FormatterName::ALL)), Container::DEFAULT_FORMATTER_NAME)->addOption(self::OPTION_GIT_DIFF_FILTER, null, InputOption::VALUE_REQUIRED, 'Filter files to mutate by git <comment>"--diff-filter"</comment> option. <comment>A</comment> - only for added files, <comment>AM</comment> - for added and modified.', Container::DEFAULT_GIT_DIFF_FILTER)->addOption(self::OPTION_GIT_DIFF_LINES, null, InputOption::VALUE_NONE, 'Mutates only added and modified <comment>lines</comment> in files.', Container::DEFAULT_GIT_DIFF_FILTER)->addOption(self::OPTION_GIT_DIFF_BASE, null, InputOption::VALUE_REQUIRED, sprintf('Base branch for <comment>"--%1$s"</comment> option. Must be used only together with <comment>"--%1$s"</comment>.', self::OPTION_GIT_DIFF_FILTER), Container::DEFAULT_GIT_DIFF_BASE)->addOption(self::OPTION_LOGGER_GITHUB, null, InputOption::VALUE_OPTIONAL, 'Log escaped Mutants as GitHub Annotations (automatically detected on Github Actions itself, use <comment>true</comment> to force-enable or <comment>false</comment> to force-disable it).', false)->addOption(self::OPTION_MAP_SOURCE_CLASS_TO_TEST, null, InputOption::VALUE_OPTIONAL, 'Enables test files filtering during "Initial Tests Run" stage when `--filter`/`--git-diff-filter`/`--git-diff-lines` are used. With this option, only those test files are executed to provide coverage, that cover changed/added source files.', false)->addOption(self::OPTION_LOGGER_GITLAB, null, InputOption::VALUE_OPTIONAL, 'Path to log escaped Mutants in the GitLab (Code Climate) JSON format.')->addOption(self::OPTION_LOGGER_HTML, null, InputOption::VALUE_REQUIRED, 'Path to HTML report file, similar to PHPUnit HTML report.')->addOption(self::OPTION_USE_NOOP_MUTATORS, null, InputOption::VALUE_NONE, 'Use noop mutators that do not change AST. For debugging purposes.')->addOption(self::OPTION_EXECUTE_ONLY_COVERING_TEST_CASES, null, InputOption::VALUE_N
Mutation Testing Code Review Annotations 8.1: src/TestFramework/PhpUnit/Adapter/PestAdapterFactory.php#L101
Escaped Mutant for Mutator "UnwrapArrayMap": --- Original +++ New @@ @@ Assert::string($testFrameworkConfigDir, 'Config dir is not allowed to be `null` for the Pest adapter'); $testFrameworkConfigContent = file_get_contents($testFrameworkConfigPath); $configManipulator = new XmlConfigurationManipulator(new PathReplacer(new Filesystem(), $testFrameworkConfigDir), $testFrameworkConfigDir); - $phpUnitAdapter = new PhpUnitAdapter($testFrameworkExecutable, $tmpDir, $jUnitFilePath, new PCOVDirectoryProvider(), new InitialConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, new XmlConfigurationVersionProvider(), $sourceDirectories, array_map(static fn(SplFileInfo $fileInfo): string => $fileInfo->getRealPath(), $filteredSourceFilesToMutate)), new MutationConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, $projectDir, new JUnitTestCaseSorter()), new ArgumentsAndOptionsBuilder($executeOnlyCoveringTestCases, $filteredSourceFilesToMutate, $mapSourceClassToTestStrategy), new VersionParser(), new CommandLineBuilder()); + $phpUnitAdapter = new PhpUnitAdapter($testFrameworkExecutable, $tmpDir, $jUnitFilePath, new PCOVDirectoryProvider(), new InitialConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, new XmlConfigurationVersionProvider(), $sourceDirectories, $filteredSourceFilesToMutate), new MutationConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, $projectDir, new JUnitTestCaseSorter()), new ArgumentsAndOptionsBuilder($executeOnlyCoveringTestCases, $filteredSourceFilesToMutate, $mapSourceClassToTestStrategy), new VersionParser(), new CommandLineBuilder()); return new PestAdapter($phpUnitAdapter); } public static function getAdapterName() : string
Mutation Testing Code Review Annotations 8.1: src/TestFramework/PhpUnit/Adapter/PhpUnitAdapterFactory.php#L101
Escaped Mutant for Mutator "UnwrapArrayMap": --- Original +++ New @@ @@ Assert::string($testFrameworkConfigDir, 'Config dir is not allowed to be `null` for the Pest adapter'); $testFrameworkConfigContent = file_get_contents($testFrameworkConfigPath); $configManipulator = new XmlConfigurationManipulator(new PathReplacer(new Filesystem(), $testFrameworkConfigDir), $testFrameworkConfigDir); - return new PhpUnitAdapter($testFrameworkExecutable, $tmpDir, $jUnitFilePath, new PCOVDirectoryProvider(), new InitialConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, new XmlConfigurationVersionProvider(), $sourceDirectories, array_map(static fn(SplFileInfo $fileInfo): string => $fileInfo->getRealPath(), $filteredSourceFilesToMutate)), new MutationConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, $projectDir, new JUnitTestCaseSorter()), new ArgumentsAndOptionsBuilder($executeOnlyCoveringTestCases, $filteredSourceFilesToMutate, $mapSourceClassToTestStrategy), new VersionParser(), new CommandLineBuilder()); + return new PhpUnitAdapter($testFrameworkExecutable, $tmpDir, $jUnitFilePath, new PCOVDirectoryProvider(), new InitialConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, new XmlConfigurationVersionProvider(), $sourceDirectories, $filteredSourceFilesToMutate), new MutationConfigBuilder($tmpDir, $testFrameworkConfigContent, $configManipulator, $projectDir, new JUnitTestCaseSorter()), new ArgumentsAndOptionsBuilder($executeOnlyCoveringTestCases, $filteredSourceFilesToMutate, $mapSourceClassToTestStrategy), new VersionParser(), new CommandLineBuilder()); } public static function getAdapterName() : string {
Mutation Testing Code Review Annotations 8.1: src/TestFramework/PhpUnit/CommandLine/ArgumentsAndOptionsBuilder.php#L80
Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ public function buildForInitialTestsRun(string $configPath, string $extraOptions) : array { $options = $this->prepareArgumentsAndOptions($configPath, $extraOptions); - if ($this->filteredSourceFilesToMutate !== [] && $this->mapSourceClassToTestStrategy !== null && !in_array('--filter', $options, true)) { + if (($this->filteredSourceFilesToMutate !== [] || $this->mapSourceClassToTestStrategy !== null) && !in_array('--filter', $options, true)) { $options[] = '--filter'; $options[] = implode('|', array_map($this->mapSourceClassToTestClass(...), $this->filteredSourceFilesToMutate)); }