run-benchmark should support Chrome Canary and Firefox Nightly
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2015 18:02:57 +0000 (18:02 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2015 18:02:57 +0000 (18:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144850

Reviewed by Darin Adler.

Added the support for Chrome Canary, Firefox (release), and Firefox Nightly.

This patch also extracts OSXBrowserDriver to launch and terminate processes on OS X.

* Scripts/webkitpy/benchmark_runner/browser_driver/browser_drivers.json:
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py: Added.
(OSXBrowserDriver):
(OSXBrowserDriver.prepareEnv): Extracted from ChromeBrowserDriver.prepareEnv.
(OSXBrowserDriver.closeBrowsers): Ditto.
(OSXBrowserDriver.launchProcess): Ditto.
(OSXBrowserDriver.terminateProcesses): Ditto.
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
(OSXChromeDriver): Removed the unused self.chromePreferences.
(OSXChromeDriver.prepareEnv): Moved to OSXBrowserDriver.
(OSXChromeDriver.closeBrowsers): Ditto.
(OSXChromeDriver.launchUrl):
(OSXChromeCanaryDriver): Added.
(OSXChromeCanaryDriver.launchUrl):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py: Added.
(OSXFirefoxDriver): Added.
(OSXFirefoxDriver.launchUrl):
(OSXFirefoxNightlyDriver): Added.
(OSXFirefoxNightlyDriver.launchUrl):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:
(OSXSafariDriver):
(OSXSafariDriver.closeBrowsers):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/browser_drivers.json
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py [new file with mode: 0644]
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py [new file with mode: 0644]
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py

index d8feee6453876089b8793cb76f1a028e814506c5..364d3b89313dee92d9befd4913a1a2bda3a59936 100644 (file)
@@ -1,3 +1,37 @@
+2015-05-11  Ryosuke Niwa  <rniwa@webkit.org>
+
+        run-benchmark should support Chrome Canary and Firefox Nightly
+        https://bugs.webkit.org/show_bug.cgi?id=144850
+
+        Reviewed by Darin Adler.
+
+        Added the support for Chrome Canary, Firefox (release), and Firefox Nightly.
+
+        This patch also extracts OSXBrowserDriver to launch and terminate processes on OS X.
+
+        * Scripts/webkitpy/benchmark_runner/browser_driver/browser_drivers.json:
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py: Added.
+        (OSXBrowserDriver):
+        (OSXBrowserDriver.prepareEnv): Extracted from ChromeBrowserDriver.prepareEnv.
+        (OSXBrowserDriver.closeBrowsers): Ditto.
+        (OSXBrowserDriver.launchProcess): Ditto.
+        (OSXBrowserDriver.terminateProcesses): Ditto.
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
+        (OSXChromeDriver): Removed the unused self.chromePreferences.
+        (OSXChromeDriver.prepareEnv): Moved to OSXBrowserDriver.
+        (OSXChromeDriver.closeBrowsers): Ditto.
+        (OSXChromeDriver.launchUrl):
+        (OSXChromeCanaryDriver): Added.
+        (OSXChromeCanaryDriver.launchUrl):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py: Added.
+        (OSXFirefoxDriver): Added.
+        (OSXFirefoxDriver.launchUrl):
+        (OSXFirefoxNightlyDriver): Added.
+        (OSXFirefoxNightlyDriver.launchUrl):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:
+        (OSXSafariDriver):
+        (OSXSafariDriver.closeBrowsers):
+
 2015-05-11  Tim Horton  <timothy_horton@apple.com>
 
         Page overlay action context override should indicate the source of the request
index c80b961577969eb973ea5588ff9540d39bf53289..e27cbffb283fefef456e40658f8fe01f168f3573 100644 (file)
@@ -3,7 +3,19 @@
         "chrome": {
             "moduleName": "OSXChromeDriver", 
             "filePath": "browser_driver.osx_chrome_driver"
-        }, 
+        },
+        "chrome-canary": {
+            "moduleName": "OSXChromeCanaryDriver", 
+            "filePath": "browser_driver.osx_chrome_driver"
+        },
+        "firefox": {
+            "moduleName": "OSXFirefoxDriver", 
+            "filePath": "browser_driver.osx_firefox_driver"
+        },
+        "firefox-nightly": {
+            "moduleName": "OSXFirefoxNightlyDriver", 
+            "filePath": "browser_driver.osx_firefox_driver"
+        },
         "safari": {
             "moduleName": "OSXSafariDriver", 
             "filePath": "browser_driver.osx_safari_driver"
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py
new file mode 100644 (file)
index 0000000..906f1b3
--- /dev/null
@@ -0,0 +1,38 @@
+
+import logging
+import os
+import subprocess
+
+from AppKit import NSRunningApplication
+from browser_driver import BrowserDriver
+
+
+_log = logging.getLogger(__name__)
+
+
+class OSXBrowserDriver(BrowserDriver):
+    bundleIdentifier = None
+
+    def prepareEnv(self):
+        self.closeBrowsers()
+
+    def closeBrowsers(self):
+        self.terminateProcesses(self.bundleIdentifier)
+
+    @classmethod
+    def launchProcess(cls, buildDir, appName, url, args):
+        if not buildDir:
+            buildDir = '/Applications/'
+        appPath = os.path.join(buildDir, appName)
+
+        _log.info('Launching "%s" with url "%s"' % (appPath, url))
+
+        # FIXME: May need to be modified for a local build such as setting up DYLD libraries
+        subprocess.Popen((['open', '-a', appPath] + args)).communicate()
+
+    @classmethod
+    def terminateProcesses(cls, bundleIdentifier):
+        _log.info('Closing all terminating all processes with the bundle identifier %s' % bundleIdentifier)
+        processes = NSRunningApplication.runningApplicationsWithBundleIdentifier_(bundleIdentifier)
+        for process in processes:
+            process.terminate()
index 878b14071f58b8168b31940b1f04bc1f909e26e9..b85ec77f1410ae0295e71f6dbf976ca3fcde234f 100644 (file)
@@ -5,29 +5,21 @@ import os
 import subprocess
 import time
 
-# We assume that this handle can only be used when the platform is OSX
-from AppKit import NSRunningApplication
-from browser_driver import BrowserDriver
+from osx_browser_driver import OSXBrowserDriver
 
 
 _log = logging.getLogger(__name__)
 
 
-class OSXChromeDriver(BrowserDriver):
+class OSXChromeDriver(OSXBrowserDriver):
+    bundleIdentifier = 'com.google.Chrome'
 
-    def prepareEnv(self):
-        self.closeBrowsers()
-        self.chromePreferences = []
+    def launchUrl(self, url, browserBuildPath):
+        self.launchProcess(buildDir=browserBuildPath, appName='Google Chrome.app', url=url, args=['--args', '--homepage', url])
+
+
+class OSXChromeCanaryDriver(OSXBrowserDriver):
+    bundleIdentifier = 'com.google.Chrome.canary'
 
     def launchUrl(self, url, browserBuildPath):
-        if not browserBuildPath:
-            browserBuildPath = '/Applications/'
-        _log.info('Launching chrome: %s with url: %s' % (os.path.join(browserBuildPath, 'Google Chrome.app'), url))
-        # FIXME: May need to be modified for develop build, such as setting up libraries
-        subprocess.Popen(['open', '-a', os.path.join(browserBuildPath, 'Google Chrome.app'), '--args', '--homepage', url] + self.chromePreferences).communicate()
-
-    def closeBrowsers(self):
-        _log.info('Closing all existing chrome processes')
-        chromes = NSRunningApplication.runningApplicationsWithBundleIdentifier_('com.google.Chrome')
-        for chrome in chromes:
-            chrome.terminate()
+        self.launchProcess(buildDir=browserBuildPath, appName='Google Chrome Canary.app', url=url, args=['--args', '--homepage', url])
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py
new file mode 100644 (file)
index 0000000..6189229
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import logging
+import os
+import subprocess
+import time
+
+from osx_browser_driver import OSXBrowserDriver
+
+
+_log = logging.getLogger(__name__)
+
+
+class OSXFirefoxDriver(OSXBrowserDriver):
+    bundleIdentifier = 'org.mozilla.firefox'
+
+    def launchUrl(self, url, browserBuildPath):
+        self.launchProcess(buildDir=browserBuildPath, appName='Firefox.app', url=url, args=[url])
+
+
+class OSXFirefoxNightlyDriver(OSXBrowserDriver):
+    bundleIdentifier = 'org.mozilla.nightly'
+
+    def launchUrl(self, url, browserBuildPath):
+        self.launchProcess(buildDir=browserBuildPath, appName='FirefoxNightly.app', url=url, args=[url])
index 62a365ac7f6d63ab131e203171635add1ff7782f..73d206de853e9a0558fce929ff5f6b1c97c01727 100644 (file)
@@ -5,16 +5,14 @@ import os
 import subprocess
 import time
 
-# We assume that this handle can only be used when the platform is OSX.
-from AppKit import NSRunningApplication
-from browser_driver import BrowserDriver
+from osx_browser_driver import OSXBrowserDriver
 from webkitpy.benchmark_runner.utils import forceRemove
 
 
 _log = logging.getLogger(__name__)
 
 
-class OSXSafariDriver(BrowserDriver):
+class OSXSafariDriver(OSXBrowserDriver):
 
     def prepareEnv(self):
         self.safariProcess = None
@@ -43,10 +41,7 @@ class OSXSafariDriver(BrowserDriver):
         subprocess.Popen(['open', url])
 
     def closeBrowsers(self):
-        _log.info('Closing all existing safari processes')
-        safariInstances = NSRunningApplication.runningApplicationsWithBundleIdentifier_('com.apple.Safari')
-        for safariInstance in safariInstances:
-            safariInstance.terminate()
+        self.terminateProcesses('com.apple.Safari')
         if self.safariProcess:
             _log.info('Safari process console output:\nstdout: %s\nstderr: %s' % self.safariProcess.communicate())
             if self.safariProcess.returncode: