Improve testing with File() keyword, found a few bugs along the way

TEST=new smoke tests

Review URL: http://codereview.chromium.org/2865039

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@51824 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 15 years ago
parent 5248d9dfe3
commit e3216c6e26

@ -115,7 +115,7 @@ class GClientKeywords(object):
class FileImpl(object): class FileImpl(object):
"""Used to implement the File('') syntax which lets you sync a single file """Used to implement the File('') syntax which lets you sync a single file
from an SVN repo.""" from a SVN repo."""
def __init__(self, file_location): def __init__(self, file_location):
self.file_location = file_location self.file_location = file_location
@ -621,11 +621,13 @@ solutions = [
scm.RunCommand(command, self._options, args, file_list) scm.RunCommand(command, self._options, args, file_list)
self._options.revision = None self._options.revision = None
elif isinstance(deps[d], self.FileImpl): elif isinstance(deps[d], self.FileImpl):
if command in (None, 'cleanup', 'diff', 'pack', 'status'):
continue
file_dep = deps[d] file_dep = deps[d]
self._options.revision = file_dep.GetRevision() self._options.revision = file_dep.GetRevision()
if run_scm: if run_scm:
scm = gclient_scm.CreateSCM(file_dep.GetPath(), self.root_dir(), d) scm = gclient_scm.SVNWrapper(file_dep.GetPath(), self.root_dir(), d)
scm.RunCommand("updatesingle", self._options, scm.RunCommand('updatesingle', self._options,
args + [file_dep.GetFilename()], file_list) args + [file_dep.GetFilename()], file_list)
if command == 'update' and not self._options.verbose: if command == 'update' and not self._options.verbose:
@ -1167,6 +1169,8 @@ def Main(argv):
logging.basicConfig(level=level, logging.basicConfig(level=level,
format='%(module)s(%(lineno)d) %(funcName)s:%(message)s') format='%(module)s(%(lineno)d) %(funcName)s:%(message)s')
options.entries_filename = options.config_filename + '_entries' options.entries_filename = options.config_filename + '_entries'
# These hacks need to die.
if not hasattr(options, 'revisions'): if not hasattr(options, 'revisions'):
# GClient.RunOnDeps expects it even if not applicable. # GClient.RunOnDeps expects it even if not applicable.
options.revisions = [] options.revisions = []
@ -1176,6 +1180,10 @@ def Main(argv):
options.nohooks = True options.nohooks = True
if not hasattr(options, 'deps_os'): if not hasattr(options, 'deps_os'):
options.deps_os = None options.deps_os = None
if not hasattr(options, 'manually_grab_svn_rev'):
options.manually_grab_svn_rev = None
if not hasattr(options, 'force'):
options.force = None
return (options, args) return (options, args)
parser.parse_args = Parse parser.parse_args = Parse
# We don't want wordwrapping in epilog (usually examples) # We don't want wordwrapping in epilog (usually examples)

@ -338,8 +338,8 @@ class FakeRepos(object):
# - var # - var
# - hooks # - hooks
# - From # - From
# TODO(maruel):
# - File # - File
# TODO(maruel):
# - $matching_files # - $matching_files
# - use_relative_paths # - use_relative_paths
fs = file_system(1, """ fs = file_system(1, """
@ -360,8 +360,8 @@ deps_os = {
fs = file_system(2, """ fs = file_system(2, """
deps = { deps = {
'src/other': 'svn://%(host)s/svn/trunk/other', 'src/other': 'svn://%(host)s/svn/trunk/other',
#'src/third_party/foo': '/trunk/third_party/foo@1',
'src/third_party/foo': From('src/other', 'foo/bar'), 'src/third_party/foo': From('src/other', 'foo/bar'),
'src/file/foo': File('svn://%(host)s/svn/trunk/third_party/foo/origin'),
} }
# I think this is wrong to have the hooks run from the base of the gclient # I think this is wrong to have the hooks run from the base of the gclient
# checkout. It's maybe a bit too late to change that behavior. # checkout. It's maybe a bit too late to change that behavior.
@ -407,7 +407,8 @@ deps = {
# - hooks # - hooks
# - From # - From
# TODO(maruel): # TODO(maruel):
# - File # - File: File is hard to test here because it's SVN-only. It's
# implementation should probably be replaced to use urllib instead.
# - $matching_files # - $matching_files
# - use_relative_paths # - use_relative_paths
self._commit_git('repo_3', { self._commit_git('repo_3', {

@ -204,11 +204,16 @@ class GClientSmokeSVN(GClientSmokeBase):
self.gclient(['config', self.svn_base + 'trunk/src/']) self.gclient(['config', self.svn_base + 'trunk/src/'])
# Test unversioned checkout. # Test unversioned checkout.
self.parseGclient(['sync', '--deps', 'mac'], self.parseGclient(['sync', '--deps', 'mac'],
['running', 'running', 'running', 'running']) ['running', 'running',
# This is due to the way svn update is called for a
# single file when File() is used in a DEPS file.
('running', self.root_dir + '/src/file/foo'),
'running', 'running', 'running', 'running'])
tree = self.mangle_svn_tree( tree = self.mangle_svn_tree(
('trunk/src@2', 'src'), ('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'), ('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other')) ('trunk/other@2', 'src/other'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/svn_hooked1'] = 'svn_hooked1' tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree) self.assertTree(tree)
@ -225,16 +230,18 @@ class GClientSmokeSVN(GClientSmokeBase):
('trunk/third_party/foo@2', 'src/third_party/fpp'), ('trunk/third_party/foo@2', 'src/third_party/fpp'),
('trunk/other@1', 'src/other'), ('trunk/other@1', 'src/other'),
('trunk/third_party/foo@2', 'src/third_party/prout')) ('trunk/third_party/foo@2', 'src/third_party/prout'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
self.assertTree(tree) self.assertTree(tree)
# Test incremental sync: delete-unversioned_trees isn't there. # Test incremental sync: delete-unversioned_trees isn't there.
self.parseGclient(['sync', '--deps', 'mac'], self.parseGclient(['sync', '--deps', 'mac'],
['running', 'running', 'running', 'running']) ['running', 'running', 'running', 'running', 'running'])
tree = self.mangle_svn_tree( tree = self.mangle_svn_tree(
('trunk/src@2', 'src'), ('trunk/src@2', 'src'),
('trunk/third_party/foo@2', 'src/third_party/fpp'), ('trunk/third_party/foo@2', 'src/third_party/fpp'),
('trunk/third_party/foo@1', 'src/third_party/foo'), ('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other'), ('trunk/other@2', 'src/other'),
('trunk/third_party/foo@2', 'src/third_party/prout')) ('trunk/third_party/foo@2', 'src/third_party/prout'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/svn_hooked1'] = 'svn_hooked1' tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree) self.assertTree(tree)
@ -242,7 +249,12 @@ class GClientSmokeSVN(GClientSmokeBase):
"""TODO(maruel): This will become an error soon.""" """TODO(maruel): This will become an error soon."""
self.gclient(['config', self.svn_base + 'trunk/src/']) self.gclient(['config', self.svn_base + 'trunk/src/'])
results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1']) results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1'])
self.checkBlock(results[0], ['running', 'running', 'running', 'running']) self.checkBlock(results[0], [
'running', 'running',
# This is due to the way svn update is called for a single file when
# File() is used in a DEPS file.
('running', self.root_dir + '/src/file/foo'),
'running', 'running', 'running', 'running'])
self.checkString('Please fix your script, having invalid --revision flags ' self.checkString('Please fix your script, having invalid --revision flags '
'will soon considered an error.\n', results[1]) 'will soon considered an error.\n', results[1])
self.assertEquals(0, results[2]) self.assertEquals(0, results[2])
@ -250,6 +262,7 @@ class GClientSmokeSVN(GClientSmokeBase):
('trunk/src@2', 'src'), ('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'), ('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other')) ('trunk/other@2', 'src/other'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/svn_hooked1'] = 'svn_hooked1' tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree) self.assertTree(tree)
@ -275,11 +288,12 @@ class GClientSmokeSVN(GClientSmokeBase):
[['running', join(self.root_dir, 'src')], [['running', join(self.root_dir, 'src')],
['running', join(self.root_dir, 'src', 'other')]]) ['running', join(self.root_dir, 'src', 'other')]])
out = self.svnBlockCleanup(out) out = self.svnBlockCleanup(out)
self.checkString('other', out[0][1]) self.checkString('file', out[0][1])
self.checkString('svn_hooked1', out[0][2]) self.checkString('other', out[0][2])
self.checkString(join('third_party', 'foo'), out[0][3]) self.checkString('svn_hooked1', out[0][3])
self.checkString(join('third_party', 'foo'), out[0][4])
self.checkString('hi', out[1][1]) self.checkString('hi', out[1][1])
self.assertEquals(4, len(out[0])) self.assertEquals(5, len(out[0]))
self.assertEquals(2, len(out[1])) self.assertEquals(2, len(out[1]))
# Revert implies --force implies running hooks without looking at pattern # Revert implies --force implies running hooks without looking at pattern
@ -287,14 +301,15 @@ class GClientSmokeSVN(GClientSmokeBase):
results = self.gclient(['revert', '--deps', 'mac']) results = self.gclient(['revert', '--deps', 'mac'])
out = self.splitBlock(results[0]) out = self.splitBlock(results[0])
# src, src/other is missing, src/other, src/third_party/foo is missing, # src, src/other is missing, src/other, src/third_party/foo is missing,
# src/third_party/foo, 2 svn hooks. # src/third_party/foo, 2 svn hooks, 3 related to File().
self.assertEquals(7, len(out)) self.assertEquals(10, len(out))
self.checkString('', results[1]) self.checkString('', results[1])
self.assertEquals(0, results[2]) self.assertEquals(0, results[2])
tree = self.mangle_svn_tree( tree = self.mangle_svn_tree(
('trunk/src@2', 'src'), ('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'), ('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other')) ('trunk/other@2', 'src/other'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/svn_hooked1'] = 'svn_hooked1' tree['src/svn_hooked1'] = 'svn_hooked1'
tree['src/svn_hooked2'] = 'svn_hooked2' tree['src/svn_hooked2'] = 'svn_hooked2'
self.assertTree(tree) self.assertTree(tree)
@ -302,11 +317,13 @@ class GClientSmokeSVN(GClientSmokeBase):
out = self.parseGclient(['status', '--deps', 'mac'], out = self.parseGclient(['status', '--deps', 'mac'],
[['running', join(self.root_dir, 'src')]]) [['running', join(self.root_dir, 'src')]])
out = self.svnBlockCleanup(out) out = self.svnBlockCleanup(out)
self.checkString('other', out[0][1]) self.checkString('file', out[0][1])
self.checkString('svn_hooked1', out[0][2]) self.checkString('other', out[0][2])
self.checkString('svn_hooked2', out[0][3]) self.checkString('svn_hooked1', out[0][3])
self.checkString(join('third_party', 'foo'), out[0][4]) self.checkString('svn_hooked2', out[0][4])
self.assertEquals(5, len(out[0])) self.checkString(join('third_party', 'foo'), out[0][5])
self.assertEquals(6, len(out[0]))
self.assertEquals(1, len(out))
def testRevertAndStatusDepsOs(self): def testRevertAndStatusDepsOs(self):
self.gclient(['config', self.svn_base + 'trunk/src/']) self.gclient(['config', self.svn_base + 'trunk/src/'])
@ -592,7 +609,11 @@ class GClientSmokeBoth(GClientSmokeBase):
results = self.gclient(['sync', '--deps', 'mac']) results = self.gclient(['sync', '--deps', 'mac'])
# 3x svn checkout, 3x run hooks # 3x svn checkout, 3x run hooks
self.checkBlock(results[0], self.checkBlock(results[0],
['running', 'running', 'running', 'running', 'running', ['running', 'running',
# This is due to the way svn update is called for a single
# file when File() is used in a DEPS file.
('running', self.root_dir + '/src/file/foo'),
'running', 'running', 'running', 'running', 'running',
'running', 'running']) 'running', 'running'])
# TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to
# new branch \'hash\''. # new branch \'hash\''.
@ -605,6 +626,7 @@ class GClientSmokeBoth(GClientSmokeBase):
('trunk/src@2', 'src'), ('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'), ('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other'))) ('trunk/other@2', 'src/other')))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/git_hooked1'] = 'git_hooked1' tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2' tree['src/git_hooked2'] = 'git_hooked2'
tree['src/svn_hooked1'] = 'svn_hooked1' tree['src/svn_hooked1'] = 'svn_hooked1'

Loading…
Cancel
Save