Пример #1
0
 def testDifferentTopLevelDirectory(self):
   # Check that even if the .gclient file does not mention the directory src
   # itself, but it is included via dependencies, the .gclient file is used.
   self.gclient(['config', self.svn_base + 'trunk/src.DEPS'])
   deps = join(self.root_dir, 'src.DEPS')
   os.mkdir(deps)
   write(join(deps, 'DEPS'),
       'deps = { "src": "%strunk/src" }' % (self.svn_base))
   src = join(self.root_dir, 'src')
   os.mkdir(src)
   res = self.gclient(['status', '--jobs', '1'], src)
   self.checkBlock(res[0], [('running', deps), ('running', src)])
Пример #2
0
 def testDifferentTopLevelDirectory(self):
   # Check that even if the .gclient file does not mention the directory src
   # itself, but it is included via dependencies, the .gclient file is used.
   self.gclient(['config', self.svn_base + 'trunk/src.DEPS'])
   deps = join(self.root_dir, 'src.DEPS')
   os.mkdir(deps)
   write(join(deps, 'DEPS'),
       'deps = { "src": "%strunk/src" }' % (self.svn_base))
   src = join(self.root_dir, 'src')
   os.mkdir(src)
   res = self.gclient(['status', '--jobs', '1'], src)
   self.checkBlock(res[0], [('running', deps), ('running', src)])
Пример #3
0
 def testDifferentTopLevelDirectory(self):
     # Check that even if the .gclient file does not mention the directory src
     # itself, but it is included via dependencies, the .gclient file is used.
     self.gclient(['config', self.git_base + 'src.DEPS'])
     deps = join(self.root_dir, 'src.DEPS')
     os.mkdir(deps)
     subprocess2.check_output(['git', 'init'], cwd=deps)
     write(join(deps, 'DEPS'),
           'deps = { "src": "%ssrc" }' % (self.git_base))
     subprocess2.check_output(['git', 'add', 'DEPS'], cwd=deps)
     subprocess2.check_output(['git', 'commit', '-a', '-m', 'DEPS file'],
                              cwd=deps)
     src = join(self.root_dir, 'src')
     os.mkdir(src)
     subprocess2.check_output(['git', 'init'], cwd=src)
     res = self.gclient(['status', '--jobs', '1', '-v'], src)
     self.checkBlock(res[0], [('running', deps), ('running', src)])
Пример #4
0
    def testRevertAndStatus(self):
        # Commit new change to repo to make repo_2's hash use a custom_var.
        cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS']
        repo_2_hash = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7]
        new_deps = cur_deps.replace('repo_2@%s\'' % repo_2_hash,
                                    'repo_2@\' + Var(\'r2hash\')')
        new_deps = 'vars = {\'r2hash\': \'%s\'}\n%s' % (repo_2_hash, new_deps)
        self.FAKE_REPOS._commit_git('repo_1', {  # pylint: disable=protected-access
          'DEPS': new_deps,
          'origin': 'git/repo_1@3\n',
        })

        config_template = ''.join([
            'solutions = [{'
            '  "name"        : "src",'
            '  "url"         : %(git_base)r + "repo_1",'
            '  "deps_file"   : "DEPS",'
            '  "managed"     : True,'
            '  "custom_vars" : %(custom_vars)s,'
            '}]'
        ])

        self.gclient([
            'config', '--spec', config_template % {
                'git_base': self.git_base,
                'custom_vars': {}
            }
        ])

        # Tested in testSync.
        self.gclient(['sync', '--deps', 'mac'])
        write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!')

        out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], [])
        # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
        # files.
        self.assertEqual(0, len(out))

        # Revert implies --force implies running hooks without looking at pattern
        # matching. For each expected path, 'git reset' and 'git clean' are run, so
        # there should be two results for each. The last two results should reflect
        # writing git_hooked1 and git_hooked2. There's only one result for the third
        # because it is clean and has no output for 'git clean'.
        out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
                                ['running', 'running'])
        self.assertEqual(2, len(out))
        tree = self.mangle_git_tree(('repo_1@3', 'src'),
                                    ('repo_2@1', 'src/repo2'),
                                    ('repo_3@2', 'src/repo2/repo_renamed'))
        tree['src/git_hooked1'] = 'git_hooked1'
        tree['src/git_hooked2'] = 'git_hooked2'
        self.assertTree(tree)

        # Make a new commit object in the origin repo, to force reset to fetch.
        self.FAKE_REPOS._commit_git('repo_2', {  # pylint: disable=protected-access
          'origin': 'git/repo_2@3\n',
        })

        self.gclient([
            'config', '--spec', config_template % {
                'git_base': self.git_base,
                'custom_vars': {
                    'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0]
                }
            }
        ])
        out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
                                ['running', 'running'])
        self.assertEqual(2, len(out))
        tree = self.mangle_git_tree(('repo_1@3', 'src'),
                                    ('repo_2@3', 'src/repo2'),
                                    ('repo_3@2', 'src/repo2/repo_renamed'))
        tree['src/git_hooked1'] = 'git_hooked1'
        tree['src/git_hooked2'] = 'git_hooked2'
        self.assertTree(tree)

        results = self.gclient(['status', '--deps', 'mac', '--jobs', '1'])
        out = results[0].splitlines(False)
        # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
        # files.
        self.assertEqual(0, len(out))
