2010-11-30 Mihai Parparita <mihaip@chromium.org>
authormihaip@chromium.org <mihaip@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Nov 2010 19:23:38 +0000 (19:23 +0000)
committermihaip@chromium.org <mihaip@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Nov 2010 19:23:38 +0000 (19:23 +0000)
        Reviewed by Tony Chang.

        Rebaseline server: baseline display tweaks
        https://bugs.webkit.org/show_bug.cgi?id=50207

        Determine which baselines were used when running the tests and higlight
        them in the UI. Sort platform names alphabetically.

        Also makes the server URL be launched in the user's browser
        automatically.

        * Scripts/webkitpy/tool/commands/data/rebaselineserver/main.css:
        * Scripts/webkitpy/tool/commands/data/rebaselineserver/main.js:
        * Scripts/webkitpy/tool/commands/data/rebaselineserver/util.js:
        * Scripts/webkitpy/tool/commands/rebaselineserver.py:
        * Scripts/webkitpy/tool/commands/rebaselineserver_unittest.py:

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

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/tool/commands/data/rebaselineserver/main.css
WebKitTools/Scripts/webkitpy/tool/commands/data/rebaselineserver/main.js
WebKitTools/Scripts/webkitpy/tool/commands/data/rebaselineserver/util.js
WebKitTools/Scripts/webkitpy/tool/commands/rebaselineserver.py
WebKitTools/Scripts/webkitpy/tool/commands/rebaselineserver_unittest.py

index 010ccf9..4f67b23 100644 (file)
@@ -1,3 +1,22 @@
+2010-11-30  Mihai Parparita  <mihaip@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Rebaseline server: baseline display tweaks
+        https://bugs.webkit.org/show_bug.cgi?id=50207
+        
+        Determine which baselines were used when running the tests and higlight
+        them in the UI. Sort platform names alphabetically.
+        
+        Also makes the server URL be launched in the user's browser
+        automatically.
+
+        * Scripts/webkitpy/tool/commands/data/rebaselineserver/main.css:
+        * Scripts/webkitpy/tool/commands/data/rebaselineserver/main.js:
+        * Scripts/webkitpy/tool/commands/data/rebaselineserver/util.js:
+        * Scripts/webkitpy/tool/commands/rebaselineserver.py:
+        * Scripts/webkitpy/tool/commands/rebaselineserver_unittest.py:
+
 2010-11-30  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Anders Carlsson.
index 62afda6..aff2bf6 100644 (file)
@@ -217,6 +217,23 @@ a, .link {
   color: gray;
 }
 
+#current-baselines {
+  font-weight: normal !important;
+}
+
+#current-baselines .platform {
+  font-weight: bold;
+}
+
+#current-baselines a {
+  color: #ddf;
+}
+
+#current-baselines .was-used-for-test {
+  color: #aaf;
+  font-weight: bold;
+}
+
 #action-buttons {
   float: right;
 }
index 25f9146..66990d0 100644 (file)
@@ -92,7 +92,7 @@ function main()
             var platformOption = document.createElement('option');
             platformOption.value = platform;
             platformOption.textContent = platform;
-  
+
             var targetOption = platformOption.cloneNode(true);
             targetOption.selected = platform == platforms.defaultPlatform;
             $('baseline-target').appendChild(targetOption);
@@ -141,7 +141,7 @@ function displayResults()
 
     selectFailureType();
 
