Page MenuHomePhabricator

PantsTestEngine.php

Authored By
cburroughs
Jan 29 2016, 7:09 PM
Size
1 KB
Referenced Files
None
Subscribers
None

PantsTestEngine.php

<?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;
}
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33378
Default Alt Text
PantsTestEngine.php (1 KB)

Event Timeline