Fix BenchmarkRunner to only import selenium when needed
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jul 2017 04:36:46 +0000 (04:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jul 2017 04:36:46 +0000 (04:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174808

Patch by Matthew Stewart <matthew_r_stewart@apple.com> on 2017-07-24
Reviewed by Stephanie Lewis.

* Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py:
(LinuxChromeDriver.launch_driver):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py:
(LinuxFirefoxDriver.launch_driver):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
(OSXChromeDriver.launch_driver):
(OSXChromeCanaryDriver.launch_driver):
(create_chrome_options):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:
(OSXFirefoxDriver.launch_driver):
(OSXFirefoxNightlyDriver.launch_driver):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:
(OSXSafariDriver.launch_driver):
* Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py:
(WebDriverBenchmarkRunner._run_one_test):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py
Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py

index 20c03481149ae41075085e5b7c7dd17a62756379..67a584fe1edce74c7ae0a1459b7c38baf31633a0 100644 (file)
@@ -1,3 +1,26 @@
+2017-07-24  Matthew Stewart  <matthew_r_stewart@apple.com>
+
+        Fix BenchmarkRunner to only import selenium when needed
+        https://bugs.webkit.org/show_bug.cgi?id=174808
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py:
+        (LinuxChromeDriver.launch_driver):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py:
+        (LinuxFirefoxDriver.launch_driver):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
+        (OSXChromeDriver.launch_driver):
+        (OSXChromeCanaryDriver.launch_driver):
+        (create_chrome_options):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:
+        (OSXFirefoxDriver.launch_driver):
+        (OSXFirefoxNightlyDriver.launch_driver):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:
+        (OSXSafariDriver.launch_driver):
+        * Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py:
+        (WebDriverBenchmarkRunner._run_one_test):
+
 2017-07-23  Darin Adler  <darin@apple.com>
 
         More NeverDestroyed and related cleanup
index 60c0ffff6785851b8db0d349353c1522291fa405..6b873f5f7f63435f488998ad8b452cbc951fcf0a 100644 (file)
@@ -27,8 +27,6 @@
 import os
 
 from linux_browser_driver import LinuxBrowserDriver
-from selenium import webdriver
-from selenium.webdriver.chrome.options import Options
 
 
 class LinuxChromeDriver(LinuxBrowserDriver):
@@ -41,6 +39,7 @@ class LinuxChromeDriver(LinuxBrowserDriver):
         super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path)
 
     def launch_driver(self, url, options, browser_build_path):
+        from webkitpy.thirdparty.autoinstalled.selenium.webdriver.chrome.options import Options
         options = Options()
         options.add_argument("--disable-web-security")
         options.add_argument("--user-data-dir")
@@ -50,6 +49,7 @@ class LinuxChromeDriver(LinuxBrowserDriver):
             binary_path = os.path.join(browser_build_path, 'chromium-browser')
             options.binary_location = binary_path
         driver_executable = self.webdriver_binary_path
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Chrome(chrome_options=options, executable_path=driver_executable)
         super(LinuxChromeDriver, self).launch_webdriver(url, driver)
         return driver
index 6bea17281783ae8645afe61349aee70abc5569cf..dee975456e5c3738918081b287a5ca947491813f 100644 (file)
@@ -27,8 +27,6 @@
 import os
 
 from linux_browser_driver import LinuxBrowserDriver
-from selenium import webdriver
-from selenium.webdriver.firefox.options import Options
 
 
 class LinuxFirefoxDriver(LinuxBrowserDriver):
@@ -43,11 +41,13 @@ class LinuxFirefoxDriver(LinuxBrowserDriver):
         super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path)
 
     def launch_driver(self, url, options, browser_build_path):
+        from webkitpy.thirdparty.autoinstalled.selenium.webdriver.firefox.options import Options
         options = Options()
         if browser_build_path:
             binary_path = os.path.join(browser_build_path, 'firefox-bin')
             options.binary_location = binary_path
         driver_executable = self.webdriver_binary_path
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Firefox(firefox_options=options, executable_path=driver_executable)
         super(LinuxFirefoxDriver, self).launch_webdriver(url, driver)
         return driver
index 013b1006686e00fc55ed6c31cdca24163315c086..c67066bbaffa1291e9ceb8724b18583a842be02e 100644 (file)
@@ -4,19 +4,11 @@ import logging
 import os
 
 from osx_browser_driver import OSXBrowserDriver
-from selenium import webdriver
-from selenium.webdriver.chrome.options import Options
 
 
 _log = logging.getLogger(__name__)
 window_size_arg = '--window-size={width},{height}'.format(width=int(OSXBrowserDriver._screen_size().width), height=int(OSXBrowserDriver._screen_size().height))
 args = ['--args', '--homepage', window_size_arg]
-chrome_options = Options()
-chrome_options.add_argument("--disable-web-security")
-chrome_options.add_argument("--user-data-dir")
-chrome_options.add_argument("--disable-extensions")
-chrome_options.add_argument(window_size_arg)
-
 
 class OSXChromeDriver(OSXBrowserDriver):
     process_name = 'Google Chrome'
