Changeset 247663 in webkit


Ignore:
Timestamp:
Jul 19, 2019 5:55:51 PM (5 years ago)
Author:
clopez@igalia.com
Message:

[webkitpy] Allow the testrunner driver to setup the environment completely without needing to start the server process.
https://bugs.webkit.org/show_bug.cgi?id=199945

Reviewed by Michael Catanzaro.

Refactor the code to create the Driver temporal directories inside Driver._setup_environ_for_driver().
This allows external callers to setup the environment for running tests by calling that method without needing to start the server process.
When this callers finish testing, it is enough with calling either Driver.stop() or Driver._delete_temporal_directories().

  • Scripts/webkitpy/port/driver.py:

(Driver._setup_environ_for_driver):
(Driver._create_temporal_directories):
(Driver):
(Driver._start):
(Driver._delete_temporal_directories):
(Driver.stop):

  • Scripts/webkitpy/w3c/wpt_runner.py: Not needed anymore to start the driver since this doesnt need the server process running.

(main):

  • Scripts/webkitpy/webdriver_tests/webdriver_test_runner.py: Ditto.

(WebDriverTestRunner.init):

  • glib/api_test_runner.py:

(TestRunner._setup_testing_environment): Ditto.

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r247646 r247663  
     12019-07-19  Carlos Alberto Lopez Perez  <clopez@igalia.com>
     2
     3        [webkitpy] Allow the testrunner driver to setup the environment completely without needing to start the server process.
     4        https://bugs.webkit.org/show_bug.cgi?id=199945
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Refactor the code to create the Driver temporal directories inside Driver._setup_environ_for_driver().
     9        This allows external callers to setup the environment for running tests by calling that method without needing to start the server process.
     10        When this callers finish testing, it is enough with calling either Driver.stop() or Driver._delete_temporal_directories().
     11
     12        * Scripts/webkitpy/port/driver.py:
     13        (Driver._setup_environ_for_driver):
     14        (Driver._create_temporal_directories):
     15        (Driver):
     16        (Driver._start):
     17        (Driver._delete_temporal_directories):
     18        (Driver.stop):
     19        * Scripts/webkitpy/w3c/wpt_runner.py: Not needed anymore to start the driver since this doesnt need the server process running.
     20        (main):
     21        * Scripts/webkitpy/webdriver_tests/webdriver_test_runner.py: Ditto.
     22        (WebDriverTestRunner.__init__):
     23        * glib/api_test_runner.py:
     24        (TestRunner._setup_testing_environment): Ditto.
     25
    1262019-07-19  Aakash Jain  <aakash_jain@apple.com>
    227
  • trunk/Tools/Scripts/webkitpy/port/driver.py

    r247642 r247663  
    411411
    412412    def _setup_environ_for_driver(self, environment):
     413        self._port._clear_global_caches_and_temporary_files()
     414        self._create_temporal_directories()
    413415        build_root_path = str(self._port._build_path())
    414416        self._append_environment_variable_path(environment, 'DYLD_LIBRARY_PATH', build_root_path)
     
    452454        return environment
    453455
     456    def _create_temporal_directories(self):
     457        # Each driver process should be using individual directories under _driver_tempdir (which is deleted when stopping),
     458        # however some subsystems on some platforms could end up using process default ones.
     459        if self._driver_tempdir is None:
     460            self._driver_tempdir = self._port._driver_tempdir(self._target_host)
     461            self._driver_user_directory_suffix = os.path.basename(str(self._driver_tempdir))
     462            user_cache_directory = self._port._path_to_user_cache_directory(self._driver_user_directory_suffix)
     463            if user_cache_directory:
     464                self._target_host.filesystem.maybe_make_directory(user_cache_directory)
     465                self._driver_user_cache_directory = user_cache_directory
     466
    454467    def _start(self, pixel_tests, per_test_args):
    455468        self.stop()
    456         # Each driver process should be using individual directories under _driver_tempdir (which is deleted when stopping),
    457         # however some subsystems on some platforms could end up using process default ones.
    458         self._port._clear_global_caches_and_temporary_files()
    459         self._driver_tempdir = self._port._driver_tempdir(self._target_host)
    460         self._driver_user_directory_suffix = os.path.basename(str(self._driver_tempdir))
    461         user_cache_directory = self._port._path_to_user_cache_directory(self._driver_user_directory_suffix)
    462         if user_cache_directory:
    463             self._target_host.filesystem.maybe_make_directory(user_cache_directory)
    464             self._driver_user_cache_directory = user_cache_directory
    465469        environment = self._setup_environ_for_test()
    466470        self._crashed_process_name = None
     
    477481        # Remote drivers will override this method to return the pid on the device.
    478482        return self._server_process.pid()
     483
     484    def _delete_temporal_directories(self):
     485        if self._driver_tempdir:
     486            self._target_host.filesystem.rmtree(str(self._driver_tempdir))
     487            self._driver_tempdir = None
     488        if self._driver_user_cache_directory:
     489            self._target_host.filesystem.rmtree(self._driver_user_cache_directory)
     490            self._driver_user_cache_directory = None
    479491
    480492    def stop(self):
     
    484496            if self._profiler:
    485497                self._profiler.profile_after_exit()
    486 
    487         if self._driver_tempdir:
    488             self._target_host.filesystem.rmtree(str(self._driver_tempdir))
    489             self._driver_tempdir = None
    490         if self._driver_user_cache_directory:
    491             self._target_host.filesystem.rmtree(self._driver_user_cache_directory)
    492             self._driver_user_cache_directory = None
     498        self._delete_temporal_directories()
    493499
    494500    def cmd_line(self, pixel_tests, per_test_args):
  • trunk/Tools/Scripts/webkitpy/w3c/wpt_runner.py

    r247550 r247663  
    8181    port._display_server = options.display_server
    8282    display_driver = port.create_driver(worker_number=0, no_timeout=True)._make_driver(pixel_tests=False)
    83     display_driver.start(False, [])
    8483    if not display_driver.check_driver(port):
    8584        raise RuntimeError("Failed to check driver %s" % display_driver.__class__.__name__)
  • trunk/Tools/Scripts/webkitpy/webdriver_tests/webdriver_test_runner.py

    r247550 r247663  
    6161                _log.warning('Test %s does not exist' % test)
    6262
    63         self._display_driver.start(False, [])
    6463        env = self._display_driver._setup_environ_for_test()
    6564        self._runners = [runner_cls(self._port, driver, env, self._expectations) for runner_cls in self.RUNNER_CLASSES]
  • trunk/Tools/glib/api_test_runner.py

    r247550 r247663  
    106106
    107107    def _setup_testing_environment(self):
    108         self._driver.start(False, [])
    109108        self._test_env = self._driver._setup_environ_for_test()
    110109        self._test_env["TEST_WEBKIT_API_WEBKIT2_RESOURCES_PATH"] = common.top_level_path("Tools", "TestWebKitAPI", "Tests", "WebKit")
Note: See TracChangeset for help on using the changeset viewer.