From 9b7ee674eb40a80f427943afd33c68425adc0b8f Mon Sep 17 00:00:00 2001 From: tuomaspelkonen Date: Mon, 6 Jun 2011 16:43:36 -0700 Subject: [PATCH] Child classes can prevent echoing test results. 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 | 10 ++++++++++ src/workflow/unit/ArcanistUnitWorkflow.php | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/unit/engine/base/ArcanistBaseUnitTestEngine.php b/src/unit/engine/base/ArcanistBaseUnitTestEngine.php index c3dee67d..b6358274 100644 --- a/src/unit/engine/base/ArcanistBaseUnitTestEngine.php +++ b/src/unit/engine/base/ArcanistBaseUnitTestEngine.php @@ -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; + } } diff --git a/src/workflow/unit/ArcanistUnitWorkflow.php b/src/workflow/unit/ArcanistUnitWorkflow.php index f9716b96..46c6511b 100644 --- a/src/workflow/unit/ArcanistUnitWorkflow.php +++ b/src/workflow/unit/ArcanistUnitWorkflow.php @@ -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; } }