public function onEndRun(Runner $testSuite, Collector $resultCollector) { Performance::stop(); if (!$this->isDisabled) { $this->renderer->renderPerformanceData(Performance::getTimeString(), Performance::getMemoryUsageString()); } Performance::downMemProfiler(); }
/** * Execute the command. * * @param InputInterface $input * @param OutputInterface $output * @return void|int */ protected function execute(InputInterface $input, OutputInterface $output) { Performance::upMemProfiler(); $this->validate($input); $container = $this->container = new Container($input->getOptions()); $this->doConfiguration($input); if ($this->isLoggingEnabled()) { $this->removeOldLogFiles(); } else { $output->writeln('<error>No log file is specified. Detailed results ' . 'will not be available.</error>'); $output->write(PHP_EOL); } if ($input->getOption('incremental')) { $output->writeln('<error>Incremental Analysis is an experimental feature and will very likely</error>'); $output->writeln('<error>yield inaccurate results at this time.</error>'); $output->write(PHP_EOL); } if ($this->textLogFile) { $renderer = new Text($output, true); } else { $renderer = new Text($output); } /** * Make initial test run to ensure tests are in a starting passing state * and also log the results so test runs during the mutation phase can * be optimised. */ $testSuiteRunner = new UnitTestRunner($container->getAdapter(), $container->getAdapter()->getProcess($container, true), $container->getTempDirectory() . '/coverage.humbug.txt'); $testSuiteRunner->addObserver(new LoggingObserver($renderer, $output, new ProgressBarObserver($input, $output))); $result = $testSuiteRunner->run($container); /** * Check if the initial test run ended with a fatal error */ if (!$result->isSuccess()) { return 1; } $output->write(PHP_EOL); /** * Message re Static Analysis */ $renderer->renderStaticAnalysisStart(); $output->write(PHP_EOL); $incrementalCache = null; if ($input->getOption('incremental')) { $incrementalCache = new IncrementalCache($container); } $mutationTestingRunner = $this->builder->build($container, $renderer, $input, $output); $mutationTestingRunner->run($result->getCoverage(), $this->mutableIterator, $incrementalCache); if ($this->isLoggingEnabled()) { $output->write(PHP_EOL); } if ($input->getOption('incremental')) { $incrementalCache->write(); } }