Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15536935
D12537.id30127.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12537.id30127.diff
View Options
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,54 @@
+<?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;
+ }
+}
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,10 @@
+<?php
+
+/**
+ * Go test.
+ */
+final class GoTestEngine extends GoBaseTestEngine {
+ protected function testPackage($package) {
+ return exec_manual('go test -v ./%s', $package);
+ }
+}
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,10 @@
+<?php
+
+/**
+ * Go test through Godep.
+ */
+final class GodepGoTestEngine extends GoBaseTestEngine {
+ protected function testPackage($package) {
+ return exec_manual('godep go test -v ./%s', $package);
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 25, 11:26 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223261
Default Alt Text
D12537.id30127.diff (3 KB)
Attached To
Mode
D12537: Add a Go unit test engine (through go and godep).
Attached
Detach File
Event Timeline
Log In to Comment