Пример #5
0
  def testRevertAndStatus(self):
    if not self.enabled:
      return

    # Commit new change to repo to make repo_2's hash use a custom_var.
    cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS']
    repo_2_hash = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7]
    new_deps = cur_deps.replace('repo_2@%s\'' % repo_2_hash,
                                'repo_2@\' + Var(\'r2hash\')')
    new_deps = 'vars = {\'r2hash\': \'%s\'}\n%s' % (repo_2_hash, new_deps)
    self.FAKE_REPOS._commit_git('repo_1', {  # pylint: disable=W0212
      'DEPS': new_deps,
      'origin': 'git/repo_1@3\n',
    })

    config_template = (
"""solutions = [{
  "name"        : "src",
  "url"         : "%(git_base)srepo_1",
  "deps_file"   : "DEPS",
  "managed"     : True,
  "custom_vars" : %(custom_vars)s,
}]""")

    self.gclient(['config', '--spec', config_template % {
      'git_base': self.git_base,
      'custom_vars': {}
    }])

    # Tested in testSync.
    self.gclient(['sync', '--deps', 'mac'])
    write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!')

    out = self.parseGclient(['status', '--deps', 'mac', '--jobs', '1'], [])
    # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
    # files.
    self.assertEquals(0, len(out))

    # Revert implies --force implies running hooks without looking at pattern
    # matching. For each expected path, 'git reset' and 'git clean' are run, so
    # there should be two results for each. The last two results should reflect
    # writing git_hooked1 and git_hooked2. There's only one result for the third
    # because it is clean and has no output for 'git clean'.
    out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
                            ['running', 'running'])
    self.assertEquals(2, len(out))
    tree = self.mangle_git_tree(('repo_1@3', 'src'),
                                ('repo_2@1', 'src/repo2'),
                                ('repo_3@2', 'src/repo2/repo_renamed'))
    tree['src/git_hooked1'] = 'git_hooked1'
    tree['src/git_hooked2'] = 'git_hooked2'
    self.assertTree(tree)

    # Make a new commit object in the origin repo, to force reset to fetch.
    self.FAKE_REPOS._commit_git('repo_2', {  # pylint: disable=W0212
      'origin': 'git/repo_2@3\n',
    })

    self.gclient(['config', '--spec', config_template % {
      'git_base': self.git_base,
      'custom_vars': {'r2hash': self.FAKE_REPOS.git_hashes['repo_2'][-1][0] }
    }])
    out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
                            ['running', 'running'])
    self.assertEquals(2, len(out))
    tree = self.mangle_git_tree(('repo_1@3', 'src'),
                                ('repo_2@3', 'src/repo2'),
                                ('repo_3@2', 'src/repo2/repo_renamed'))
    tree['src/git_hooked1'] = 'git_hooked1'
    tree['src/git_hooked2'] = 'git_hooked2'
    self.assertTree(tree)

    results = self.gclient(['status', '--deps', 'mac', '--jobs', '1'])
    out = results[0].splitlines(False)
    # TODO(maruel): http://crosbug.com/3584 It should output the unversioned
    # files.
    self.assertEquals(0, len(out))