Page MenuHomePhabricator

D12537.id30108.diff
No OneTemporary

D12537.id30108.diff

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 @@
+<?php
+
+/**
+ * Go test Wrapper
+ */
+abstract class GoBaseTestEngine extends ArcanistUnitTestEngine {
+
+ public function run() {
+ $this->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 @@
+<?php
+
+/**
+ * Go test Wrapper
+ */
+final class GoTestEngine extends GoBaseTestEngine {
+ protected $binary = 'go';
+}
diff --git a/src/unit/engine/GodepGoTestEngine.php b/src/unit/engine/GodepGoTestEngine.php
new file mode 100644
--- /dev/null
+++ b/src/unit/engine/GodepGoTestEngine.php
@@ -0,0 +1,8 @@
+<?php
+
+/**
+ * Go test Wrapper
+ */
+final class GodepGoTestEngine extends GoBaseTestEngine {
+ protected $binary = 'godep go';
+}

File Metadata

Mime Type
text/plain
Expires
Mar 30 2025, 7:31 PM (5 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7727422
Default Alt Text
D12537.id30108.diff (3 KB)

Event Timeline