Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/GoBaseTestEngine.php
- This file was added.
| <?php | |||||
| /** | |||||
| * Go test Runner | |||||
| */ | |||||
| abstract class GoBaseTestEngine extends ArcanistUnitTestEngine { | |||||
| /** | |||||
| * testPackage must be defined by subclasses. | |||||
| * | |||||
| * @param $package The package path relative to the project root path | |||||
| * @return command exit code | |||||
| * @return stdout | |||||
| * @return stderr | |||||
| */ | |||||
| abstract protected function testPackage($package); | |||||
| public function run() { | |||||
| $this->affectedPackages = array(); | |||||
| foreach ($this->getPaths() as $path) { | |||||
| // Must always test a package. | |||||
| if (!is_dir($path)) { | |||||
| // If it's a file but not a go file. Skip this test | |||||
| if (substr($path, -3) != '.go') { | |||||
| continue; | |||||
| } | |||||
| $path = dirname($path); | |||||
| } | |||||
| if (!array_key_exists($path, $this->affectedPackages)) { | |||||
| $this->affectedPackages[] = $path; | |||||
| } | |||||
| } | |||||
| if (empty($this->affectedPackages)) { | |||||
| throw new ArcanistNoEffectException('No tests to run.'); | |||||
| } | |||||
| $parser = new ArcanistGoTestResultParser(); | |||||
| $results = array(); | |||||
| foreach ($this->affectedPackages as $package) { | |||||
| if ($package == '.') { | |||||
| $package = ''; | |||||
| } | |||||
| list($err, $stdout, $stderr) = $this->testPackage($package); | |||||
| $r = $parser->parseTestResults(null, $stdout.$stderr); | |||||
| $results = array_merge($results, $r); | |||||
| } | |||||
| return $results; | |||||
| } | |||||
| } | |||||