run-webkit-tests: handle Darwin framework/library environment variables more consistently
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Mar 2016 19:59:41 +0000 (19:59 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Mar 2016 19:59:41 +0000 (19:59 +0000)
<http://webkit.org/b/155392>

Reviewed by Daniel Bates.

These changes will make it possible to pass through environment
variables from the run-webkit-tests command-line.

* Scripts/webkitpy/port/base.py:
(Port.to.setup_environ_for_server): Add DYLD_FRAMEWORK_PATH,
__XPC_DYLD_FRAMEWORK_PATH and __XPC_DYLD_LIBRARY_PATH to the
list of variables to keep from the run-webkit-test environment.

* Scripts/webkitpy/port/driver.py:
(Driver._append_environment_variable_path): Add method to append
a path to an environment variable, or set the path if the
variable doesn't exist.
(Driver._setup_environ_for_driver): Extract build_root_path into
a local variable.  Use Driver._append_environment_variable_path
to extend DYLD_LIBRARY_PATH, __XPC_DYLD_LIBRARY_PATH,
DYLD_FRAMEWORK_PATH and __XPC_DYLD_FRAMEWORK_PATH instead of
overwriting them.

* Scripts/webkitpy/port/driver_unittest.py:
(DriverTest.test__append_environment_variable_path): Add test
method to test Driver._append_environment_variable_path.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/port/base.py
Tools/Scripts/webkitpy/port/driver.py
Tools/Scripts/webkitpy/port/driver_unittest.py

index b961e52..ed32328 100644 (file)
@@ -1,3 +1,32 @@
+2016-03-12  David Kilzer  <ddkilzer@apple.com>
+
+        run-webkit-tests: handle Darwin framework/library environment variables more consistently
+        <http://webkit.org/b/155392>
+
+        Reviewed by Daniel Bates.
+
+        These changes will make it possible to pass through environment
+        variables from the run-webkit-tests command-line.
+
+        * Scripts/webkitpy/port/base.py:
+        (Port.to.setup_environ_for_server): Add DYLD_FRAMEWORK_PATH,
+        __XPC_DYLD_FRAMEWORK_PATH and __XPC_DYLD_LIBRARY_PATH to the
+        list of variables to keep from the run-webkit-test environment.
+
+        * Scripts/webkitpy/port/driver.py:
+        (Driver._append_environment_variable_path): Add method to append
+        a path to an environment variable, or set the path if the
+        variable doesn't exist.
+        (Driver._setup_environ_for_driver): Extract build_root_path into
+        a local variable.  Use Driver._append_environment_variable_path
+        to extend DYLD_LIBRARY_PATH, __XPC_DYLD_LIBRARY_PATH,
+        DYLD_FRAMEWORK_PATH and __XPC_DYLD_FRAMEWORK_PATH instead of
+        overwriting them.
+
+        * Scripts/webkitpy/port/driver_unittest.py:
+        (DriverTest.test__append_environment_variable_path): Add test
+        method to test Driver._append_environment_variable_path.
+
 2016-03-11  Alexey Proskuryakov  <ap@apple.com>
 
         [ios-sim debug] API test WTF_Lock.ContendedShortSection and WTF_ParkingLot.UnparkOneFifty timing out
index c1cbe38..292843f 100644 (file)
@@ -838,8 +838,11 @@ class Port(object):
             'XDG_RUNTIME_DIR',
 
             # Darwin:
+            'DYLD_FRAMEWORK_PATH',
             'DYLD_LIBRARY_PATH',
             'HOME',
+            '__XPC_DYLD_FRAMEWORK_PATH',
+            '__XPC_DYLD_LIBRARY_PATH',
 
             # CYGWIN:
             'HOMEDRIVE',
index 44a745e..8fa8d9f 100644 (file)
@@ -311,10 +311,18 @@ class Driver(object):
             self._start(pixel_tests, per_test_args)
             self._run_post_start_tasks()
 
+    def _append_environment_variable_path(self, environment, variable, path):
+        if variable in environment:
+            environment[variable] = environment[variable] + os.pathsep + path
+        else:
+            environment[variable] = path
+
     def _setup_environ_for_driver(self, environment):
-        environment['DYLD_LIBRARY_PATH'] = str(self._port._build_path())
-        environment['__XPC_DYLD_LIBRARY_PATH'] = environment['DYLD_LIBRARY_PATH']
-        environment['DYLD_FRAMEWORK_PATH'] = str(self._port._build_path())
+        build_root_path = str(self._port._build_path())
+        self._append_environment_variable_path(environment, 'DYLD_LIBRARY_PATH', build_root_path)
+        self._append_environment_variable_path(environment, '__XPC_DYLD_LIBRARY_PATH', build_root_path)
+        self._append_environment_variable_path(environment, 'DYLD_FRAMEWORK_PATH', build_root_path)
+        self._append_environment_variable_path(environment, '__XPC_DYLD_FRAMEWORK_PATH', build_root_path)
         # Use an isolated temp directory that can be deleted after testing (especially important on Mac, as
         # CoreMedia disk cache is in the temp directory).
         environment['TMPDIR'] = str(self._driver_tempdir)
index 0bf4303..cda62c3 100644 (file)
@@ -38,6 +38,7 @@ from webkitpy.port.port_testcase import TestWebKitPort
 
 from webkitpy.tool.mocktool import MockOptions
 
+import os
 import sys
 
 class DriverOutputTest(unittest.TestCase):
@@ -281,3 +282,28 @@ class DriverTest(unittest.TestCase):
         driver = Driver(port, 0, pixel_tests=True)
         driver.start(True, [])
         self.assertTrue(driver._server_process.started)
+
+    def test__append_environment_variable_path(self):
+        port = self.make_port()
+        driver = Driver(port, None, pixel_tests=False)
+
+        environment = {}
+        variable = 'DYLD_FAKE_PATH'
+        path = '/tmp/fake-dyld-path'
+        driver._append_environment_variable_path(environment, variable, path)
+        self.assertEqual(environment[variable], path)
+
+        base_value = ''
+        environment[variable] = base_value
+        driver._append_environment_variable_path(environment, variable, path)
+        self.assertEqual(environment[variable], base_value + os.pathsep + path)
+
+        base_value = '/usr/lib'
+        environment[variable] = base_value
+        driver._append_environment_variable_path(environment, variable, path)
+        self.assertEqual(environment[variable], base_value + os.pathsep + path)
+
+        base_value = os.pathsep.join(['/usr/lib', '/usr/local/lib'])
+        environment[variable] = base_value
+        driver._append_environment_variable_path(environment, variable, path)
+        self.assertEqual(environment[variable], base_value + os.pathsep + path)