]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Child classes can prevent echoing test results.
authortuomaspelkonen <tuomaspelkonen@fb.com>
Mon, 6 Jun 2011 23:43:36 +0000 (16:43 -0700)
committertuomaspelkonen <tuomaspelkonen@fb.com>
Tue, 7 Jun 2011 18:01:51 +0000 (11:01 -0700)
Summary:
We changed our Facebook implementation to echo test results while the
tests are running. We do not want to echo the test results twice.

Test Plan:
Tested that implementing the function in PhutilUnitTestEngine and
returning true showed the results and returning false didn't show the
results.

Reviewed By: epriestley
Reviewers: jungejason, epriestley, grglr, slawekbiel
Commenters: slawekbiel, aran
CC: sgrimm, slawekbiel, aran, tuomaspelkonen, epriestley
Differential Revision: 400

src/unit/engine/base/ArcanistBaseUnitTestEngine.php
src/workflow/unit/ArcanistUnitWorkflow.php

index c3dee67d1e562fbf5cecc6fab16c3339a481f1f8..b635827421dab1f348018cce38780b5e8c644ce2 100644 (file)
@@ -71,4 +71,14 @@ abstract class ArcanistBaseUnitTestEngine {
   public function setDifferentialDiffID($id) {
     $this->diffID = $id;
   }
+
+  /**
+   * Modify the return value of this function in the child class, if
+   * you do not need to echo the test results after all the tests have
+   * been run. This is the case for example when the child class
+   * prints the tests results while the tests are running.
+   */
+  public function shouldEchoTestResults() {
+    return true;
+  }
 }
index f9716b96fde72414e3660d4f0f1777003111a1b9..46c6511b711934a188d6fb890ee156cfe0bf4f46 100644 (file)
@@ -122,9 +122,13 @@ EOTEXT
       if ($result_code == ArcanistUnitTestResult::RESULT_POSTPONED) {
         $postponed_count++;
       } else {
-        echo '  '.$status_codes[$result_code].' '.$result->getName()."\n";
+        if ($this->engine->shouldEchoTestResults()) {
+          echo '  '.$status_codes[$result_code].' '.$result->getName()."\n";
+        }
         if ($result_code != ArcanistUnitTestResult::RESULT_PASS) {
-          echo $result->getUserData()."\n";
+          if ($this->engine->shouldEchoTestResults()) {
+            echo $result->getUserData()."\n";
+          }
           $unresolved[] = $result;
         }
       }