2010-11-30 Mihai Parparita <mihaip@chromium.org>
[WebKit-https.git] / WebKitTools / Scripts / webkitpy / tool / commands / rebaselineserver.py
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,