<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[178236] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/178236">178236</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2015-01-10 00:01:32 -0800 (Sat, 10 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update the output format for run-api-tests
https://bugs.webkit.org/show_bug.cgi?id=140332

Reviewed by Dan Bernstein.

Changes the output format for run-api-tests be a bit simpler (no longer 
indented based on suite, as we were not really using suite very well) but
also include details in the case of failure.

Changes verbose mode to no longer spew out the gtest default printer output,
as the custom printer now includes the failure information.

* Scripts/run-api-tests:
(runTestsBySuite):
(runTest):
Augment the custom gtest printer by replacing the tokens &quot;**PASS**&quot; and &quot;**FAIL**&quot;
with colorized variants and strip out leaks spew (the leaks can be added back using
the new --show-leaks argument).

* TestWebKitAPI/TestsController.cpp:
(TestWebKitAPI::Printer::OnTestPartResult):
(TestWebKitAPI::Printer::OnTestEnd):
(TestWebKitAPI::TestsController::run):
Implement a custom result printer that just prints out the information we want.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsrunapitests">trunk/Tools/Scripts/run-api-tests</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsControllercpp">trunk/Tools/TestWebKitAPI/TestsController.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (178235 => 178236)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-01-10 05:48:54 UTC (rev 178235)
+++ trunk/Tools/ChangeLog        2015-01-10 08:01:32 UTC (rev 178236)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2015-01-09  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Update the output format for run-api-tests
+        https://bugs.webkit.org/show_bug.cgi?id=140332
+
+        Reviewed by Dan Bernstein.
+
+        Changes the output format for run-api-tests be a bit simpler (no longer 
+        indented based on suite, as we were not really using suite very well) but
+        also include details in the case of failure.
+
+        Changes verbose mode to no longer spew out the gtest default printer output,
+        as the custom printer now includes the failure information.
+
+        * Scripts/run-api-tests:
+        (runTestsBySuite):
+        (runTest):
+        Augment the custom gtest printer by replacing the tokens &quot;**PASS**&quot; and &quot;**FAIL**&quot;
+        with colorized variants and strip out leaks spew (the leaks can be added back using
+        the new --show-leaks argument).
+
+        * TestWebKitAPI/TestsController.cpp:
+        (TestWebKitAPI::Printer::OnTestPartResult):
+        (TestWebKitAPI::Printer::OnTestEnd):
+        (TestWebKitAPI::TestsController::run):
+        Implement a custom result printer that just prints out the information we want.
+
+2015-01-09  Sam Weinig  &lt;sam@webkit.org&gt;
+
</ins><span class="cx">         TestWebKitAPI should print out the lists that fail at the end
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=140329
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptsrunapitests"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/run-api-tests (178235 => 178236)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/run-api-tests        2015-01-10 05:48:54 UTC (rev 178235)
+++ trunk/Tools/Scripts/run-api-tests        2015-01-10 08:01:32 UTC (rev 178236)
</span><span class="lines">@@ -37,8 +37,8 @@
</span><span class="cx"> sub buildTestTool();
</span><span class="cx"> sub dumpTestsBySuite(\@);
</span><span class="cx"> sub listAllTests();
</span><del>-sub runTest($$$);
-sub runTestsBySuite(\@$);
</del><ins>+sub runTest($$);
+sub runTestsBySuite(\@);
</ins><span class="cx"> sub prepareEnvironmentForRunningTestTool();
</span><span class="cx"> sub testToolPath();
</span><span class="cx"> 
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> 
</span><span class="cx"> my $showHelp = 0;
</span><span class="cx"> my $verbose = 0;
</span><ins>+my $showLeaks = 0;
</ins><span class="cx"> my $dumpTests = 0;
</span><span class="cx"> my $build = 1;
</span><span class="cx"> my $root;
</span><span class="lines">@@ -65,6 +66,7 @@
</span><span class="cx">   -d|--dump-tests       Dump the names of testcases without running them
</span><span class="cx">   --[no-]build          Build (or do not build) unit tests prior to running (default: $buildDefault)
</span><span class="cx">   --root=               Path to the pre-built root containing TestWebKitAPI
</span><ins>+  --show-leaks          Show leaks in the output
</ins><span class="cx"> @{[ sharedCommandLineOptionsUsage(indent =&gt; 2, switchWidth =&gt; 21) ]}
</span><span class="cx"> Examples
</span><span class="cx"> 
</span><span class="lines">@@ -80,6 +82,7 @@
</span><span class="cx">     sharedCommandLineOptions(),
</span><span class="cx">     'help' =&gt; \$showHelp,
</span><span class="cx">     'verbose|v' =&gt; \$verbose,
</span><ins>+    'show-leaks' =&gt; \$showLeaks,
</ins><span class="cx">     'dump|d' =&gt; \$dumpTests,
</span><span class="cx">     'build!' =&gt; \$build,
</span><span class="cx">     'root=s' =&gt; \$root
</span><span class="lines">@@ -105,7 +108,7 @@
</span><span class="cx">     exit 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-exit runTestsBySuite(@testsToRun, $verbose);
</del><ins>+exit runTestsBySuite(@testsToRun);
</ins><span class="cx"> 
</span><span class="cx"> sub isSupportedPlatform()
</span><span class="cx"> {
</span><span class="lines">@@ -129,21 +132,14 @@
</span><span class="cx">     print &quot;------------------\n&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub runTestsBySuite(\@$)
</del><ins>+sub runTestsBySuite(\@)
</ins><span class="cx"> {
</span><del>-    my ($tests, $verbose) = @_;
-    my $anyFailures = 0;
-    my $lastSuite = &quot;&quot;;
</del><ins>+    my ($tests) = @_;
</ins><span class="cx">     for my $suiteAndTest (sort @$tests) {
</span><span class="cx">         my ($suite, $test) = split(/\./, $suiteAndTest);
</span><del>-        if ($lastSuite ne $suite) {
-            $lastSuite = $suite;
-            print &quot;Suite: $suite\n&quot; unless $verbose;
-        }
-        my $failed = runTest($suite, $test, $verbose);
-        $anyFailures ||= $failed;
</del><ins>+        runTest($suite, $test);
</ins><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (@testsFailed) {
</span><span class="cx">         print &quot;\nTests that failed:\n&quot;;
</span><span class="cx">         for my $test (@testsFailed) {
</span><span class="lines">@@ -156,18 +152,17 @@
</span><span class="cx">             print &quot;  $test\n&quot;;
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    return $anyFailures;
</del><ins>+
+    return @testsFailed &gt; 0 || @testsTimedOut &gt; 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub runTest($$$)
</del><ins>+sub runTest($$)
</ins><span class="cx"> {
</span><del>-    my ($suite, $testName, $verbose) = @_;
</del><ins>+    my ($suite, $testName) = @_;
</ins><span class="cx">     my $test = $suite . &quot;.&quot; . $testName;
</span><span class="cx"> 
</span><span class="cx">     my $gtestArg = &quot;--gtest_filter=&quot; . $test;
</span><span class="cx"> 
</span><del>-    print &quot;    Test: $testName -&gt; &quot; unless $verbose;
-
</del><span class="cx">     my $result = 0;
</span><span class="cx">     my $timedOut = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -178,15 +173,14 @@
</span><span class="cx"> 
</span><span class="cx">     local *DEVNULL;
</span><span class="cx">     my ($childIn, $childOut, $childErr);
</span><del>-    if ($verbose) {
-        $childOut = &quot;&gt;&amp;STDERR&quot;;
-        $childErr = &quot;&gt;&amp;STDERR&quot;;
</del><ins>+    if ($verbose || $showLeaks) {
+        $childErr = 0;
</ins><span class="cx">     } else {
</span><span class="cx">         open(DEVNULL, &quot;&gt;&quot;, File::Spec-&gt;devnull()) or die &quot;Failed to open /dev/null&quot;;
</span><del>-        $childOut = &quot;&gt;&amp;DEVNULL&quot;;
</del><span class="cx">         $childErr = &quot;&gt;&amp;DEVNULL&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">     my $pid;
</span><span class="cx">     my @commonArguments = (testToolPath(), $gtestArg, @ARGV);
</span><span class="cx">     if (isIOSWebKit()) {
</span><span class="lines">@@ -197,10 +191,6 @@
</span><span class="cx">         $pid = open3($childIn, $childOut, $childErr, @commonArguments) or die &quot;Failed to run test: $test.&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    close($childIn);
-    close($childOut);
-    close($childErr);
-    close(DEVNULL) unless ($verbose);
</del><span class="cx">     eval {
</span><span class="cx">         local $SIG{ALRM} = sub { die &quot;alarm\n&quot; };
</span><span class="cx">         alarm $timeout;
</span><span class="lines">@@ -214,18 +204,23 @@
</span><span class="cx">         $timedOut = 1;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    my @testOutput = &lt;$childOut&gt;;
+    @testOutput = grep { !/^LEAK:/ } @testOutput unless $showLeaks;
+    map { s/\*\*PASS\*\*/possiblyColored(&quot;bold green&quot;, &quot;PASS&quot;)/eg } @testOutput;
+    map { s/\*\*FAIL\*\*/possiblyColored(&quot;bold red&quot;, &quot;FAIL&quot;)/eg } @testOutput;
+    print STDOUT @testOutput;
+
+    close($childIn);
+    close($childOut);
+    close($childErr) unless ($verbose || $showLeaks);
+    close(DEVNULL) unless ($verbose || $showLeaks);
+
</ins><span class="cx">     if ($result) {
</span><span class="cx">         push @testsFailed, $test;
</span><span class="cx">     }
</span><span class="cx">     if ($timedOut) {
</span><span class="cx">         push @testsTimedOut, $test;
</span><del>-        print possiblyColored(&quot;bold yellow&quot;, &quot;Timeout&quot;), &quot;\n&quot;;
-    } elsif (!$verbose) {
-        if ($result) {
-            print possiblyColored(&quot;bold red&quot;, &quot;Failed&quot;), &quot;\n&quot;;
-        } else {
-            print possiblyColored(&quot;bold green&quot;, &quot;Passed&quot;), &quot;\n&quot;;
-        }
</del><ins>+        print possiblyColored(&quot;bold yellow&quot;, &quot;TIMEOUT&quot;), &quot; $test\n&quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return $timedOut || $result;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestsController.cpp (178235 => 178236)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestsController.cpp        2015-01-10 05:48:54 UTC (rev 178235)
+++ trunk/Tools/TestWebKitAPI/TestsController.cpp        2015-01-10 08:01:32 UTC (rev 178236)
</span><span class="lines">@@ -30,6 +30,30 @@
</span><span class="cx"> 
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><ins>+class Printer : public ::testing::EmptyTestEventListener {
+    virtual void OnTestPartResult(const ::testing::TestPartResult&amp; test_part_result)
+    {
+        if (!test_part_result.failed())
+            return;
+
+        std::stringstream stream;
+        stream &lt;&lt; &quot;\n&quot; &lt;&lt; test_part_result.file_name() &lt;&lt; &quot;:&quot; &lt;&lt; test_part_result.line_number() &lt;&lt; &quot;\n&quot; &lt;&lt; test_part_result.summary() &lt;&lt; &quot;\n\n&quot;;
+        failures += stream.str();
+    }
+
+    virtual void OnTestEnd(const ::testing::TestInfo&amp; test_info)
+    {
+        if (test_info.result()-&gt;Passed())
+            std::cout &lt;&lt; &quot;**PASS** &quot; &lt;&lt; test_info.test_case_name() &lt;&lt; &quot;.&quot; &lt;&lt; test_info.name() &lt;&lt; &quot;\n&quot;;
+        else
+            std::cout &lt;&lt; &quot;**FAIL** &quot; &lt;&lt; test_info.test_case_name() &lt;&lt; &quot;.&quot; &lt;&lt; test_info.name() &lt;&lt; &quot;\n&quot; &lt;&lt; failures;
+
+        failures = std::string();
+    }
+    
+    std::string failures;
+};
+
</ins><span class="cx"> TestsController&amp; TestsController::shared()
</span><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;TestsController&gt; shared;
</span><span class="lines">@@ -48,6 +72,11 @@
</span><span class="cx"> bool TestsController::run(int argc, char** argv)
</span><span class="cx"> {
</span><span class="cx">     ::testing::InitGoogleTest(&amp;argc, argv);
</span><ins>+
+    ::testing::TestEventListeners&amp; listeners = ::testing::UnitTest::GetInstance()-&gt;listeners();
+    delete listeners.Release(listeners.default_result_printer());
+    listeners.Append(new Printer);
+
</ins><span class="cx">     return !RUN_ALL_TESTS();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>