Changeset View
Changeset View
Standalone View
Standalone View
src/unit/parser/ArcanistGoTestResultParser.php
Show All 25 Lines | public function parseTestResults($path, $test_results) { | ||||
// Temp store for test case results (in case we run multiple test cases) | // Temp store for test case results (in case we run multiple test cases) | ||||
$test_case_results = array(); | $test_case_results = array(); | ||||
foreach ($test_results as $i => $line) { | foreach ($test_results as $i => $line) { | ||||
if (strncmp($line, '--- PASS', 8) === 0) { | if (strncmp($line, '--- PASS', 8) === 0) { | ||||
// We have a passing test | // We have a passing test | ||||
$meta = array(); | $meta = array(); | ||||
preg_match( | preg_match( | ||||
'/^--- PASS: (?P<test_name>.+) \((?P<time>.+) seconds\).*/', | '/^--- PASS: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds)?\).*/', | ||||
$line, | $line, | ||||
$meta); | $meta); | ||||
$result = new ArcanistUnitTestResult(); | $result = new ArcanistUnitTestResult(); | ||||
// For now set name without test case, we'll add it later | // For now set name without test case, we'll add it later | ||||
$result->setName($meta['test_name']); | $result->setName($meta['test_name']); | ||||
$result->setResult(ArcanistUnitTestResult::RESULT_PASS); | $result->setResult(ArcanistUnitTestResult::RESULT_PASS); | ||||
$result->setDuration($meta['time']); | $result->setDuration($meta['time']); | ||||
$test_case_results[] = $result; | $test_case_results[] = $result; | ||||
continue; | continue; | ||||
} | } | ||||
if (strncmp($line, '--- FAIL', 8) === 0) { | if (strncmp($line, '--- FAIL', 8) === 0) { | ||||
// We have a failing test | // We have a failing test | ||||
$reason = trim($test_results[$i + 1]); | $reason = trim($test_results[$i + 1]); | ||||
$meta = array(); | $meta = array(); | ||||
preg_match( | preg_match( | ||||
'/^--- FAIL: (?P<test_name>.+) \((?P<time>.+) seconds\).*/', | '/^--- FAIL: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds)?\).*/', | ||||
$line, | $line, | ||||
$meta); | $meta); | ||||
$result = new ArcanistUnitTestResult(); | $result = new ArcanistUnitTestResult(); | ||||
$result->setName($meta['test_name']); | $result->setName($meta['test_name']); | ||||
$result->setResult(ArcanistUnitTestResult::RESULT_FAIL); | $result->setResult(ArcanistUnitTestResult::RESULT_FAIL); | ||||
$result->setDuration($meta['time']); | $result->setDuration($meta['time']); | ||||
$result->setUserData($reason."\n"); | $result->setUserData($reason."\n"); | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |