Only store the SVN revision in the summarized results if we're on a builder
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 21:26:06 +0000 (21:26 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 21:26:06 +0000 (21:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76976

Reviewed by Dirk Pranke.

This shaves another ~130ms off the single test run-webkit-tests runtime.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(summarize_results):
* Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
(ResultSummaryTest.get_result):
(ResultSummaryTest):
(ResultSummaryTest.get_result_summary):
(ResultSummaryTest.get_unexpected_results):
(ResultSummaryTest.test_no_svn_revision):
(ResultSummaryTest.test_svn_revision):
* Scripts/webkitpy/layout_tests/port/base.py:
(Port.use_trac_links_in_results_html):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106035 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py

index 28d67a9..107b733 100644 (file)
@@ -1,3 +1,24 @@
+2012-01-25  Ojan Vafai  <ojan@chromium.org>
+
+        Only store the SVN revision in the summarized results if we're on a builder
+        https://bugs.webkit.org/show_bug.cgi?id=76976
+
+        Reviewed by Dirk Pranke.
+
+        This shaves another ~130ms off the single test run-webkit-tests runtime.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (summarize_results):
+        * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
+        (ResultSummaryTest.get_result):
+        (ResultSummaryTest):
+        (ResultSummaryTest.get_result_summary):
+        (ResultSummaryTest.get_unexpected_results):
+        (ResultSummaryTest.test_no_svn_revision):
+        (ResultSummaryTest.test_svn_revision):
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        (Port.use_trac_links_in_results_html):
+
 2012-01-26  Luciano Wolf  <luciano.wolf@openbossa.org>
 
         [Qt][WK2] fast/loader tests failed after r94178
index 8090e2b..b1df780 100644 (file)
@@ -102,6 +102,11 @@ def interpret_test_failures(port, test_name, failures):
     return test_dict
 
 
+def use_trac_links_in_results_html(port_obj):
+    # We only use trac links on the buildbots.
+    # Use existence of builder_name as a proxy for knowing we're on a bot.
+    return port_obj.get_option("builder_name")
+
 # FIXME: This should be on the Manager class (since that's the only caller)
 # or split off from Manager onto another helper class, but should not be a free function.
 # Most likely this should be made into its own class, and this super-long function
@@ -228,7 +233,10 @@ def summarize_results(port_obj, expectations, result_summary, retry_summary, tes
     results['has_wdiff'] = port_obj.wdiff_available()
     results['has_pretty_patch'] = port_obj.pretty_patch_available()
     try:
-        results['revision'] = port_obj.host.scm().head_svn_revision()
+        # We only use the svn revision for using trac links in the results.html file,
+        # Don't do this by default since it takes >100ms.
+        if use_trac_links_in_results_html(port_obj):
+            results['revision'] = port_obj.host.scm().head_svn_revision()
     except Exception, e:
         _log.warn("Failed to determine svn revision for checkout (cwd: %s, webkit_base: %s), leaving 'revision' key blank in full_results.json.\n%s" % (port_obj._filesystem.getcwd(), port_obj.path_from_webkit_base(), e))
         # Handle cases where we're running outside of version control.
index e292d29..5e965ca 100644 (file)
@@ -42,8 +42,12 @@ from webkitpy.layout_tests.port import port_testcase
 
 from webkitpy import layout_tests
 from webkitpy.layout_tests import run_webkit_tests
+from webkitpy.layout_tests.controllers import manager
 from webkitpy.layout_tests.controllers.manager import interpret_test_failures,  Manager, natural_sort_key, test_key, TestRunInterruptedException, TestShard
+from webkitpy.layout_tests.models import result_summary
+from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.models import test_failures
+from webkitpy.layout_tests.models import test_results
 from webkitpy.layout_tests.models.result_summary import ResultSummary
 from webkitpy.layout_tests.models.test_expectations import TestExpectations
 from webkitpy.layout_tests.models.test_results import TestResult
@@ -370,6 +374,56 @@ class ResultSummaryTest(unittest.TestCase):
         self.assertTrue(test_dict['is_mismatch_reftest'])
         self.assertEqual(test_dict['ref_file'], 'foo/common.html')
 
+    def get_result(self, test_name, result_type=test_expectations.PASS, run_time=0):
+        failures = []
+        if result_type == test_expectations.TIMEOUT:
+            failures = [test_failures.FailureTimeout()]
+        elif result_type == test_expectations.CRASH:
+            failures = [test_failures.FailureCrash()]
+        return test_results.TestResult(test_name, failures=failures, test_run_time=run_time)
+
+    def get_result_summary(self, port, test_names, expectations_str):
+        expectations = test_expectations.TestExpectations(port, test_names, expectations_str, port.test_configuration(), is_lint_mode=False)
+        return test_names, result_summary.ResultSummary(expectations, test_names), expectations
+
+    # FIXME: Use this to test more of summarize_results. This was moved from printing_unittest.py.
+    def get_unexpected_results(self, port, expected, passing, flaky):
+        tests = ['passes/text.html', 'failures/expected/timeout.html', 'failures/expected/crash.html']
+        expectations = ''
+        paths, rs, exp = self.get_result_summary(port, tests, expectations)
+        if expected:
+            rs.add(self.get_result('passes/text.html', test_expectations.PASS), expected)
+            rs.add(self.get_result('failures/expected/timeout.html', test_expectations.TIMEOUT), expected)
+            rs.add(self.get_result('failures/expected/crash.html', test_expectations.CRASH), expected)
+        elif passing:
+            rs.add(self.get_result('passes/text.html'), expected)
+            rs.add(self.get_result('failures/expected/timeout.html'), expected)
+            rs.add(self.get_result('failures/expected/crash.html'), expected)
+        else:
+            rs.add(self.get_result('passes/text.html', test_expectations.TIMEOUT), expected)
+            rs.add(self.get_result('failures/expected/timeout.html', test_expectations.CRASH), expected)
+            rs.add(self.get_result('failures/expected/crash.html', test_expectations.TIMEOUT), expected)
+        retry = rs
+        if flaky:
+            paths, retry, exp = self.get_result_summary(port, tests, expectations)
+            retry.add(self.get_result('passes/text.html'), True)
+            retry.add(self.get_result('failures/expected/timeout.html'), True)
+            retry.add(self.get_result('failures/expected/crash.html'), True)
+        unexpected_results = manager.summarize_results(port, exp, rs, retry, test_timings={}, only_unexpected=True, interrupted=False)
+        return unexpected_results
+
+    def test_no_svn_revision(self):
+        host = MockHost()
+        port = host.port_factory.get('test')
+        results = self.get_unexpected_results(port, expected=False, passing=False, flaky=False)
+        self.assertTrue('revision' not in results)
+
+    def test_svn_revision(self):
+        host = MockHost()
+        port = host.port_factory.get('test')
+        port._options.builder_name = 'dummy builder'
+        results = self.get_unexpected_results(port, expected=False, passing=False, flaky=False)
+        self.assertTrue('revision' in results)
 
 if __name__ == '__main__':
     port_testcase.main()