1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Fix broken ArcanistPhpunitTestResultParser

Summary:
The ArcanistPhpunitTestResultParser has been changed
to use phutil_json_decode instead of json_decode in
rARCa4d33ef117aa8702181154b60ce1ce52bcfc119b
That has broken the functionality as json_decode has returned
an object before but phutil_json_decode does return an array.
The code has now been adopted to work with the array result
instead of an object.

Test Plan: Run a phpunit test case

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aurelijus, epriestley

Differential Revision: https://secure.phabricator.com/D12751
This commit is contained in:
Sascha Egerer 2015-05-07 08:41:28 -07:00 committed by epriestley
parent 6f7bedaceb
commit 3e36b3fc43

View file

@ -35,7 +35,7 @@ final class ArcanistPhpunitTestResultParser extends ArcanistTestResultParser {
$results = array(); $results = array();
foreach ($report as $event) { foreach ($report as $event) {
switch ($event->event) { switch (idx($event, 'event')) {
case 'test': case 'test':
break; break;
case 'testStart': case 'testStart':
@ -48,34 +48,42 @@ final class ArcanistPhpunitTestResultParser extends ArcanistTestResultParser {
$status = ArcanistUnitTestResult::RESULT_PASS; $status = ArcanistUnitTestResult::RESULT_PASS;
$user_data = ''; $user_data = '';
if ('fail' == $event->status) { if ('fail' == idx($event, 'status')) {
$status = ArcanistUnitTestResult::RESULT_FAIL; $status = ArcanistUnitTestResult::RESULT_FAIL;
$user_data .= $event->message."\n"; $user_data .= idx($event, 'message')."\n";
foreach ($event->trace as $trace) { foreach (idx($event, 'trace') as $trace) {
$user_data .= sprintf("\n%s:%s", $trace->file, $trace->line); $user_data .= sprintf(
"\n%s:%s",
idx($trace, 'file'),
idx($trace, 'line'));
} }
} else if ('error' == $event->status) { } else if ('error' == idx($event, 'status')) {
if (strpos($event->message, 'Skipped Test') !== false) { if (strpos(idx($event, 'message'), 'Skipped Test') !== false) {
$status = ArcanistUnitTestResult::RESULT_SKIP; $status = ArcanistUnitTestResult::RESULT_SKIP;
$user_data .= $event->message; $user_data .= idx($event, 'message');
} else if (strpos($event->message, 'Incomplete Test') !== false) { } else if (strpos(
idx($event, 'message'),
'Incomplete Test') !== false) {
$status = ArcanistUnitTestResult::RESULT_SKIP; $status = ArcanistUnitTestResult::RESULT_SKIP;
$user_data .= $event->message; $user_data .= idx($event, 'message');
} else { } else {
$status = ArcanistUnitTestResult::RESULT_BROKEN; $status = ArcanistUnitTestResult::RESULT_BROKEN;
$user_data .= $event->message; $user_data .= idx($event, 'message');
foreach ($event->trace as $trace) { foreach (idx($event, 'trace') as $trace) {
$user_data .= sprintf("\n%s:%s", $trace->file, $trace->line); $user_data .= sprintf(
"\n%s:%s",
idx($trace, 'file'),
idx($trace, 'line'));
} }
} }
} }
$name = preg_replace('/ \(.*\)/s', '', $event->test); $name = preg_replace('/ \(.*\)/s', '', idx($event, 'test'));
$result = new ArcanistUnitTestResult(); $result = new ArcanistUnitTestResult();
$result->setName($name); $result->setName($name);
$result->setResult($status); $result->setResult($status);
$result->setDuration($event->time); $result->setDuration(idx($event, 'time'));
$result->setCoverage($coverage); $result->setCoverage($coverage);
$result->setUserData($user_data); $result->setUserData($user_data);
@ -85,7 +93,7 @@ final class ArcanistPhpunitTestResultParser extends ArcanistTestResultParser {
if (!$last_test_finished) { if (!$last_test_finished) {
$results[] = id(new ArcanistUnitTestResult()) $results[] = id(new ArcanistUnitTestResult())
->setName($event->test) // use last event ->setName(idx($event, 'test')) // use last event
->setUserData($this->stderr) ->setUserData($this->stderr)
->setResult(ArcanistUnitTestResult::RESULT_BROKEN); ->setResult(ArcanistUnitTestResult::RESULT_BROKEN);
} }