Page MenuHomePhabricator

D7848.diff

diff --git a/src/unit/ArcanistUnitTestResult.php b/src/unit/ArcanistUnitTestResult.php
--- a/src/unit/ArcanistUnitTestResult.php
+++ b/src/unit/ArcanistUnitTestResult.php
@@ -14,7 +14,6 @@
const RESULT_UNSOUND = 'unsound';
const RESULT_POSTPONED = 'postponed';
- private $namespace;
private $name;
private $link;
private $result;
diff --git a/src/unit/engine/ArcanistBaseTestResultParser.php b/src/unit/engine/ArcanistBaseTestResultParser.php
--- a/src/unit/engine/ArcanistBaseTestResultParser.php
+++ b/src/unit/engine/ArcanistBaseTestResultParser.php
@@ -8,6 +8,7 @@
protected $enableCoverage;
protected $projectRoot;
protected $coverageFile;
+ protected $stderr;
public function setEnableCoverage($enable_coverage) {
$this->enableCoverage = $enable_coverage;
@@ -33,6 +34,11 @@
return $this;
}
+ public function setStderr($stderr) {
+ $this->stderr = $stderr;
+ return $this;
+ }
+
/**
* Parse test results from provided input and return an array
* of ArcanistUnitTestResult
diff --git a/src/unit/engine/PhpunitResultParser.php b/src/unit/engine/PhpunitResultParser.php
--- a/src/unit/engine/PhpunitResultParser.php
+++ b/src/unit/engine/PhpunitResultParser.php
@@ -23,6 +23,14 @@
*/
public function parseTestResults($path, $test_results) {
+ if (!$test_results) {
+ $result = id(new ArcanistUnitTestResult())
+ ->setName($path)
+ ->setUserData($this->stderr)
+ ->setResult(ArcanistUnitTestResult::RESULT_BROKEN);
+ return array($result);
+ }
+
$report = $this->getJsonReport($test_results);
// coverage is for all testcases in the executed $path
@@ -33,8 +41,14 @@
$results = array();
foreach ($report as $event) {
- if ('test' != $event->event) {
- continue;
+ switch ($event->event) {
+ case 'test':
+ break;
+ case 'testStart':
+ $lastTestFinished = false;
+ // fall through
+ default:
+ continue 2; // switch + loop
}
$status = ArcanistUnitTestResult::RESULT_PASS;
@@ -72,8 +86,15 @@
$result->setUserData($user_data);
$results[] = $result;
+ $lastTestFinished = true;
}
+ if (!$lastTestFinished) {
+ $results[] = id(new ArcanistUnitTestResult())
+ ->setName($event->test) // use last event
+ ->setUserData($this->stderr)
+ ->setResult(ArcanistUnitTestResult::RESULT_BROKEN);
+ }
return $results;
}
@@ -85,12 +106,7 @@
private function readCoverage() {
$test_results = Filesystem::readFile($this->coverageFile);
if (empty($test_results)) {
- throw new Exception('Clover coverage XML report file is empty, '
- . 'it probably means that phpunit failed to run tests. '
- . 'Try running arc unit with --trace option and then run '
- . 'generated phpunit command yourself, you might get the '
- . 'answer.'
- );
+ return array();
}
$coverage_dom = new DOMDocument();
diff --git a/src/unit/engine/PhpunitTestEngine.php b/src/unit/engine/PhpunitTestEngine.php
--- a/src/unit/engine/PhpunitTestEngine.php
+++ b/src/unit/engine/PhpunitTestEngine.php
@@ -71,8 +71,10 @@
$config = $this->configFile ? csprintf('-c %s', $this->configFile) : null;
- $futures[$test_path] = new ExecFuture('%C %C --log-json %s %C %s',
- $this->phpunitBinary, $config, $json_tmp, $clover, $test_path);
+ $stderr = "-d display_errors=stderr";
+
+ $futures[$test_path] = new ExecFuture('%C %C %C --log-json %s %C %s',
+ $this->phpunitBinary, $config, $stderr, $json_tmp, $clover, $test_path);
$tmpfiles[$test_path] = array(
'json' => $json_tmp,
'clover' => $clover_tmp,
@@ -89,7 +91,8 @@
$results[] = $this->parseTestResults(
$test,
$tmpfiles[$test]['json'],
- $tmpfiles[$test]['clover']);
+ $tmpfiles[$test]['clover'],
+ $stderr);
}
return array_mergev($results);
@@ -101,16 +104,18 @@
* @param string $path Path to test
* @param string $json_tmp Path to phpunit json report
* @param string $clover_tmp Path to phpunit clover report
+ * @param string $stderr Data written to stderr
*
* @return array
*/
- private function parseTestResults($path, $json_tmp, $clover_tmp) {
+ private function parseTestResults($path, $json_tmp, $clover_tmp, $stderr) {
$test_results = Filesystem::readFile($json_tmp);
return id(new PhpunitResultParser())
->setEnableCoverage($this->getEnableCoverage())
->setProjectRoot($this->projectRoot)
->setCoverageFile($clover_tmp)
->setAffectedTests($this->affectedTests)
+ ->setStderr($stderr)
->parseTestResults($path, $test_results);
}

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/2s/es/poz4dpdsqja2ooyq
Default Alt Text
D7848.diff (4 KB)

Event Timeline