From cdb161a19a76990c9a40bcffb834387e9c3581a1 Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 7 Sep 2012 14:18:55 -0700 Subject: [PATCH] Allow Phutil tests setting link Summary: Also delete some copy pasta. Test Plan: Next diff. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3455 --- .../engine/phutil/ArcanistPhutilTestCase.php | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/unit/engine/phutil/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/ArcanistPhutilTestCase.php index e0ec47d8..17ad7574 100644 --- a/src/unit/engine/phutil/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/ArcanistPhutilTestCase.php @@ -349,15 +349,7 @@ abstract class ArcanistPhutilTestCase { * @task internal */ final private function failTest($reason) { - $coverage = $this->endCoverage(); - - $result = new ArcanistUnitTestResult(); - $result->setCoverage($coverage); - $result->setName($this->runningTest); - $result->setResult(ArcanistUnitTestResult::RESULT_FAIL); - $result->setDuration(microtime(true) - $this->testStartTime); - $result->setUserData($reason); - $this->results[] = $result; + $this->resultTest(ArcanistUnitTestResult::RESULT_FAIL, $reason); } @@ -370,15 +362,7 @@ abstract class ArcanistPhutilTestCase { * @task internal */ final private function passTest($reason) { - $coverage = $this->endCoverage(); - - $result = new ArcanistUnitTestResult(); - $result->setCoverage($coverage); - $result->setName($this->runningTest); - $result->setResult(ArcanistUnitTestResult::RESULT_PASS); - $result->setDuration(microtime(true) - $this->testStartTime); - $result->setUserData($reason); - $this->results[] = $result; + $this->resultTest(ArcanistUnitTestResult::RESULT_PASS, $reason); } @@ -390,12 +374,18 @@ abstract class ArcanistPhutilTestCase { * @task internal */ final private function skipTest($reason) { + $this->resultTest(ArcanistUnitTestResult::RESULT_SKIP, $reason); + } + + + final private function resultTest($test_result, $reason) { $coverage = $this->endCoverage(); $result = new ArcanistUnitTestResult(); $result->setCoverage($coverage); $result->setName($this->runningTest); - $result->setResult(ArcanistUnitTestResult::RESULT_SKIP); + $result->setLink($this->getLink($this->runningTest)); + $result->setResult($test_result); $result->setDuration(microtime(true) - $this->testStartTime); $result->setUserData($reason); $this->results[] = $result; @@ -542,4 +532,8 @@ abstract class ArcanistPhutilTestCase { return $this; } + protected function getLink($method) { + return null; + } + }