Change the output of arc unit

arc unit will now show the number of consecutive tests with the same
  result instead of printing a "." for each one. Due to the number of
  tests the "dots" didn't fit in one line any more. Furthermore the
  result list is shortened, only non passing tests or tests taking
  longer than a time threshold (50ms) will be reported (both to the user
  and to phabricator).

llvm-svn: 218826
This commit is contained in:
Johannes Doerfert 2014-10-01 21:26:24 +00:00
parent 2960178a77
commit c3285a1ded

View File

@ -27,8 +27,11 @@ final class LitTestEngine extends ArcanistUnitTestEngine {
ArcanistUnitTestResult::RESULT_POSTPONED => 'yellow' ArcanistUnitTestResult::RESULT_POSTPONED => 'yellow'
); );
$s = "["; $s = "\t[\033[0;30m";
$number = -1;
$lastColor = ""; $lastColor = "";
$lastResult = "";
$lastNumber = "";
foreach ($results as $result) { foreach ($results as $result) {
$color = $colors[$result->getResult()]; $color = $colors[$result->getResult()];
if (!$color && $lastColor) if (!$color && $lastColor)
@ -37,14 +40,29 @@ final class LitTestEngine extends ArcanistUnitTestEngine {
$s .= "<bg:$color>"; $s .= "<bg:$color>";
elseif ($lastColor !== $color) elseif ($lastColor !== $color)
$s .= "</bg><bg:$color>"; $s .= "</bg><bg:$color>";
if ($number <= 0)
$number = 1;
elseif ($lastResult == $result->getResult())
$number += 1;
else
$number = 1;
if ($number > 1 && $number <= 10)
$s = substr($s, 0, -1);
elseif ($number > 10 && $number <= 100)
$s = substr($s, 0, -2);
elseif ($number > 100 && $number <= 1000)
$s = substr($s, 0, -3);
$s .= "$number";
$lastNumber = $number;
$lastResult = $result->getResult();
$lastColor = $color; $lastColor = $color;
$s .= ".";
} }
if ($lastColor) if ($lastColor)
$s .= "</bg>"; $s .= "</bg>";
$s .= "\033[0m";
$c = count($results); $c = count($results);
if ($numTests) if ($numTests)
$s .= str_repeat(" ", $numTests - $c) . " $c/$numTests]"; $s .= " $c/$numTests]";
else else
$s .= " $c]"; $s .= " $c]";
return phutil_console_format($s); return phutil_console_format($s);
@ -99,9 +117,9 @@ final class LitTestEngine extends ArcanistUnitTestEngine {
$numTests = (int)$matches[1]; $numTests = (int)$matches[1];
} }
if ($res == ArcanistUnitTestResult::RESULT_FAIL) if ($res == ArcanistUnitTestResult::RESULT_FAIL)
print "\033[1A"; print "\033[0A";
if ($res != ArcanistUnitTestResult::RESULT_SKIP && $res != ArcanistUnitTestResult::RESULT_PASS) if ($res != ArcanistUnitTestResult::RESULT_SKIP && $res != ArcanistUnitTestResult::RESULT_PASS)
print "\r\033[K\033[1A".$line.self::progress($results, $numTests); print "\r\033[K\033[0A".$line.self::progress($results, $numTests);
if ($res == ArcanistUnitTestResult::RESULT_UNSOUND) if ($res == ArcanistUnitTestResult::RESULT_UNSOUND)
continue; continue;
$result = new ArcanistUnitTestResult(); $result = new ArcanistUnitTestResult();
@ -112,7 +130,7 @@ final class LitTestEngine extends ArcanistUnitTestEngine {
$lastTime = $newTime; $lastTime = $newTime;
$results[] = $result; $results[] = $result;
$dots .= "."; $dots .= ".";
print "\r\033[K\033[1A".self::progress($results, $numTests); print "\r\033[K\033[0A".self::progress($results, $numTests);
} }
} }
list ($out1,$out2) = $litFuture->read(); list ($out1,$out2) = $litFuture->read();
@ -122,7 +140,15 @@ final class LitTestEngine extends ArcanistUnitTestEngine {
} }
print "\n"; print "\n";
return $results; $timeThreshold = 0.050;
$interestingTests = array();
foreach ($results as $result) {
if ($result->getResult() != "pass")
$interestingTests[] = $result;
if ($result->getDuration() > $timeThreshold)
$interestingTests[] = $result;
}
return $interestingTests;
} }
/** /**