-    document.body.classList.remove('loading');
+    document.body.className = '';
 }
 
 /**
@@ -253,13 +253,17 @@ function selectTest()
     currentBaselines.textContent = '';
     var baselines = results.tests[selectedTest].baselines;
     var testName = selectedTest.split('.').slice(0, -1).join('.');
-    for (var platform in baselines) {
-        if (currentBaselines.firstChild) {
+    getSortedKeys(baselines).forEach(function(platform, i) {
+        if (i != 0) {
             currentBaselines.appendChild(document.createTextNode('; '));
         }
-        currentBaselines.appendChild(document.createTextNode(platform + ' ('));
-        for (var i = 0, extension; extension = baselines[platform][i]; i++) {
-            if (i != 0) {
+        var platformName = document.createElement('span');
+        platformName.className = 'platform';
+        platformName.textContent = platform;
+        currentBaselines.appendChild(platformName);
+        currentBaselines.appendChild(document.createTextNode(' ('));
+        getSortedKeys(baselines[platform]).forEach(function(extension, j) {
+            if (j != 0) {
                 currentBaselines.appendChild(document.createTextNode(', '));
             }
             var link = document.createElement('a');
@@ -275,10 +279,13 @@ function selectTest()
                 link.textContent = extension.substring(1);
             }
             link.target = '_blank';
+            if (baselines[platform][extension]) {
+                link.className = 'was-used-for-test';
+            }
             currentBaselines.appendChild(link);
-        }
+        });
         currentBaselines.appendChild(document.createTextNode(')'));
-    }
+    });
 
     updateState();
     loupe.hide();
index b348462..5ad7612 100644 (file)
@@ -91,4 +91,14 @@ function toggle(id)
 function getTracUrl(layoutTestPath)
 {
   return 'http://trac.webkit.org/browser/trunk/LayoutTests/' + layoutTestPath;
+}
+
+function getSortedKeys(obj)
+{
+    var keys = [];
+    for (var key in obj) {
+        keys.push(key);
+    }
+    keys.sort();
+    return keys;
 }
\ No newline at end of file
index 2924a6f..2dcc566 100644 (file)
@@ -183,7 +183,7 @@ class RebaselineHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             shutil.copyfileobj(static_file, self.wfile)
 
 
-def _get_test_baselines(test_file, layout_tests_directory, platforms, filesystem):
+def _get_test_baselines(test_file, test_port, layout_tests_directory, platforms, filesystem):
     class AllPlatformsPort(WebKitPort):
         def __init__(self):
             WebKitPort.__init__(self, filesystem=filesystem)
@@ -196,11 +196,14 @@ def _get_test_baselines(test_file, layout_tests_directory, platforms, filesystem
         def platform_from_directory(self, directory):
             return self._platforms_by_directory[directory]
 
+    test_path = filesystem.join(layout_tests_directory, test_file)
+
     all_platforms_port = AllPlatformsPort()
 
-    test_baselines = {}
+    all_test_baselines = {}
     for baseline_extension in ('.txt', '.checksum', '.png'):
-        test_path = filesystem.join(layout_tests_directory, test_file)
+        test_baselines = test_port.expected_baselines(
+            test_path, baseline_extension)
         baselines = all_platforms_port.expected_baselines(
             test_path, baseline_extension, all_baselines=True)
         for platform_directory, expected_filename in baselines:
@@ -211,14 +214,12 @@ def _get_test_baselines(test_file, layout_tests_directory, platforms, filesystem
             else:
                 platform = all_platforms_port.platform_from_directory(
                     platform_directory)
-            if platform not in test_baselines:
-                test_baselines[platform] = []
-            test_baselines[platform].append(baseline_extension)
+            platform_baselines = all_test_baselines.setdefault(platform, {})
+            was_used_for_test = (
+                platform_directory, expected_filename) in test_baselines
+            platform_baselines[baseline_extension] = was_used_for_test
         
-    for platform, extensions in test_baselines.items():
-        test_baselines[platform] = tuple(extensions)
-
-    return test_baselines
+    return all_test_baselines
 
 class RebaselineServer(AbstractDeclarativeCommand):
     name = "rebaseline-server"
@@ -250,12 +251,17 @@ class RebaselineServer(AbstractDeclarativeCommand):
         print 'Gathering current baselines...'
         for test_file, test_json in results_json['tests'].items():
             test_json['state'] = STATE_NEEDS_REBASELINE
+            test_path = filesystem.join(layout_tests_directory, test_file)
             test_json['baselines'] = _get_test_baselines(
-                test_file, layout_tests_directory, platforms, filesystem)
+                test_file, port, layout_tests_directory, platforms, filesystem)
+
+        server_url = "http://localhost:%d/" % options.httpd_port
+        print "Starting server at %s" % server_url
+        print ("Use the 'Exit' link in the UI, %squitquitquit "
+            "or Ctrl-C to stop") % server_url
 
-        print "Starting server at http://localhost:%d/" % options.httpd_port
-        print ("Use the 'Exit' link in the UI, http://localhost:%d/"
-            "quitquitquit or Ctrl-C to stop") % options.httpd_port
+        threading.Timer(
+            .1, lambda: self._tool.user.open_url(server_url)).start()
 
         httpd = RebaselineHTTPServer(
             httpd_port=options.httpd_port,
index ea52902..b37da3d 100644 (file)
@@ -30,6 +30,7 @@ import unittest
 
 from webkitpy.common.system import filesystem_mock
 from webkitpy.layout_tests.port import base
+from webkitpy.layout_tests.port.webkit import WebKitPort
 from webkitpy.tool.commands import rebaselineserver
 
 
@@ -37,7 +38,7 @@ class GetBaselinesTest(unittest.TestCase):
     def test_no_baselines(self):
         self._assertBaselines(
             test_files=(),
-            test='fast/missing.html',
+            test_name='fast/missing.html',
             expected_baselines={})
 
     def test_text_baselines(self):
@@ -46,8 +47,11 @@ class GetBaselinesTest(unittest.TestCase):
                 'fast/text-expected.txt',
                 'platform/mac/fast/text-expected.txt',
             ),
-            test='fast/text.html',
-            expected_baselines={'mac': ('.txt',), 'base': ('.txt',)})
+            test_name='fast/text.html',
+            expected_baselines={
+                'mac': {'.txt': True},
+                'base': {'.txt': False},
+            })
 
     def test_image_and_text_baselines(self):
         self._assertBaselines(
@@ -58,11 +62,11 @@ class GetBaselinesTest(unittest.TestCase):
                 'platform/win/fast/image-expected.png',
                 'platform/win/fast/image-expected.checksum',
             ),
-            test='fast/image.html',
+            test_name='fast/image.html',
             expected_baselines={
-                'base': ('.txt',),
-                'mac': ('.checksum', '.png'),
-                'win': ('.checksum', '.png'),
+                'base': {'.txt': True},
+                'mac': {'.checksum': True, '.png': True},
+                'win': {'.checksum': False, '.png': False},
             })
 
     def test_extra_baselines(self):
@@ -71,18 +75,25 @@ class GetBaselinesTest(unittest.TestCase):
                 'fast/text-expected.txt',
                 'platform/nosuchplatform/fast/text-expected.txt',
             ),
-            test='fast/text.html',
-            expected_baselines={'base': ('.txt',)})
+            test_name='fast/text.html',
+            expected_baselines={'base': {'.txt': True}})
 
-    def _assertBaselines(self, test_files, test, expected_baselines):
+    def _assertBaselines(self, test_files, test_name, expected_baselines):
         layout_tests_directory = base.Port().layout_tests_dir()
         mock_filesystem = filesystem_mock.MockFileSystem()
-        for file in test_files + (test,):
+        for file in test_files + (test_name,):
             file_path = mock_filesystem.join(layout_tests_directory, file)
             mock_filesystem.files[file_path] = ''
+
+        class TestMacPort(WebKitPort):
+            def __init__(self):
+                WebKitPort.__init__(self, filesystem=mock_filesystem)
+                self._name = 'mac'
+
         actual_baselines = rebaselineserver._get_test_baselines(
-            test,
+            test_name,
+            TestMacPort(),
             layout_tests_directory,
             ('mac', 'win', 'linux'),
             mock_filesystem)
-        self.assertEqual(actual_baselines, expected_baselines)
+        self.assertEqual(expected_baselines, actual_baselines)