Changeset View
Changeset View
Standalone View
Standalone View
src/unit/parser/ArcanistGoTestResultParser.php
| Show All 19 Lines | public function parseTestResults($path, $test_results) { | ||||
| $test_results = explode("\n", $test_results); | $test_results = explode("\n", $test_results); | ||||
| $results = array(); | $results = array(); | ||||
| // We'll get our full test case name at the end and add it back in | // We'll get our full test case name at the end and add it back in | ||||
| $test_case_name = ''; | $test_case_name = ''; | ||||
| // 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) { | for ($i = 0; $i < count($test_results); $i++) { | ||||
| $line = $test_results[$i]; | |||||
| if (strlen($line) >= 18 | |||||
| && strncmp($line, '==================', 18) === 0 | |||||
| && strncmp($test_results[$i + 1], 'WARNING: DATA RACE', 18) === 0) { | |||||
| // We have a race condition | |||||
| $i++; // Advance to WARNING: DATA RACE | |||||
| $reason = ''; | |||||
| $test_name = ''; | |||||
| // loop to collect all data and move to the === line | |||||
| while (strncmp($test_results[$i], '==================', 18) !== 0) { | |||||
| if (strncmp($test_results[$i], 'Goroutine', 9) === 0) { | |||||
| $meta = array(); | |||||
| preg_match( | |||||
| '/^.*\.(?P<test_name>[^\.]+)$/', | |||||
| $test_results[$i + 1], | |||||
| $meta); | |||||
| $test_name = $meta['test_name'].' Race Detected'; | |||||
| } | |||||
| $reason .= $test_results[$i++]."\n"; | |||||
| } | |||||
| $result = new ArcanistUnitTestResult(); | |||||
| $result->setName($test_name); | |||||
| $result->setResult(ArcanistUnitTestResult::RESULT_FAIL); | |||||
| $result->setUserData($reason); | |||||
| $test_case_results[] = $result; | |||||
| continue; | |||||
| } | |||||
| 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>.+)\s*s(?:econds)?\).*/', | '/^--- PASS: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds)?\).*/', | ||||
| $line, | $line, | ||||
| $meta); | $meta); | ||||
| ▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines | |||||