Page MenuHomePhabricator
Paste P1934

PantsTestEngine.php
ActivePublic

Authored by cburroughs on Jan 29 2016, 6:58 PM.
Tags
None
Referenced Files
F1081440: PantsTestEngine.php
Jan 29 2016, 7:09 PM
F1081429: PantsTestEngine.php
Jan 29 2016, 6:58 PM
Subscribers
None
<?php
final class PantsTestEngine extends ArcanistUnitTestEngine {
public function getEngineConfigurationName() {
return "pants";
}
public function run() {
$projectRoot = $this->getWorkingCopy()->getProjectRoot();
$xunit_dir = Filesystem::createTemporaryDirectory();
$future = $this->buildTestFuture($xunit_dir);
$future->setCWD($projectRoot);
list($err, $stdout, $stderr) = $future->resolve();
$results = array();
$xunit_files = glob(Filesystem::resolvePath($xunit_dir."/*.xml"));
foreach ($xunit_files as $xunit_file) {
$results[] = $this->parseTestResults($xunit_file);
}
Filesystem::remove($xunit_dir);
return array_mergev($results);
}
public function buildTestFuture($xunit_dir) {
$paths = $this->getPaths();
$cmd_line = csprintf('./pants test-changed --test-changed-include-dependees=transitive --test-changed-parent=origin/master --test-pytest-junit-xml-dir=%s', $xunit_dir);
return new ExecFuture('%C', $cmd_line);
}
public function parseTestResults($xunit_file) {
$parser = new ArcanistXUnitTestResultParser();
$results = $parser->parseTestResults(Filesystem::readFile($xunit_file));
return $results;
}
}