run-gtk-tests (glib/common.py) cannot determine build directory when webKitBranchBuil...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2018 08:54:02 +0000 (08:54 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Jun 2018 08:54:02 +0000 (08:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185643

Reviewed by Frédéric Wang.

Check if webKitBranchBuild is true in git config to add the branch name to the build path.

* Scripts/webkitpy/common/checkout/scm/git.py:
(Git.read_git_config): Add output_type parameter.
(Git.read_config): Call read_git_config with cws and executive.
(Git._upstream_branch): Use read_config().
(Git._assert_can_squash): Ditto.
(Git.remote_branch_ref): Ditto.
* Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
(GitSVNTest.test_read_git_config):
* glib/common.py:
(get_build_path):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/scm/git.py
Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py
Tools/glib/common.py

index 5c0faf0..4d9377f 100644 (file)
@@ -1,3 +1,23 @@
+2018-06-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        run-gtk-tests (glib/common.py) cannot determine build directory when webKitBranchBuild=true
+        https://bugs.webkit.org/show_bug.cgi?id=185643
+
+        Reviewed by Frédéric Wang.
+
+        Check if webKitBranchBuild is true in git config to add the branch name to the build path.
+
+        * Scripts/webkitpy/common/checkout/scm/git.py:
+        (Git.read_git_config): Add output_type parameter.
+        (Git.read_config): Call read_git_config with cws and executive.
+        (Git._upstream_branch): Use read_config().
+        (Git._assert_can_squash): Ditto.
+        (Git.remote_branch_ref): Ditto.
+        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
+        (GitSVNTest.test_read_git_config):
+        * glib/common.py:
+        (get_build_path):
+
 2018-06-20  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [WebKit on watchOS] Fixed position elements sometimes flicker when scrolling
index 8d30ee4..eac451f 100644 (file)
@@ -136,13 +136,22 @@ class Git(SCM, SVNRepository):
         return filepath.replace(root_end_with_slash, '')
 
     @classmethod
-    def read_git_config(cls, key, cwd=None, executive=None):
+    def read_git_config(cls, key, output_type=None, cwd=None, executive=None):
         # FIXME: This should probably use cwd=self.checkout_root.
         # Pass --get-all for cases where the config has multiple values
         # Pass the cwd if provided so that we can handle the case of running webkit-patch outside of the working directory.
         # FIXME: This should use an Executive.
         executive = executive or Executive()
-        return executive.run_command([cls.executable_name, "config", "--get-all", key], ignore_errors=True, cwd=cwd).rstrip('\n')
+        cmd = [cls.executable_name, "config", "--get-all"]
+        if output_type == bool:
+            cmd.append("--bool")
+        elif output_type == int:
+            cmd.append("--int")
+        cmd.append(key)
+        return executive.run_command(cmd, ignore_errors=True, cwd=cwd).rstrip('\n')
+
+    def read_config(self, key, output_type=None):
+        return self.read_git_config(key, output_type, self.checkout_root, self._executive)
 
     @staticmethod
     def commit_success_regexp():
@@ -193,7 +202,7 @@ class Git(SCM, SVNRepository):
 
     def _upstream_branch(self):
         current_branch = self._current_branch()
-        return self._branch_from_ref(self.read_git_config('branch.%s.merge' % current_branch, cwd=self.checkout_root, executive=self._executive).strip())
+        return self._branch_from_ref(self.read_config('branch.%s.merge' % current_branch).strip())
 
     def merge_base(self, git_commit):
         if git_commit:
@@ -406,7 +415,7 @@ class Git(SCM, SVNRepository):
         self._run_git(['checkout', 'HEAD'] + file_paths)
 
     def _assert_can_squash(self, has_working_directory_changes):
-        squash = self.read_git_config('webkit-patch.commit-should-always-squash', cwd=self.checkout_root, executive=self._executive)
+        squash = self.read_config('webkit-patch.commit-should-always-squash')
         should_squash = squash and squash.lower() == "true"
 
         if not should_squash:
@@ -518,7 +527,7 @@ class Git(SCM, SVNRepository):
 
     def remote_branch_ref(self):
         # Use references so that we can avoid collisions, e.g. we don't want to operate on refs/heads/trunk if it exists.
-        remote_branch_refs = self.read_git_config('svn-remote.svn.fetch', cwd=self.checkout_root, executive=self._executive)
+        remote_branch_refs = self.read_config('svn-remote.svn.fetch')
         if not remote_branch_refs:
             remote_master_ref = 'refs/remotes/origin/master'
             if not self.branch_ref_exists(remote_master_ref):
index 2fa58ba..ec189b5 100644 (file)
@@ -1142,6 +1142,49 @@ class GitSVNTest(SCMTest):
         run_command(['git', 'config', key, value])
         self.assertEqual(self.scm.read_git_config(key), value)
 
+        value = 'true'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+
+        value = 'yes'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, bool), 'true')
+
+        value = 'oN'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, bool), 'true')
+
+        value = '1'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, bool), 'true')
+
+        value = 'false'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+
+        value = 'no'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, bool), 'false')
+
+        value = 'oFf'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, bool), 'false')
+
+        value = '0'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, bool), 'false')
+
+        value = '1k'
+        run_command(['git', 'config', key, value])
+        self.assertEqual(self.scm.read_git_config(key), value)
+        self.assertEqual(self.scm.read_git_config(key, int), '1024')
+
     def test_local_commits(self):
         test_file = os.path.join(self.git_checkout_path, 'test_file')
         write_into_file_at_path(test_file, 'foo')
index 8a7b2fb..4530782 100644 (file)
@@ -21,6 +21,15 @@ import select
 import subprocess
 import sys
 
+tools_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'Tools', 'Scripts'))
+if tools_dir not in sys.path:
+    sys.path.insert(0, tools_dir)
+
+from webkitpy.common.checkout.scm import Git
+from webkitpy.common.checkout.scm.detection import SCMDetector
+from webkitpy.common.system.executive import Executive
+from webkitpy.common.system.filesystem import FileSystem
+
 top_level_dir = None
 build_dir = None
 library_build_dir = None
@@ -75,9 +84,19 @@ def get_build_path(fatal=True):
     if is_valid_build_directory(build_dir):
         return build_dir
 
+    base_build_dir = top_level_path('WebKitBuild')
+
+    scm = SCMDetector(FileSystem(), Executive()).default_scm()
+    if isinstance(scm, Git):
+        is_branch_build = scm.read_config('core.webKitBranchBuild', bool)
+        if is_branch_build and is_branch_build.lower() == 'true':
+            current_branch = scm._current_branch()
+            if current_branch != 'master':
+                base_build_dir = os.path.join(base_build_dir, scm._current_branch())
+
     global build_types
     for build_type in build_types:
-        build_dir = top_level_path('WebKitBuild', build_type)
+        build_dir = os.path.join(base_build_dir, build_type)
         if is_valid_build_directory(build_dir):
             return build_dir
 
@@ -90,7 +109,7 @@ def get_build_path(fatal=True):
     if is_valid_build_directory(build_dir):
         return build_dir
 
-    build_dir = top_level_path("WebKitBuild")
+    build_dir = base_build_dir
     if is_valid_build_directory(build_dir):
         return build_dir