<!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>[243882] branches/safari-607-branch/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/243882">243882</a></dd>
<dt>Author</dt> <dd>kocsen_chung@apple.com</dd>
<dt>Date</dt> <dd>2019-04-04 10:50:25 -0700 (Thu, 04 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/243842">r243842</a>. rdar://problem/34841155

    run-webkit-tests: Upload test results (new results database)
    https://bugs.webkit.org/show_bug.cgi?id=196577
    <rdar://problem/34841155>

    Reviewed by Lucas Forschler.

    * Scripts/webkitpy/layout_tests/controllers/manager.py:
    (Manager.run): Upload results after each device shard, since the configuration will be
    different for each device.
    (Manager._results_to_upload_json_trie): Convert a TestRunResults object to a trie to be
    uploaded to a results database.
    * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
    (parse_args): Add new 'Upload Options' and prepare 'Results JSON Options' for deprecation.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243842 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari607branchToolsChangeLog">branches/safari-607-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari607branchToolsScriptswebkitpylayout_testscontrollersmanagerpy">branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py</a></li>
<li><a href="#branchessafari607branchToolsScriptswebkitpylayout_testsrun_webkit_testspy">branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari607branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/ChangeLog (243881 => 243882)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/ChangeLog       2019-04-04 17:49:51 UTC (rev 243881)
+++ branches/safari-607-branch/Tools/ChangeLog  2019-04-04 17:50:25 UTC (rev 243882)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2019-04-04  Kocsen Chung  <kocsen_chung@apple.com>
+
+        Cherry-pick r243842. rdar://problem/34841155
+
+    run-webkit-tests: Upload test results (new results database)
+    https://bugs.webkit.org/show_bug.cgi?id=196577
+    <rdar://problem/34841155>
+    
+    Reviewed by Lucas Forschler.
+    
+    * Scripts/webkitpy/layout_tests/controllers/manager.py:
+    (Manager.run): Upload results after each device shard, since the configuration will be
+    different for each device.
+    (Manager._results_to_upload_json_trie): Convert a TestRunResults object to a trie to be
+    uploaded to a results database.
+    * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+    (parse_args): Add new 'Upload Options' and prepare 'Results JSON Options' for deprecation.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243842 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-04-03  Jonathan Bedard  <jbedard@apple.com>
+
+            run-webkit-tests: Upload test results (new results database)
+            https://bugs.webkit.org/show_bug.cgi?id=196577
+            <rdar://problem/34841155>
+
+            Reviewed by Lucas Forschler.
+
+            * Scripts/webkitpy/layout_tests/controllers/manager.py:
+            (Manager.run): Upload results after each device shard, since the configuration will be
+            different for each device.
+            (Manager._results_to_upload_json_trie): Convert a TestRunResults object to a trie to be
+            uploaded to a results database.
+            * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+            (parse_args): Add new 'Upload Options' and prepare 'Results JSON Options' for deprecation.
+
</ins><span class="cx"> 2019-04-02  Kocsen Chung  <kocsen_chung@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r240339. rdar://problem/49539128
</span></span></pre></div>
<a id="branchessafari607branchToolsScriptswebkitpylayout_testscontrollersmanagerpy"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (243881 => 243882)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py    2019-04-04 17:49:51 UTC (rev 243881)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py       2019-04-04 17:50:25 UTC (rev 243882)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> from webkitpy.layout_tests.models.test_input import TestInput
</span><span class="cx"> from webkitpy.layout_tests.models.test_run_results import INTERRUPTED_EXIT_STATUS
</span><span class="cx"> from webkitpy.tool.grammar import pluralize
</span><ins>+from webkitpy.results.upload import Upload
</ins><span class="cx"> from webkitpy.xcode.device_type import DeviceType
</span><span class="cx"> 
</span><span class="cx"> _log = logging.getLogger(__name__)
</span><span class="lines">@@ -174,6 +175,7 @@
</span><span class="cx">         return True
</span><span class="cx"> 
</span><span class="cx">     def run(self, args):
</span><ins>+        num_failed_uploads = 0
</ins><span class="cx">         total_tests = set()
</span><span class="cx">         aggregate_test_names = set()
</span><span class="cx">         aggregate_tests = set()
</span><span class="lines">@@ -252,12 +254,38 @@
</span><span class="cx"> 
</span><span class="cx">             _log.info('Running {}{}'.format(pluralize(len(tests_to_run_by_device[device_type]), 'test'), ' for {}'.format(str(device_type)) if device_type else ''))
</span><span class="cx">             _log.info('')
</span><ins>+            start_time_for_device = time.time()
</ins><span class="cx">             if not tests_to_run_by_device[device_type]:
</span><span class="cx">                 continue
</span><span class="cx">             if not self._set_up_run(tests_to_run_by_device[device_type], device_type=device_type):
</span><span class="cx">                 return test_run_results.RunDetails(exit_code=-1)
</span><span class="cx"> 
</span><ins>+            configuration = self._port.configuration_for_upload(self._port.target_host(0))
+            configuration['flavor'] = 'wk2' if self._options.webkit_test_runner else 'wk1'
</ins><span class="cx">             temp_initial_results, temp_retry_results, temp_enabled_pixel_tests_in_retry = self._run_test_subset(tests_to_run_by_device[device_type], tests_to_skip, device_type=device_type)
</span><ins>+
+            if self._options.report_urls:
+                self._printer.writeln('\n')
+                self._printer.write_update('Preparing upload data ...')
+
+                upload = Upload(
+                    suite='layout-tests',
+                    configuration=configuration,
+                    details=Upload.create_details(options=self._options),
+                    commits=self._port.commits_for_upload(),
+                    run_stats=Upload.create_run_stats(
+                        start_time=start_time_for_device,
+                        end_time=time.time(),
+                        tests_skipped=temp_initial_results.remaining + temp_initial_results.expected_skips,
+                    ),
+                    results=self._results_to_upload_json_trie(self._expectations[device_type], temp_initial_results),
+                )
+                for url in self._options.report_urls:
+                    self._printer.write_update('Uploading to {} ...'.format(url))
+                    if not upload.upload(url, log_line_func=self._printer.writeln):
+                        num_failed_uploads += 1
+                self._printer.writeln('Uploads completed!')
+
</ins><span class="cx">             initial_results = initial_results.merge(temp_initial_results) if initial_results else temp_initial_results
</span><span class="cx">             retry_results = retry_results.merge(temp_retry_results) if retry_results else temp_retry_results
</span><span class="cx">             enabled_pixel_tests_in_retry |= temp_enabled_pixel_tests_in_retry
</span><span class="lines">@@ -268,7 +296,10 @@
</span><span class="cx">         self._runner.stop_servers()
</span><span class="cx"> 
</span><span class="cx">         end_time = time.time()
</span><del>-        return self._end_test_run(start_time, end_time, initial_results, retry_results, enabled_pixel_tests_in_retry)
</del><ins>+        result = self._end_test_run(start_time, end_time, initial_results, retry_results, enabled_pixel_tests_in_retry)
+        if num_failed_uploads:
+            result.exit_code = -1
+        return result
</ins><span class="cx"> 
</span><span class="cx">     def _run_test_subset(self, tests_to_run, tests_to_skip, device_type=None):
</span><span class="cx">         try:
</span><span class="lines">@@ -409,6 +440,47 @@
</span><span class="cx">                     (result.type != test_expectations.MISSING) and
</span><span class="cx">                     (result.type != test_expectations.CRASH or include_crashes))]
</span><span class="cx"> 
</span><ins>+    def _output_perf_metrics(self, run_time, initial_results):
+        perf_metrics_json = json_results_generator.perf_metrics_for_test(run_time, initial_results.results_by_name.values())
+        perf_metrics_path = self._filesystem.join(self._results_directory, "layout_test_perf_metrics.json")
+        self._filesystem.write_text_file(perf_metrics_path, json.dumps(perf_metrics_json))
+
+    def _results_to_upload_json_trie(self, expectations, results):
+        FAILURE_TO_TEXT = {
+            test_expectations.PASS: Upload.Expectations.PASS,
+            test_expectations.CRASH: Upload.Expectations.CRASH,
+            test_expectations.TIMEOUT: Upload.Expectations.TIMEOUT,
+            test_expectations.IMAGE: Upload.Expectations.IMAGE,
+            test_expectations.TEXT: Upload.Expectations.TEXT,
+            test_expectations.AUDIO: Upload.Expectations.AUDIO,
+            test_expectations.MISSING: Upload.Expectations.WARNING,
+            test_expectations.IMAGE_PLUS_TEXT: ' '.join([Upload.Expectations.IMAGE, Upload.Expectations.TEXT]),
+        }
+
+        results_trie = {}
+        for result in results.results_by_name.itervalues():
+            if result.type == test_expectations.SKIP:
+                continue
+
+            expected = expectations.filtered_expectations_for_test(
+                result.test_name,
+                self._options.pixel_tests or bool(result.reftest_type),
+                self._options.world_leaks,
+            )
+            if expected == {test_expectations.PASS}:
+                expected = None
+            else:
+                expected = ' '.join([FAILURE_TO_TEXT.get(e, Upload.Expectations.FAIL) for e in expected])
+
+            json_results_generator.add_path_to_trie(
+                result.test_name,
+                Upload.create_test_result(
+                    expected=expected,
+                    actual=FAILURE_TO_TEXT.get(result.type, Upload.Expectations.FAIL) if result.type else None,
+                    time=int(result.test_run_time * 1000),
+                ), results_trie)
+        return results_trie
+
</ins><span class="cx">     def _upload_json_files(self, summarized_results, initial_results, results_including_passes=None, start_time=None, end_time=None):
</span><span class="cx">         """Writes the results of the test run as JSON files into the results
</span><span class="cx">         dir and upload the files to the appengine server.
</span></span></pre></div>
<a id="branchessafari607branchToolsScriptswebkitpylayout_testsrun_webkit_testspy"></a>
<div class="modfile"><h4>Modified: branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (243881 => 243882)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py       2019-04-04 17:49:51 UTC (rev 243881)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py  2019-04-04 17:50:25 UTC (rev 243882)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> from webkitpy.port import configuration_options, platform_options
</span><span class="cx"> from webkitpy.layout_tests.views import buildbot_results
</span><span class="cx"> from webkitpy.layout_tests.views import printing
</span><ins>+from webkitpy.results.options import upload_options
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> _log = logging.getLogger(__name__)
</span><span class="lines">@@ -317,17 +318,13 @@
</span><span class="cx">         optparse.make_option("--wptserver-doc-root", type="string", help=("Set web platform server document root, relative to LayoutTests directory")),
</span><span class="cx">     ]))
</span><span class="cx"> 
</span><del>-    # FIXME: Move these into json_results_generator.py
-    option_group_definitions.append(("Result JSON Options", [
</del><ins>+    # FIXME: Remove this group once the old results dashboards are deprecated.
+    option_group_definitions.append(("Legacy Result Options", [
</ins><span class="cx">         optparse.make_option("--master-name", help="The name of the buildbot master."),
</span><del>-        optparse.make_option("--builder-name", default="",
-            help=("The name of the builder shown on the waterfall running this script. e.g. Apple MountainLion Release WK2 (Tests).")),
</del><span class="cx">         optparse.make_option("--build-name", default="DUMMY_BUILD_NAME",
</span><span class="cx">             help=("The name of the builder used in its path, e.g. webkit-rel.")),
</span><span class="cx">         optparse.make_option("--build-slave", default="DUMMY_BUILD_SLAVE",
</span><span class="cx">             help=("The name of the buildslave used. e.g. apple-macpro-6.")),
</span><del>-        optparse.make_option("--build-number", default="DUMMY_BUILD_NUMBER",
-            help=("The build number of the builder running this script.")),
</del><span class="cx">         optparse.make_option("--test-results-server", action="append", default=[],
</span><span class="cx">             help=("If specified, upload results json files to this appengine server.")),
</span><span class="cx">         optparse.make_option("--results-server-host", action="append", default=[],
</span><span class="lines">@@ -340,6 +337,8 @@
</span><span class="cx">             help=("If specified, tests are allowed to make requests to the specified hostname."))
</span><span class="cx">     ]))
</span><span class="cx"> 
</span><ins>+    option_group_definitions.append(('Upload Options', upload_options()))
+
</ins><span class="cx">     option_parser = optparse.OptionParser(usage="%prog [options] [<path>...]")
</span><span class="cx"> 
</span><span class="cx">     for group_name, group_options in option_group_definitions:
</span></span></pre>
</div>
</div>

</body>
</html>