Title: [219860] trunk/Tools
Revision
219860
Author
[email protected]
Date
2017-07-24 21:36:46 -0700 (Mon, 24 Jul 2017)

Log Message

Fix BenchmarkRunner to only import selenium when needed
https://bugs.webkit.org/show_bug.cgi?id=174808

Patch by Matthew Stewart <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (219859 => 219860)


--- trunk/Tools/ChangeLog	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/ChangeLog	2017-07-25 04:36:46 UTC (rev 219860)
@@ -1,3 +1,26 @@
+2017-07-24  Matthew Stewart  <[email protected]>
+
+        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  <[email protected]>
 
         More NeverDestroyed and related cleanup

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py (219859 => 219860)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py	2017-07-25 04:36:46 UTC (rev 219860)
@@ -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 @@
         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 @@
             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

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py (219859 => 219860)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py	2017-07-25 04:36:46 UTC (rev 219860)
@@ -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 @@
         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

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py (219859 => 219860)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py	2017-07-25 04:36:46 UTC (rev 219860)
@@ -4,20 +4,12 @@
 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'
     browser_name = 'chrome'
@@ -28,11 +20,13 @@
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, 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="" driver=driver)
         return driver
@@ -48,6 +42,7 @@
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, 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)
@@ -54,6 +49,17 @@
         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="" 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

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py (219859 => 219860)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py	2017-07-25 04:36:46 UTC (rev 219860)
@@ -4,14 +4,11 @@
 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 @@
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, 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="" driver=driver)
         return driver
@@ -44,6 +44,8 @@
         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, 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)
@@ -50,6 +52,7 @@
         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="" driver=driver)
         return driver

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py (219859 => 219860)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py	2017-07-25 04:36:46 UTC (rev 219860)
@@ -7,7 +7,6 @@
 
 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 @@
         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="" driver=driver)
         return driver

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py (219859 => 219860)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py	2017-07-25 04:35:46 UTC (rev 219859)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py	2017-07-25 04:36:46 UTC (rev 219860)
@@ -4,7 +4,6 @@
 import logging
 
 from benchmark_runner import BenchmarkRunner
-from selenium.webdriver.support.ui import WebDriverWait
 
 
 _log = logging.getLogger(__name__)
@@ -18,6 +17,7 @@
         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 = ''.format(root=web_root, plan_name=self._plan_name, test_file=test_file)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to