예제 #1
0
 public function run()
 {
     $results = array();
     $build_start = microtime(true);
     $config_manager = $this->getConfigurationManager();
     if ($this->getEnableCoverage() !== false) {
         $command = $config_manager->getConfigFromAnySource('unit.engine.tap.cover');
     } else {
         $command = $config_manager->getConfigFromAnySource('unit.engine.tap.command');
     }
     $timeout = $config_manager->getConfigFromAnySource('unit.engine.tap.timeout');
     if (!$timeout) {
         $timeout = 15;
     }
     $future = new ExecFuture('%C', $command);
     $future->setTimeout($timeout);
     $result = new ArcanistUnitTestResult();
     $result->setName($command ? $command : 'unknown');
     try {
         list($stdout, $stderr) = $future->resolvex();
         $result->setResult(ArcanistUnitTestResult::RESULT_PASS);
         if ($this->getEnableCoverage() !== false) {
             $coverage = $this->readCoverage('coverage/cobertura-coverage.xml');
             $result->setCoverage($coverage);
         }
     } catch (CommandException $exc) {
         $result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
         if ($future->getWasKilledByTimeout()) {
             print "Process stdout:\n" . $exc->getStdout() . "\nProcess stderr:\n" . $exc->getStderr() . "\nExceeded timeout of {$timeout} secs.\nMake unit tests faster.";
         } else {
             $result->setUserdata($exc->getStdout() . $exc->getStderr());
         }
     }
     $result->setDuration(microtime(true) - $build_start);
     $results[] = $result;
     return $results;
 }
예제 #2
0
 /**
  * Build the projects relevant for the specified test assemblies and return
  * the results of the builds as test results. This build also passes the
  * "SkipTestsOnBuild" parameter when building the projects, so that MSBuild
  * conditionals can be used to prevent any tests running as part of the
  * build itself (since the unit tester is about to run each of the tests
  * individually).
  *
  * @param  array   Array of test assemblies.
  * @return array   Array of test results.
  */
 private function buildProjects(array $test_assemblies)
 {
     $build_futures = array();
     $build_failed = false;
     $build_start = microtime(true);
     $results = array();
     foreach ($test_assemblies as $test_assembly) {
         $build_future = new ExecFuture('%C %s', $this->buildEngine, '/p:SkipTestsOnBuild=True');
         $build_future->setCWD(Filesystem::resolvePath(dirname($test_assembly['project'])));
         $build_futures[$test_assembly['project']] = $build_future;
     }
     $iterator = Futures($build_futures)->limit(1);
     foreach ($iterator as $test_assembly => $future) {
         $result = new ArcanistUnitTestResult();
         $result->setName('(build) ' . $test_assembly);
         try {
             $future->resolvex();
             $result->setResult(ArcanistUnitTestResult::RESULT_PASS);
         } catch (CommandException $exc) {
             if ($exc->getError() > 1) {
                 throw $exc;
             }
             $result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
             $result->setUserdata($exc->getStdout());
             $build_failed = true;
         }
         $result->setDuration(microtime(true) - $build_start);
         $results[] = $result;
     }
     return $results;
 }