Commit e3216c6e authored by maruel@chromium.org's avatar maruel@chromium.org

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
parent 5248d9df
......@@ -115,7 +115,7 @@ class GClientKeywords(object):
class FileImpl(object):
"""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):
self.file_location = file_location
......@@ -621,11 +621,13 @@ solutions = [
scm.RunCommand(command, self._options, args, file_list)
self._options.revision = None
elif isinstance(deps[d], self.FileImpl):
if command in (None, 'cleanup', 'diff', 'pack', 'status'):
continue
file_dep = deps[d]
self._options.revision = file_dep.GetRevision()
if run_scm:
scm = gclient_scm.CreateSCM(file_dep.GetPath(), self.root_dir(), d)
scm.RunCommand("updatesingle", self._options,
scm = gclient_scm.SVNWrapper(file_dep.GetPath(), self.root_dir(), d)
scm.RunCommand('updatesingle', self._options,
args + [file_dep.GetFilename()], file_list)
if command == 'update' and not self._options.verbose:
......@@ -1167,6 +1169,8 @@ def Main(argv):
logging.basicConfig(level=level,
format='%(module)s(%(lineno)d) %(funcName)s:%(message)s')
options.entries_filename = options.config_filename + '_entries'
# These hacks need to die.
if not hasattr(options, 'revisions'):
# GClient.RunOnDeps expects it even if not applicable.
options.revisions = []
......@@ -1176,6 +1180,10 @@ def Main(argv):
options.nohooks = True
if not hasattr(options, 'deps_os'):
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)
parser.parse_args = Parse
# We don't want wordwrapping in epilog (usually examples)
......
......@@ -338,8 +338,8 @@ class FakeRepos(object):
# - var
# - hooks
# - From
# TODO(maruel):
# - File
# TODO(maruel):
# - $matching_files
# - use_relative_paths
fs = file_system(1, """
......@@ -360,8 +360,8 @@ deps_os = {
fs = file_system(2, """
deps = {
'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/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
# checkout. It's maybe a bit too late to change that behavior.
......@@ -407,7 +407,8 @@ deps = {
# - hooks
# - From
# 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
# - use_relative_paths
self._commit_git('repo_3', {
......
......@@ -204,11 +204,16 @@ class GClientSmokeSVN(GClientSmokeBase):
self.gclient(['config', self.svn_base + 'trunk/src/'])
# Test unversioned checkout.
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(
('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree)
......@@ -225,16 +230,18 @@ class GClientSmokeSVN(GClientSmokeBase):
('trunk/third_party/foo@2', 'src/third_party/fpp'),
('trunk/other@1', 'src/other'),
('trunk/third_party/foo@2', 'src/third_party/prout'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
self.assertTree(tree)
# Test incremental sync: delete-unversioned_trees isn't there.
self.parseGclient(['sync', '--deps', 'mac'],
['running', 'running', 'running', 'running'])
['running', 'running', 'running', 'running', 'running'])
tree = self.mangle_svn_tree(
('trunk/src@2', 'src'),
('trunk/third_party/foo@2', 'src/third_party/fpp'),
('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other'),
('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'
self.assertTree(tree)
......@@ -242,7 +249,12 @@ class GClientSmokeSVN(GClientSmokeBase):
"""TODO(maruel): This will become an error soon."""
self.gclient(['config', self.svn_base + 'trunk/src/'])
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 '
'will soon considered an error.\n', results[1])
self.assertEquals(0, results[2])
......@@ -250,6 +262,7 @@ class GClientSmokeSVN(GClientSmokeBase):
('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'),
('trunk/other@2', 'src/other'))
tree['src/file/foo/origin'] = 'svn/trunk/third_party/foo@2\n'
tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree)
......@@ -275,11 +288,12 @@ class GClientSmokeSVN(GClientSmokeBase):
[['running', join(self.root_dir, 'src')],
['running', join(self.root_dir, 'src', 'other')]])
out = self.svnBlockCleanup(out)
self.checkString('other', out[0][1])
self.checkString('svn_hooked1', out[0][2])
self.checkString(join('third_party', 'foo'), out[0][3])
self.checkString('file', out[0][1])
self.checkString('other', out[0][2])
self.checkString('svn_hooked1', out[0][3])
self.checkString(join('third_party', 'foo'), out[0][4])
self.checkString('hi', out[1][1])
self.assertEquals(4, len(out[0]))
self.assertEquals(5, len(out[0]))
self.assertEquals(2, len(out[1]))
# Revert implies --force implies running hooks without looking at pattern
......@@ -287,14 +301,15 @@ class GClientSmokeSVN(GClientSmokeBase):
results = self.gclient(['revert', '--deps', 'mac'])
out = self.splitBlock(results[0])
# src, src/other is missing, src/other, src/third_party/foo is missing,
# src/third_party/foo, 2 svn hooks.
self.assertEquals(7, len(out))
# src/third_party/foo, 2 svn hooks, 3 related to File().
self.assertEquals(10, len(out))
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = self.mangle_svn_tree(
('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'),
('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_hooked2'] = 'svn_hooked2'
self.assertTree(tree)
......@@ -302,11 +317,13 @@ class GClientSmokeSVN(GClientSmokeBase):
out = self.parseGclient(['status', '--deps', 'mac'],
[['running', join(self.root_dir, 'src')]])
out = self.svnBlockCleanup(out)
self.checkString('other', out[0][1])
self.checkString('svn_hooked1', out[0][2])
self.checkString('svn_hooked2', out[0][3])
self.checkString(join('third_party', 'foo'), out[0][4])
self.assertEquals(5, len(out[0]))
self.checkString('file', out[0][1])
self.checkString('other', out[0][2])
self.checkString('svn_hooked1', out[0][3])
self.checkString('svn_hooked2', out[0][4])
self.checkString(join('third_party', 'foo'), out[0][5])
self.assertEquals(6, len(out[0]))
self.assertEquals(1, len(out))
def testRevertAndStatusDepsOs(self):
self.gclient(['config', self.svn_base + 'trunk/src/'])
......@@ -592,7 +609,11 @@ class GClientSmokeBoth(GClientSmokeBase):
results = self.gclient(['sync', '--deps', 'mac'])
# 3x svn checkout, 3x run hooks
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'])
# TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to
# new branch \'hash\''.
......@@ -605,6 +626,7 @@ class GClientSmokeBoth(GClientSmokeBase):
('trunk/src@2', 'src'),
('trunk/third_party/foo@1', 'src/third_party/foo'),
('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_hooked2'] = 'git_hooked2'
tree['src/svn_hooked1'] = 'svn_hooked1'
......@@ -675,7 +697,7 @@ class GClientSmokeBoth(GClientSmokeBase):
self.gclient(['sync', '--deps', 'mac'])
results = self.gclient(['recurse', 'sh', '-c',
'echo $GCLIENT_SCM,$GCLIENT_URL,`pwd`'])
entries = [tuple(line.split(','))
for line in results[0].strip().split('\n')]
logging.debug(entries)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment