run-webkit-tests calls out to webkit-build-directory twice
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 01:04:43 +0000 (01:04 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 01:04:43 +0000 (01:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77248

Reviewed by Dirk Pranke.

This reduces to calls to webkit-build-directory to one call and
saves 500ms for run-webkit-tests over a single file.

* Scripts/webkit-build-directory:
If called with no arguments, print out both the top-level directory and the
configuration directory.

* Scripts/webkit-build-directory:
* Scripts/webkitpy/layout_tests/port/config.py:
(Config.build_directory):
When called with no arguments, get and cache both the top-level and configuration directories.

* Scripts/webkitpy/layout_tests/port/config_standalone.py:
(main):
* Scripts/webkitpy/layout_tests/port/config_unittest.py:
(ConfigTest.assert_configuration):
(ConfigTest.test_build_directory.mock_webkit_build_directory):
(ConfigTest.test_build_directory):
(ConfigTest.test_default_configuration__notfound):
* Scripts/webkitpy/layout_tests/port/webkit.py:
(WebKitPort._build_path):
Cache the root directory in the options object so that other users
of the options object don't need to call out to webkit-build-directory.

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

Tools/ChangeLog
Tools/Scripts/webkit-build-directory
Tools/Scripts/webkitpy/layout_tests/port/config.py
Tools/Scripts/webkitpy/layout_tests/port/config_standalone.py
Tools/Scripts/webkitpy/layout_tests/port/config_unittest.py
Tools/Scripts/webkitpy/layout_tests/port/webkit.py

index 48bc56fdaed7431785bfa3fbd65169ae127b0af3..421f95dcffd1160400addc665c4c55fe49a71b10 100644 (file)
@@ -1,3 +1,34 @@
+2012-01-30  Ojan Vafai  <ojan@chromium.org>
+
+        run-webkit-tests calls out to webkit-build-directory twice
+        https://bugs.webkit.org/show_bug.cgi?id=77248
+
+        Reviewed by Dirk Pranke.
+
+        This reduces to calls to webkit-build-directory to one call and
+        saves 500ms for run-webkit-tests over a single file.
+
+        * Scripts/webkit-build-directory:
+        If called with no arguments, print out both the top-level directory and the 
+        configuration directory.
+
+        * Scripts/webkit-build-directory:
+        * Scripts/webkitpy/layout_tests/port/config.py:
+        (Config.build_directory):
+        When called with no arguments, get and cache both the top-level and configuration directories.
+
+        * Scripts/webkitpy/layout_tests/port/config_standalone.py:
+        (main):
+        * Scripts/webkitpy/layout_tests/port/config_unittest.py:
+        (ConfigTest.assert_configuration):
+        (ConfigTest.test_build_directory.mock_webkit_build_directory):
+        (ConfigTest.test_build_directory):
+        (ConfigTest.test_default_configuration__notfound):
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        (WebKitPort._build_path):
+        Cache the root directory in the options object so that other users
+        of the options object don't need to call out to webkit-build-directory.
+
 2012-01-30  Ojan Vafai  <ojan@chromium.org>
 
         Parsing test_expecations.txt + Skipped lists takes too long
index bf7d66dbfb962c2d61320cdf7c70f63b8059c7e5..dab1d6622fff7f52d79d3d280dc77aee19664852 100755 (executable)
@@ -57,12 +57,15 @@ my $getOptionsResult = GetOptions(
     'help|h' => \$showHelp,
 );
 
-if (!$getOptionsResult || $showHelp || (!$showConfigurationDirectory && !$showTopLevelDirectory)) {
+if (!$getOptionsResult || $showHelp) {
     print STDERR $usage;
     exit 1;
 }
 
-if ($showTopLevelDirectory) {
+if (!$showConfigurationDirectory && !$showTopLevelDirectory) {
+    print baseProductDir() . "\n";
+    print productDir() . "\n";
+} elsif ($showTopLevelDirectory) {
     print baseProductDir() . "\n";
 } else {
     print productDir() . "\n";
index c5529072818d302ea3de868b93f7da7b3c865700..6a1045f12ef29f420a6570453b089016aec07058 100644 (file)
@@ -74,12 +74,19 @@ class Config(object):
             flags = ["--configuration", self.flag_for_configuration(configuration)]
         else:
             configuration = ""
-            flags = ["--top-level"]
+            flags = []
 
         if not self._build_directories.get(configuration):
             args = ["perl", self.script_path("webkit-build-directory")] + flags
-            self._build_directories[configuration] = (
-                self._executive.run_command(args, cwd=self.webkit_base_dir()).rstrip())
+            output = self._executive.run_command(args, cwd=self.webkit_base_dir()).rstrip()
+            parts = output.split("\n")
+            self._build_directories[configuration] = parts[0]
+
+            if len(parts) == 2:
+                default_configuration = parts[1][len(parts[0]):]
+                if default_configuration.startswith("/"):
+                    default_configuration = default_configuration[1:]
+                self._build_directories[default_configuration] = parts[1]
 
         return self._build_directories[configuration]
 
index 3dec3b91c4562beca91ba50e7c7215b5b42ddcaf..5b048314520c899454cfde16e6c9332e2fe2593f 100644 (file)
@@ -57,7 +57,7 @@ def main(argv=None):
         argv = sys.argv
 
     if len(argv) == 3 and argv[1] == '--mock':
-        e = executive_mock.MockExecutive2(output='foo')
+        e = executive_mock.MockExecutive2(output='foo\nfoo/%s' % argv[2])
         fs = filesystem_mock.MockFileSystem({'foo/Configuration': argv[2]})
     else:
         e = executive.Executive()
index e557eefe8f1506273c45f9a3c3e52241995f80d7..51a779850056901008990a2553277fac17bf1fe4 100644 (file)
@@ -51,18 +51,21 @@ class ConfigTest(unittest.TestCase):
     def assert_configuration(self, contents, expected):
         # This tests that a configuration file containing
         # _contents_ ends up being interpreted as _expected_.
-        c = self.make_config('foo', {'foo/Configuration': contents})
+        output = 'foo\nfoo/%s' % contents
+        c = self.make_config(output, {'foo/Configuration': contents})
         self.assertEqual(c.default_configuration(), expected)
 
     def test_build_directory(self):
         # --top-level
         def mock_webkit_build_directory(arg_list):
             if arg_list == ['--top-level']:
-                return '/WebKitBuild'
+                return '/WebKitBuild/'
             elif arg_list == ['--configuration', '--debug']:
                 return '/WebKitBuild/Debug'
             elif arg_list == ['--configuration', '--release']:
                 return '/WebKitBuild/Release'
+            elif arg_list == []:
+                return '/WebKitBuild/\n/WebKitBuild//Debug\n'
             return 'Error'
 
         def mock_run_command(arg_list):
@@ -71,10 +74,10 @@ class ConfigTest(unittest.TestCase):
             return 'Error'
 
         c = self.make_config(run_command_fn=mock_run_command)
-        self.assertTrue(c.build_directory(None).endswith('WebKitBuild'))
+        self.assertEqual(c.build_directory(None), '/WebKitBuild/')
 
         # Test again to check caching
-        self.assertTrue(c.build_directory(None).endswith('WebKitBuild'))
+        self.assertEqual(c.build_directory(None), '/WebKitBuild/')
 
         # Test other values
         self.assertTrue(c.build_directory('Release').endswith('/Release'))
@@ -95,7 +98,7 @@ class ConfigTest(unittest.TestCase):
 
     def test_default_configuration__notfound(self):
         # This tests what happens if the default configuration file doesn't exist.
-        c = self.make_config(output='foo', files={'foo/Configuration': None})
+        c = self.make_config(output='foo\nfoo/Release', files={'foo/Configuration': None})
         self.assertEqual(c.default_configuration(), "Release")
 
     def test_default_configuration__unknown(self):
index 41a152d6f0718a8ba5bbaf465809c37c00b86f6a..7918066525f1d380c8afbfdb878a8ae376f6140a 100644 (file)
@@ -380,6 +380,9 @@ class WebKitPort(Port):
         build_directory = self.get_option('root')
         if not build_directory:
             build_directory = self._config.build_directory(self.get_option('configuration'))
+            # Set --root here Since this modifies the options object used by the worker subprocesses,
+            # it avoids the slow call out to build_directory in each subprocess.
+            self.set_option_default('root', build_directory)
         return self._filesystem.join(build_directory, *comps)
 
     def _path_to_driver(self):