]> khamidou — GitHub mirrors - arcanist.git/commitdiff
'arc diff' passes the diff ID to Test Engine class.
authortuomaspelkonen <tuomaspelkonen@fb.com>
Fri, 27 May 2011 23:15:43 +0000 (16:15 -0700)
committertuomaspelkonen <tuomaspelkonen@fb.com>
Thu, 2 Jun 2011 19:19:05 +0000 (12:19 -0700)
Summary:
Test Engine classes might need the differential Diff ID to be
able to attach postponed test results to diffs.

Test Plan:
Added setDifferentialDiff function to PhutilUnitTestEngine class
and made sure it was called with the correct diff ID when running
'arc diff --preview'

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

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

index a8f5b41ddc21e9151d1777d120c5137276959464..c3dee67d1e562fbf5cecc6fab16c3339a481f1f8 100644 (file)
@@ -26,6 +26,7 @@ abstract class ArcanistBaseUnitTestEngine {
   private $workingCopy;
   private $paths;
   private $arguments = array();
+  protected $diffID;
 
   final public function __construct() {
 
@@ -62,4 +63,12 @@ abstract class ArcanistBaseUnitTestEngine {
 
   abstract public function run();
 
+  /**
+   * This function is called after run() when the diff is created
+   * Child classes should override this function if they want to
+   * do more with the diff ID.
+   */
+  public function setDifferentialDiffID($id) {
+    $this->diffID = $id;
+  }
 }
index b86ecc732946d29f8534be86d7613ce67736fec1..f21e5f67ac9cf85712e3be73e29271b7e86ffddf 100644 (file)
@@ -27,6 +27,7 @@ class ArcanistDiffWorkflow extends ArcanistBaseWorkflow {
   private $unresolvedLint;
   private $unresolvedTests;
   private $diffID;
+  private $unitWorkflow;
 
   public function getCommandHelp() {
     return phutil_console_format(<<<EOTEXT
@@ -295,6 +296,10 @@ EOTEXT
       'differential.creatediff',
       $diff);
 
+    if ($this->unitWorkflow) {
+      $this->unitWorkflow->setDifferentialDiffID($diff_info['diffid']);
+    }
+
     if ($this->unresolvedLint) {
       $data = array();
       foreach ($this->unresolvedLint as $message) {
@@ -1107,8 +1112,8 @@ EOTEXT
       if ($repository_api instanceof ArcanistSubversionAPI) {
         $argv = array_merge($argv, array_keys($paths));
       }
-      $unit_workflow = $this->buildChildWorkflow('unit', $argv);
-      $unit_result   = $unit_workflow->run();
+      $this->unitWorkflow = $this->buildChildWorkflow('unit', $argv);
+      $unit_result = $this->unitWorkflow->run();
       switch ($unit_result) {
         case ArcanistUnitWorkflow::RESULT_OKAY:
           echo phutil_console_format(
@@ -1133,7 +1138,7 @@ EOTEXT
           break;
       }
 
-      $this->unresolvedTests = $unit_workflow->getUnresolvedTests();
+      $this->unresolvedTests = $this->unitWorkflow->getUnresolvedTests();
 
       return $unit_result;
     } catch (ArcanistNoEngineException $ex) {
index c706ce9e14bf6265f338568f492503e483827045..0a53487e51330f9e1314566048942025e2ad1780 100644 (file)
@@ -29,6 +29,7 @@ class ArcanistUnitWorkflow extends ArcanistBaseWorkflow {
   const RESULT_SKIP     = 3;
 
   private $unresolvedTests;
+  private $engine;
 
   public function getCommandHelp() {
     return phutil_console_format(<<<EOTEXT
@@ -92,12 +93,12 @@ EOTEXT
 
 
     PhutilSymbolLoader::loadClass($engine_class);
-    $engine = newv($engine_class, array());
-    $engine->setWorkingCopy($working_copy);
-    $engine->setPaths($paths);
-    $engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
+    $this->engine = newv($engine_class, array());
+    $this->engine->setWorkingCopy($working_copy);
+    $this->engine->setPaths($paths);
+    $this->engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
 
-    $results = $engine->run();
+    $results = $this->engine->run();
 
     $status_codes = array(
       ArcanistUnitTestResult::RESULT_PASS => phutil_console_format(
@@ -156,4 +157,10 @@ EOTEXT
     return $this->unresolvedTests;
   }
 
+  public function setDifferentialDiffID($id) {
+    if ($this->engine) {
+      $this->engine->setDifferentialDiffID($id);
+    }
+  }
+
 }