]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Show a better expected vs actual for tests with large output
authorepriestley <git@epriestley.com>
Mon, 26 Mar 2012 16:43:47 +0000 (09:43 -0700)
committerepriestley <git@epriestley.com>
Mon, 26 Mar 2012 16:43:47 +0000 (09:43 -0700)
Summary: When tests have a lot of output, show a diff of the expected/actual.

Test Plan: Used this when developing D2016 to examine large output usefully.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2017

src/unit/engine/phutil/testcase/ArcanistPhutilTestCase.php
src/unit/engine/phutil/testcase/__init__.php

index 2895d5c654baf488cbccbf2d22d05decea86d12c..a6b1dc019ef989c1af7b474f6cc94a1fdc565c2c 100644 (file)
@@ -79,17 +79,17 @@ abstract class ArcanistPhutilTestCase {
 
     $output .= "\n";
 
-    if (strpos($expect, "\n") !== false) {
-      $expect = "\n{$expect}";
+    if (strpos($expect, "\n") === false && strpos($result, "\n") === false) {
+      $output .= "Expected: {$expect}\n";
+      $output .= "Actual: {$result}";
+    } else {
+      $output .= "Expected vs Actual Output Diff\n";
+      $output .= ArcanistDiffUtils::renderDifferences(
+        $expect,
+        $result,
+        $lines = 0xFFFF);
     }
 
-    if (strpos($result, "\n") !== false) {
-      $result = "\n{$result}";
-    }
-
-    $output .= "Expected: {$expect}\n";
-    $output .= "Actual: {$result}";
-
     $this->failTest($output);
     throw new ArcanistPhutilTestTerminatedException($output);
   }
index 6a8819e90b466a59fd8bc58e98e0295b2a76b09e..8a68cf9bae3c8379e89b118c5b281f3aa913b30a 100644 (file)
@@ -6,6 +6,7 @@
 
 
 
+phutil_require_module('arcanist', 'difference');
 phutil_require_module('arcanist', 'unit/engine/phutil/testcase/exception');
 phutil_require_module('arcanist', 'unit/result');