@@ -28,11 +20,13 @@ class OSXChromeDriver(OSXBrowserDriver):
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
 
     def launch_driver(self, url, options, browser_build_path):
+        chrome_options = create_chrome_options()
         if browser_build_path:
             app_path = os.path.join(browser_build_path, self.app_name)
             binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
             chrome_options.binary_location = binary_path
         driver_executable = self.webdriver_binary_path
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)
         self._launch_webdriver(url=url, driver=driver)
         return driver
@@ -48,12 +42,24 @@ class OSXChromeCanaryDriver(OSXBrowserDriver):
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
 
     def launch_driver(self, url, options, browser_build_path):
+        chrome_options = create_chrome_options()
         if not browser_build_path:
             browser_build_path = '/Applications/'
         app_path = os.path.join(browser_build_path, self.app_name)
         binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
         chrome_options.binary_location = binary_path
         driver_executable = self.webdriver_binary_path
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)
         self._launch_webdriver(url=url, driver=driver)
         return driver
+
+
+def create_chrome_options():
+    from webkitpy.thirdparty.autoinstalled.selenium.webdriver.chrome.options import Options
+    chrome_options = Options()
+    chrome_options.add_argument("--disable-web-security")
+    chrome_options.add_argument("--user-data-dir")
+    chrome_options.add_argument("--disable-extensions")
+    chrome_options.add_argument(window_size_arg)
+    return chrome_options
index 67afe839a4b5df6ffd3823550fc6d3151f5b2463..54a056b0fe62303310ea1a0060fe12106b1731bd 100644 (file)
@@ -4,14 +4,11 @@ import logging
 import os
 
 from osx_browser_driver import OSXBrowserDriver
-from selenium import webdriver
-from selenium.webdriver.firefox.options import Options
 
 
 _log = logging.getLogger(__name__)
 
 args = ['--args', '-width', str(int(OSXBrowserDriver._screen_size().width)), '-height', str(int(OSXBrowserDriver._screen_size().height))]
-firefox_options = Options()
 
 
 class OSXFirefoxDriver(OSXBrowserDriver):
@@ -24,11 +21,14 @@ class OSXFirefoxDriver(OSXBrowserDriver):
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
 
     def launch_driver(self, url, options, browser_build_path):
+        from webkitpy.thirdparty.autoinstalled.selenium.webdriver.firefox.options import Options
+        firefox_options = Options()
         if browser_build_path:
             app_path = os.path.join(browser_build_path, self.app_name)
             binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
             firefox_options.binary_location = binary_path
         driver_executable = self.webdriver_binary_path
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable)
         self._launch_webdriver(url=url, driver=driver)
         return driver
@@ -44,12 +44,15 @@ class OSXFirefoxNightlyDriver(OSXBrowserDriver):
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
 
     def launch_driver(self, url, options, browser_build_path):
+        from webkitpy.thirdparty.autoinstalled.selenium.webdriver.firefox.options import Options
+        firefox_options = Options()
         if not browser_build_path:
             browser_build_path = '/Applications/'
         app_path = os.path.join(browser_build_path, self.app_name)
         binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
         firefox_options.binary_location = binary_path
         driver_executable = self.webdriver_binary_path
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable)
         self._launch_webdriver(url=url, driver=driver)
         return driver
index 89a2f06d4971d8561ad5d9524e3470d856aa1f93..c6a0c4a3f78f5161ba33b546ff2dce9d2dce1da6 100644 (file)
@@ -7,7 +7,6 @@ import time
 
 from osx_browser_driver import OSXBrowserDriver
 from webkitpy.benchmark_runner.utils import force_remove
-from selenium import webdriver
 
 
 _log = logging.getLogger(__name__)
@@ -46,6 +45,7 @@ class OSXSafariDriver(OSXBrowserDriver):
         subprocess.Popen(['open', '-a', args[0], url])
 
     def launch_driver(self, url, options, browser_build_path):
+        from webkitpy.thirdparty.autoinstalled.selenium import webdriver
         driver = webdriver.Safari(quiet=False)
         self._launch_webdriver(url=url, driver=driver)
         return driver
index 1eb53f9966fd77ae13f4efe9cd4f884f47434d50..82c1d41b21529ff07dc4fbfdbd174d65ae645a4f 100644 (file)
@@ -4,7 +4,6 @@ import json
 import logging
 
 from benchmark_runner import BenchmarkRunner
-from selenium.webdriver.support.ui import WebDriverWait
 
 
 _log = logging.getLogger(__name__)
@@ -18,6 +17,7 @@ class WebDriverBenchmarkRunner(BenchmarkRunner):
         return result
 
     def _run_one_test(self, web_root, test_file):
+        from webkitpy.thirdparty.autoinstalled.selenium.webdriver.support.ui import WebDriverWait
         result = None
         try:
             url = 'file://{root}/{plan_name}/{test_file}'.format(root=web_root, plan_name=self._plan_name, test_file=test_file)