]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow Phutil tests setting link
authorvrana <jakubv@fb.com>
Fri, 7 Sep 2012 21:18:55 +0000 (14:18 -0700)
committervrana <jakubv@fb.com>
Fri, 7 Sep 2012 22:42:50 +0000 (15:42 -0700)
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

src/unit/engine/phutil/ArcanistPhutilTestCase.php

index e0ec47d8643400f9a5c00a7f1adecd9b548e7bc9..17ad75749d1f14ee97583633101f1930696ccdd9 100644 (file)
@@ -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;
+  }
+
 }