Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/GoTestResultParser.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Go Test Result Parsing utility | * Go Test Result Parsing utility | ||||
| * | * | ||||
| * Intended to enable custom unit engines derived | * (To generate test output, run something like: `go test -v`) | ||||
| * from Go's built-in test utility to reuse | |||||
| * common business logic related to parsing | |||||
| * Go test results. | |||||
| * | |||||
| * (To generate test output, run something like: | |||||
| * `go test -v`) | |||||
| */ | */ | ||||
| final class GoTestResultParser extends ArcanistBaseTestResultParser { | final class GoTestResultParser extends ArcanistBaseTestResultParser { | ||||
| /** | /** | ||||
| * Parse test results from Go test report | * Parse test results from Go test report | ||||
| * (e.g. `go test -v`) | * (e.g. `go test -v`) | ||||
| * | * | ||||
| * @param string $path Path to test | * @param string $path Path to test | ||||
| * @param string $test_results String containing Go test output | * @param string $test_results String containing Go test output | ||||
| * | * | ||||
| * @return array | * @return array | ||||
| */ | */ | ||||
| public function parseTestResults($path, $test_results) { | 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(); | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | private function fixNames($test_case_results, $test_case_name) { | ||||
| foreach ($test_case_results as &$result) { | foreach ($test_case_results as &$result) { | ||||
| $test_name = $result->getName(); | $test_name = $result->getName(); | ||||
| $result->setName('Go::Test::'.$test_case_name.'::'.$test_name); | $result->setName('Go::Test::'.$test_case_name.'::'.$test_name); | ||||
| } | } | ||||
| return $test_case_results; | return $test_case_results; | ||||
| } | } | ||||
| } | } | ||||