diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -211,6 +211,9 @@ 'ArcanistXMLLinterTestCase' => 'lint/linter/__tests__/ArcanistXMLLinterTestCase.php', 'ArcanistXUnitTestResultParser' => 'unit/parser/ArcanistXUnitTestResultParser.php', 'CSharpToolsTestEngine' => 'unit/engine/CSharpToolsTestEngine.php', + 'GoBaseTestEngine' => 'unit/engine/GoBaseTestEngine.php', + 'GoTestEngine' => 'unit/engine/GoTestEngine.php', + 'GodepGoTestEngine' => 'unit/engine/GodepGoTestEngine.php', 'NoseTestEngine' => 'unit/engine/NoseTestEngine.php', 'PhpunitTestEngine' => 'unit/engine/PhpunitTestEngine.php', 'PhpunitTestEngineTestCase' => 'unit/engine/__tests__/PhpunitTestEngineTestCase.php', @@ -389,6 +392,9 @@ 'ArcanistXMLLinter' => 'ArcanistLinter', 'ArcanistXMLLinterTestCase' => 'ArcanistLinterTestCase', 'CSharpToolsTestEngine' => 'XUnitTestEngine', + 'GoBaseTestEngine' => 'ArcanistUnitTestEngine', + 'GoTestEngine' => 'GoBaseTestEngine', + 'GodepGoTestEngine' => 'GoBaseTestEngine', 'NoseTestEngine' => 'ArcanistUnitTestEngine', 'PhpunitTestEngine' => 'ArcanistUnitTestEngine', 'PhpunitTestEngineTestCase' => 'ArcanistTestCase', diff --git a/src/unit/engine/GoBaseTestEngine.php b/src/unit/engine/GoBaseTestEngine.php new file mode 100644 --- /dev/null +++ b/src/unit/engine/GoBaseTestEngine.php @@ -0,0 +1,48 @@ +affectedTests = array(); + foreach ($this->getPaths() as $path) { + // Always test the entire folder. + 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->affectedTests)) { + $this->affectedTests[] = $path; + } + } + + if (empty($this->affectedTests)) { + throw new ArcanistNoEffectException('No tests to run.'); + } + + $parser = new ArcanistGoTestResultParser(); + $results = array(); + + foreach ($this->affectedTests as $path) { + $args = ''; + if ($path !== '.') { + $args = $path; + } + list($err, $stdout, $stderr) = exec_manual( + '%s test -v ./%s', + $this->binary, + $args); + $r = $parser->parseTestResults(null, $stdout.$stderr); + $results = array_merge($results, $r); + } + + return $results; + } +} diff --git a/src/unit/engine/GoTestEngine.php b/src/unit/engine/GoTestEngine.php new file mode 100644 --- /dev/null +++ b/src/unit/engine/GoTestEngine.php @@ -0,0 +1,8 @@ +