From: indiefan Date: Mon, 28 Jan 2013 01:16:50 +0000 (-0800) Subject: Added base test result parser class. Implemented Go test result parser based on Go... X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ce0a491bcd168148107d0fa22b760dc6973ec29a;p=arcanist.git Added base test result parser class. Implemented Go test result parser based on Go's built in test utility output. Test Plan: Ran PhpunitTestEngine unit test and used both test result parsers to generate test results. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, aurelijus Differential Revision: https://secure.phabricator.com/D4676 --- diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7da6c249..03370337 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -18,6 +18,7 @@ phutil_register_library_map(array( 'ArcanistArcanistLinterTestCase' => 'lint/linter/__tests__/ArcanistArcanistLinterTestCase.php', 'ArcanistBaseCommitParser' => 'parser/ArcanistBaseCommitParser.php', 'ArcanistBaseCommitParserTestCase' => 'parser/__tests__/ArcanistBaseCommitParserTestCase.php', + 'ArcanistBaseTestResultParser' => 'unit/engine/ArcanistBaseTestResultParser.php', 'ArcanistBaseUnitTestEngine' => 'unit/engine/ArcanistBaseUnitTestEngine.php', 'ArcanistBaseWorkflow' => 'workflow/ArcanistBaseWorkflow.php', 'ArcanistBranchWorkflow' => 'workflow/ArcanistBranchWorkflow.php', @@ -143,6 +144,8 @@ phutil_register_library_map(array( 'ArcanistXHPASTLinterTestCase' => 'lint/linter/__tests__/ArcanistXHPASTLinterTestCase.php', 'ComprehensiveLintEngine' => 'lint/engine/ComprehensiveLintEngine.php', 'ExampleLintEngine' => 'lint/engine/ExampleLintEngine.php', + 'GoTestResultParser' => 'unit/engine/GoTestResultParser.php', + 'GoTestResultParserTestCase' => 'unit/engine/__tests__/GoTestResultParserTestCase.php', 'NoseTestEngine' => 'unit/engine/NoseTestEngine.php', 'PHPUnitTestEngineTestCase' => 'unit/engine/__tests__/PHPUnitTestEngineTestCase.php', 'PhpunitResultParser' => 'unit/engine/PhpunitResultParser.php', @@ -259,8 +262,11 @@ phutil_register_library_map(array( 'ArcanistXHPASTLinterTestCase' => 'ArcanistArcanistLinterTestCase', 'ComprehensiveLintEngine' => 'ArcanistLintEngine', 'ExampleLintEngine' => 'ArcanistLintEngine', + 'GoTestResultParser' => 'ArcanistBaseTestResultParser', + 'GoTestResultParserTestCase' => 'ArcanistTestCase', 'NoseTestEngine' => 'ArcanistBaseUnitTestEngine', 'PHPUnitTestEngineTestCase' => 'ArcanistTestCase', + 'PhpunitResultParser' => 'ArcanistBaseTestResultParser', 'PhpunitTestEngine' => 'ArcanistBaseUnitTestEngine', 'PhutilLintEngine' => 'ArcanistLintEngine', 'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine', diff --git a/src/unit/engine/ArcanistBaseTestResultParser.php b/src/unit/engine/ArcanistBaseTestResultParser.php new file mode 100644 index 00000000..11389abe --- /dev/null +++ b/src/unit/engine/ArcanistBaseTestResultParser.php @@ -0,0 +1,46 @@ +enableCoverage = $enable_coverage; + + return $this; + } + + public function setProjectRoot($project_root) { + $this->projectRoot = $project_root; + + return $this; + } + + public function setCoverageFile($coverage_file) { + $this->coverageFile = $coverage_file; + + return $this; + } + + public function setAffectedTests($affected_tests) { + $this->affectedTests = $affected_tests; + + return $this; + } + + /** + * Parse test results from provided input and return an array + * of ArcanistUnitTestResult + * + * @param string $path Path to test + * @param string $test_results String containing test results + * + * @return array ArcanistUnitTestResult + */ + abstract public function parseTestResults($path, $test_results); +} diff --git a/src/unit/engine/GoTestResultParser.php b/src/unit/engine/GoTestResultParser.php new file mode 100644 index 00000000..5debcbf4 --- /dev/null +++ b/src/unit/engine/GoTestResultParser.php @@ -0,0 +1,140 @@ + $line) { + + if (strncmp($line, "--- PASS", 8) === 0) { + // We have a passing test + $meta = array(); + preg_match( + '/^--- PASS: (?P.+) \((?P