Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/XUnitTestEngine.php
| Show All 36 Lines | protected function loadEnvironment() { | ||||
| $this->projectRoot = $this->getWorkingCopy()->getProjectRoot(); | $this->projectRoot = $this->getWorkingCopy()->getProjectRoot(); | ||||
| // Determine build engine. | // Determine build engine. | ||||
| if (Filesystem::binaryExists('msbuild')) { | if (Filesystem::binaryExists('msbuild')) { | ||||
| $this->buildEngine = 'msbuild'; | $this->buildEngine = 'msbuild'; | ||||
| } else if (Filesystem::binaryExists('xbuild')) { | } else if (Filesystem::binaryExists('xbuild')) { | ||||
| $this->buildEngine = 'xbuild'; | $this->buildEngine = 'xbuild'; | ||||
| } else { | } else { | ||||
| throw new Exception('Unable to find msbuild or xbuild in PATH!'); | throw new Exception( | ||||
| pht( | |||||
| 'Unable to find %s or %s in %s!', | |||||
| 'msbuild', | |||||
| 'xbuild', | |||||
| 'PATH')); | |||||
| } | } | ||||
| // Determine runtime engine (.NET or Mono). | // Determine runtime engine (.NET or Mono). | ||||
| if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
| $this->runtimeEngine = ''; | $this->runtimeEngine = ''; | ||||
| } else if (Filesystem::binaryExists('mono')) { | } else if (Filesystem::binaryExists('mono')) { | ||||
| $this->runtimeEngine = Filesystem::resolveBinary('mono'); | $this->runtimeEngine = Filesystem::resolveBinary('mono'); | ||||
| } else { | } else { | ||||
| throw new Exception('Unable to find Mono and you are not on Windows!'); | throw new Exception( | ||||
| pht('Unable to find Mono and you are not on Windows!')); | |||||
| } | } | ||||
| // Read the discovery rules. | // Read the discovery rules. | ||||
| $this->discoveryRules = | $this->discoveryRules = | ||||
| $this->getConfigurationManager()->getConfigFromAnySource( | $this->getConfigurationManager()->getConfigFromAnySource( | ||||
| 'unit.csharp.discovery'); | 'unit.csharp.discovery'); | ||||
| if ($this->discoveryRules === null) { | if ($this->discoveryRules === null) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | |||||
| 'You must configure discovery rules to map C# files '. | 'You must configure discovery rules to map C# files '. | ||||
| 'back to test projects (`unit.csharp.discovery` in .arcconfig).'); | 'back to test projects (`%s` in %s).', | ||||
| 'unit.csharp.discovery', | |||||
| '.arcconfig')); | |||||
| } | } | ||||
| // Determine xUnit test runner path. | // Determine xUnit test runner path. | ||||
| if ($this->xunitHintPath === null) { | if ($this->xunitHintPath === null) { | ||||
| $this->xunitHintPath = | $this->xunitHintPath = | ||||
| $this->getConfigurationManager()->getConfigFromAnySource( | $this->getConfigurationManager()->getConfigFromAnySource( | ||||
| 'unit.csharp.xunit.binary'); | 'unit.csharp.xunit.binary'); | ||||
| } | } | ||||
| $xunit = $this->projectRoot.DIRECTORY_SEPARATOR.$this->xunitHintPath; | $xunit = $this->projectRoot.DIRECTORY_SEPARATOR.$this->xunitHintPath; | ||||
| if (file_exists($xunit) && $this->xunitHintPath !== null) { | if (file_exists($xunit) && $this->xunitHintPath !== null) { | ||||
| $this->testEngine = Filesystem::resolvePath($xunit); | $this->testEngine = Filesystem::resolvePath($xunit); | ||||
| } else if (Filesystem::binaryExists('xunit.console.clr4.exe')) { | } else if (Filesystem::binaryExists('xunit.console.clr4.exe')) { | ||||
| $this->testEngine = 'xunit.console.clr4.exe'; | $this->testEngine = 'xunit.console.clr4.exe'; | ||||
| } else { | } else { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | |||||
| "Unable to locate xUnit console runner. Configure ". | "Unable to locate xUnit console runner. Configure ". | ||||
| "it with the `unit.csharp.xunit.binary' option in .arcconfig"); | "it with the `%s' option in %s.", | ||||
| 'unit.csharp.xunit.binary', | |||||
| '.arcconfig')); | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Main entry point for the test engine. Determines what assemblies to build | * Main entry point for the test engine. Determines what assemblies to build | ||||
| * and test based on the files that have changed. | * and test based on the files that have changed. | ||||
| * | * | ||||
| * @return array Array of test results. | * @return array Array of test results. | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | private function generateProjects() { | ||||
| $regenerate_future = new ExecFuture( | $regenerate_future = new ExecFuture( | ||||
| '%C Protobuild.exe --resync %s', | '%C Protobuild.exe --resync %s', | ||||
| $this->runtimeEngine, | $this->runtimeEngine, | ||||
| $platform); | $platform); | ||||
| $regenerate_future->setCWD(Filesystem::resolvePath( | $regenerate_future->setCWD(Filesystem::resolvePath( | ||||
| $this->projectRoot)); | $this->projectRoot)); | ||||
| $results = array(); | $results = array(); | ||||
| $result = new ArcanistUnitTestResult(); | $result = new ArcanistUnitTestResult(); | ||||
| $result->setName("(regenerate projects for $platform)"); | $result->setName(pht('(regenerate projects for %s)', $platform)); | ||||
| try { | try { | ||||
| $regenerate_future->resolvex(); | $regenerate_future->resolvex(); | ||||
| $result->setResult(ArcanistUnitTestResult::RESULT_PASS); | $result->setResult(ArcanistUnitTestResult::RESULT_PASS); | ||||
| } catch(CommandException $exc) { | } catch(CommandException $exc) { | ||||
| if ($exc->getError() > 1) { | if ($exc->getError() > 1) { | ||||
| throw $exc; | throw $exc; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines | |||||