Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions go_test_engine/__phutil_library_init__.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

phutil_register_library('go-test-engine', __FILE__);

18 changes: 18 additions & 0 deletions go_test_engine/__phutil_library_map__.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* This file is automatically generated. Use 'arc liberate' to rebuild it.
*
* @generated
* @phutil-library-version 2
*/
phutil_register_library_map(array(
'__library_version__' => 2,
'class' => array(
'GoTestEngine' => 'src/GoTestEngine.php',
),
'function' => array(),
'xmap' => array(
'GoTestEngine' => 'ArcanistUnitTestEngine',
),
));
19 changes: 19 additions & 0 deletions go_test_engine/src/GoTestEngine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
final class GoTestEngine extends ArcanistUnitTestEngine {
public function run() {
$command = $this->getConfigurationManager()->getConfigFromAnySource('unit.engine.go.command');
$future = new ExecFuture($command);

do {
list($stdout, $stderr) = $future->read();
echo $stdout;
echo $stderr;
sleep(0.5);
} while (!$future->isReady());

list($error, $stdout, $stderr) = $future->resolve();

$parser = new ArcanistGoTestResultParser();
return $parser->parseTestResults("", $stdout);
}
}
51 changes: 48 additions & 3 deletions multi_test_engine/src/MultiTestEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,65 @@ public function run() {
$results = array();

foreach ($engines as $engine_or_configuration) {
$include = false;
$includeReport = false;
$changedFileMatchesInclude = false;

if (is_array($engine_or_configuration)) {
$engine_class = $engine_or_configuration['engine'];

foreach ($engine_or_configuration as $configuration => $value) {
if ($configuration != 'engine') {
if ($configuration != 'engine' &&
$configuration != 'include' &&
$configuration != 'include_report') {
$config->setRuntimeConfig($configuration, $value);
}

switch($configuration) {
case 'include':
$include = $value;
break;
case 'include_report':
$includeReport = $value
break
}
}
} else {
$engine_class = $engine_or_configuration;
}

$engine = $this->instantiateEngine($engine_class);
$results = array_merge($results, $engine->run());

// If a regex is configured we'll do a match on all changed files to see if there's a match
// before calling $engine->run()
if ($include) {
$include = '/' . $include . '/';
foreach ($this->getPaths() as $path) {
if (preg_match($include, $path)) {
$changedFileMatchesInclude = true;
break;
}
}
}

// No need to execute the unit tests, so bail - but do report that we skipped running tests.
if (!$changedFileMatchesInclude) {
$test_results = [];
// Be silent by default if no files match the include regex, but if the config
// includes a bit to see it, output a skip test result for visibility when
// no tests match the include regex.
if ($includeReport) {
$skip_test = new ArcanistUnitTestResult();
$skip_test->setName("No changed files match " . $include . " - not running " . $engine_class);
$skip_test->setResult(ArcanistUnitTestResult::RESULT_SKIP);
$test_results[] = $skip_test;
}

// Actually run the tests if we didn't already decide not to run them.
} else {
$test_results = $engine->run();
}

$results = array_merge($results, $test_results);
}

return $results;
Expand Down