Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14033704
D7848.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7848.diff
View Options
Index: src/unit/ArcanistUnitTestResult.php
===================================================================
--- src/unit/ArcanistUnitTestResult.php
+++ src/unit/ArcanistUnitTestResult.php
@@ -14,7 +14,6 @@
const RESULT_UNSOUND = 'unsound';
const RESULT_POSTPONED = 'postponed';
- private $namespace;
private $name;
private $link;
private $result;
Index: src/unit/engine/ArcanistBaseTestResultParser.php
===================================================================
--- src/unit/engine/ArcanistBaseTestResultParser.php
+++ 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
Index: src/unit/engine/PhpunitResultParser.php
===================================================================
--- src/unit/engine/PhpunitResultParser.php
+++ 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();
Index: src/unit/engine/PhpunitTestEngine.php
===================================================================
--- src/unit/engine/PhpunitTestEngine.php
+++ 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
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 10, 7:29 PM (2 d, 7 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746754
Default Alt Text
D7848.diff (4 KB)
Attached To
Mode
D7848: Print a more useful error message if any PHPUnit tests crash
Attached
Detach File
Event Timeline
Log In to Comment