Skip to content

Instantly share code, notes, and snippets.

@kalbasit
Created April 24, 2015 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalbasit/27bb67b7428034b32fa4 to your computer and use it in GitHub Desktop.
Save kalbasit/27bb67b7428034b32fa4 to your computer and use it in GitHub Desktop.
Phabricator Go Testing.
<?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) {
list($err, $stdout, $stderr) = exec_manual($this->binary . ' test -v ./' . $path);
$r = $parser->parseTestResults(null, $stdout . $stderr);
$results = array_merge($results, $r);
}
return $results;
}
}
?>
<?php
/**
* Go test Wrapper
*/
final class GodepGoTestEngine extends GoBaseTestEngine {
protected $binary = 'godep go';
}
?>
<?php
/**
* Go test Wrapper
*/
final class GoTestEngine extends GoBaseTestEngine {
protected $binary = 'go';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment