def testChromeSpecWithGclientTemplate(self): """Test WriteConfigFile with chrome checkout with a gclient template.""" template_path = self._CreateGclientTemplate("""solutions = [ { 'name': 'src', 'custom_deps': {'dep1': '1'}, 'custom_vars': {'var1': 'test1', 'var2': 'test2'}, }, { 'name': 'no-vars', 'custom_deps': {'dep2': '2', 'dep3': '3'} }, { 'name': 'no-deps', 'custom_vars': {'var3': 'a', 'var4': 'b'} } ]""") gclient.WriteConfigFile('gclient', self._TEST_CWD, True, '7becbe4afb42b3301d42149d7d1cade017f150ff', template=template_path) self._AssertGclientConfigSpec( """solutions = [{'custom_deps': {'dep1': '1'}, 'custom_vars': {'var1': 'test1', 'var2': 'test2'}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git@7becbe4afb42b3301d42149d7d1cade017f150ff'}, {'custom_deps': {'dep2': '2', 'dep3': '3'}, 'name': 'no-vars'}, {'custom_vars': {'var3': 'a', 'var4': 'b'}, 'name': 'no-deps'}, {'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src-internal', 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git'}] """)
def SyncChrome(gclient_path, options): """Sync new Chrome.""" gclient.WriteConfigFile(gclient_path, options.chrome_root, options.internal, options.version, options.gclient_template, options.use_cache) gclient.Sync(gclient_path, options.chrome_root, reset=options.reset, ignore_locks=options.ignore_locks)
def testChromiumSpec(self): """Test WriteConfigFile with chromium checkout and no revision.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, False, None) self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}] """)
def testChromeSpecWithReleaseTagDepsGit(self): """Test WriteConfigFile with chrome checkout at a given release tag.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, True, '41.0.2270.0') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': 'releases/41.0.2270.0/.DEPS.git', 'managed': True, 'name': 'CHROME_DEPS', 'url': 'https://chrome-internal.googlesource.com/chrome/tools/buildspec.git'}] """)
def SyncChrome(gclient_path, options): """Sync new Chrome.""" gclient.WriteConfigFile(gclient_path, options.chrome_root, options.internal, options.version, options.gclient_template, options.use_cache, git_cache_dir=options.git_cache_dir) gclient.Sync(gclient_path, options.chrome_root, reset=options.reset)
def testChromiumSpecWithGitHash(self): """Test WriteConfigFile with chromium checkout at a given git revision.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, False, '7becbe4afb42b3301d42149d7d1cade017f150ff') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git@7becbe4afb42b3301d42149d7d1cade017f150ff'}] """)
def testChromiumSpecWithReleaseTag(self): """Test WriteConfigFile with chromium checkout at a given release tag.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, False, '41.0.2270.0') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git@refs/tags/41.0.2270.0'}] """)
def testChromiumSpecWithGitHead(self): """Test WriteConfigFile with chromium checkout at a given git revision.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, False, 'HEAD') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git@HEAD'}] target_os = ['chromeos'] """)
def testChromeSpecWithReleaseTag(self): """Test WriteConfigFile with chrome checkout at a given release tag.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, True, '45.0.2431.1') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': 'releases/45.0.2431.1/DEPS', 'managed': True, 'name': 'CHROME_DEPS', 'url': 'https://chrome-internal.googlesource.com/chrome/tools/buildspec.git'}] target_os = ['chromeos'] cache_dir = '/b/git-cache' """)
def testChromiumSpecCustomInvalidCacheDir(self): """Test WriteConfigFile with chromium checkout and no revision.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, False, None, git_cache_dir='/doesnotexist') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}] target_os = ['chromeos'] cache_dir = '/tmp/git-cache' """)
def main(args): parser = GetParser() options = parser.parse_args(args) # Revert any lingering local changes. if not osutils.SafeMakedirs(options.chrome_root) and options.reset: try: gclient.Revert(options.gclient, options.chrome_root) except cros_build_lib.RunCommandError: osutils.RmDir(options.chrome_root) osutils.SafeMakedirs(options.chrome_root) # Sync new Chrome. gclient.WriteConfigFile(options.gclient, options.chrome_root, options.internal, options.pdf, options.version) gclient.Sync(options.gclient, options.chrome_root, options.reset) return 0
def testChromeSpec(self): """Test WriteConfigFile with chrome checkout and no revision.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, True, None) self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}, {'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src-internal', 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git'}] target_os = ['chromeos'] cache_dir = '/b/git-cache' """)
def testChromeSpecWithGitHash(self): """Test WriteConfigFile with chrome checkout at a given git revision.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, True, '7becbe4afb42b3301d42149d7d1cade017f150ff') self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git@7becbe4afb42b3301d42149d7d1cade017f150ff'}, {'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': True, 'name': 'src-internal', 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git'}] target_os = ['chromeos'] cache_dir = '/b/git-cache' """)
def main(args): parser = GetParser() options = parser.parse_args(args) # Revert any lingering local changes. if not osutils.SafeMakedirs(options.chrome_root) and options.reset: try: gclient.Revert(options.gclient, options.chrome_root) except cros_build_lib.RunCommandError: osutils.RmDir(options.chrome_root) osutils.SafeMakedirs(options.chrome_root) # Sync new Chrome. gclient.WriteConfigFile(options.gclient, options.chrome_root, options.internal, options.pdf, options.version) sync_fn = functools.partial(gclient.Sync, options.gclient, options.chrome_root, reset=options.reset) # Sync twice when run with --reset, which implies 'gclient sync -D'. # # There's a bug with 'gclient sync -D' that gets hit when the location of a # dependency checkout (in the DEPS file) is moved to a path that contains # (in a directory fashion) its old path. E.g., when Blink is moved from # Webkit/Source/ to Webkit/. When this happens, a 'gclient sync -D' will # blow away Webkit/Source/ after the sync, since it is no longer in the # DEPS file, leaving the Blink checkout missing a Source/ subdirectory. # # This bug also gets hit the other way around - E.g., if Blink moves from # Webkit/ to Webkit/Source/. # # To work around this, we sync twice, so that any directories deleted by # the first sync will be restored in the second. # # TODO(rcui): Remove this workaround when the bug is fixed in gclient, or # replace with a more sophisticated solution that syncs twice only when any # paths in the DEPS file cannot be found after initial sync. if options.reset: sync_fn() sync_fn() return 0
def testChromeSpecWithGitHashNoManaged(self): """Like testChromeSpecWithGitHash() but with "managed" sets to False.""" gclient.WriteConfigFile('gclient', self._TEST_CWD, True, '7becbe4afb42b3301d42149d7d1cade017f150ff', managed=False) self._AssertGclientConfigSpec("""solutions = [{'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': False, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git@7becbe4afb42b3301d42149d7d1cade017f150ff'}, {'custom_deps': {}, 'custom_vars': {}, 'deps_file': '.DEPS.git', 'managed': False, 'name': 'src-internal', 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git'}] target_os = ['chromeos'] """)
def SetUp(self): """Sets up Chromium repo. It skips repo set up if reuse_repo is set and repo exists. Setup steps: 1. Make sure chromium_dir doesn't exist. 2. mkdir chromium_dir and cd to it 3. Run "fetch --nohooks chromium" 4. Set up gclient config ('managed' set to False) 5. In chromium_dir/src, run "git pull origin master" 6. "gclient sync --nohooks" """ if self.reuse_repo and os.path.exists(self.repo_dir): if git.IsGitRepo(self.repo_dir): return else: raise Exception( 'Chromium repo broken. Please manually remove it: %s' % self.chromium_dir) if os.path.exists(self.chromium_dir): raise Exception( 'Chromium repo exists. Please manually remove it: %s' % self.chromium_dir) osutils.SafeMakedirs(self.chromium_dir) cros_build_lib.RunCommand(['fetch', '--nohooks', 'chromium'], cwd=self.chromium_dir, log_output=True) # 'managed' should be set to False. Otherwise, 'gclient sync' will call # 'git pull' to ruin bisecting point. gclient.WriteConfigFile(self.gclient, self.chromium_dir, True, None, managed=False) # Need to perform git pull before gclient sync when managed is set to False. git.RunGit(self.repo_dir, ['pull', 'origin', 'master']) self.GclientSync(reset=True, nohooks=True)