Commit 50fd2bd7 authored by maruel@chromium.org's avatar maruel@chromium.org

Fix multiple tests on Windows.

BUG=23328
Review URL: http://codereview.chromium.org/2446001

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@48613 0039d316-1c4b-4281-b951-d872f2087c98
parent 1e3b8f0d
......@@ -6,13 +6,15 @@
"""Generate fake repositories for testing."""
import atexit
import errno
import logging
import os
import pprint
import re
import shutil
import stat
import subprocess
import sys
import time
import unittest
......@@ -35,10 +37,69 @@ def addKill():
subprocess.kill = kill_nix
def rmtree(path):
"""Delete a directory."""
if os.path.exists(path):
shutil.rmtree(path)
def rmtree(*path):
"""Recursively removes a directory, even if it's marked read-only.
Remove the directory located at *path, if it exists.
shutil.rmtree() doesn't work on Windows if any of the files or directories
are read-only, which svn repositories and some .svn files are. We need to
be able to force the files to be writable (i.e., deletable) as we traverse
the tree.
Even with all this, Windows still sometimes fails to delete a file, citing
a permission error (maybe something to do with antivirus scans or disk
indexing). The best suggestion any of the user forums had was to wait a
bit and try again, so we do that too. It's hand-waving, but sometimes it
works. :/
"""
file_path = os.path.join(*path)
if not os.path.exists(file_path):
return
def RemoveWithRetry_win(rmfunc, path):
os.chmod(path, stat.S_IWRITE)
if win32_api_avail:
win32api.SetFileAttributes(path, win32con.FILE_ATTRIBUTE_NORMAL)
try:
return rmfunc(path)
except EnvironmentError, e:
if e.errno != errno.EACCES:
raise
print 'Failed to delete %s: trying again' % repr(path)
time.sleep(0.1)
return rmfunc(path)
def RemoveWithRetry_non_win(rmfunc, path):
if os.path.islink(path):
return os.remove(path)
else:
return rmfunc(path)
win32_api_avail = False
remove_with_retry = None
if sys.platform.startswith('win'):
# Some people don't have the APIs installed. In that case we'll do without.
try:
win32api = __import__('win32api')
win32con = __import__('win32con')
win32_api_avail = True
except ImportError:
pass
remove_with_retry = RemoveWithRetry_win
else:
remove_with_retry = RemoveWithRetry_non_win
for root, dirs, files in os.walk(file_path, topdown=False):
# For POSIX: making the directory writable guarantees removability.
# Windows will ignore the non-read-only bits in the chmod value.
os.chmod(root, 0770)
for name in files:
remove_with_retry(os.remove, os.path.join(root, name))
for name in dirs:
remove_with_retry(os.rmdir, os.path.join(root, name))
remove_with_retry(os.rmdir, file_path)
def write(path, content):
......@@ -69,7 +130,9 @@ def read_tree(tree_root):
for d in filter(lambda x: x.startswith('.'), dirs):
dirs.remove(d)
for f in [join(root, f) for f in files if not f.startswith('.')]:
tree[f[len(tree_root) + 1:]] = open(join(root, f), 'rb').read()
filepath = f[len(tree_root) + 1:].replace(os.sep, '/')
assert len(filepath), f
tree[filepath] = open(join(root, f), 'rU').read()
return tree
......@@ -92,7 +155,7 @@ def mangle_svn_tree(*args):
for k, v in tree.iteritems():
if not k.startswith(old_root):
continue
result[join(new_root, k[len(old_root) + 1:])] = v
result[join(new_root, k[len(old_root) + 1:]).replace(os.sep, '/')] = v
return result
......@@ -330,8 +393,10 @@ hooks = [
def setUpGIT(self):
"""Creates git repositories and start the servers."""
if self.gitdaemon:
return
return True
self.setUp()
if sys.platform == 'win32':
return False
for repo in ['repo_%d' % r for r in range(1, 5)]:
check_call(['git', 'init', '-q', join(self.git_root, repo)])
self.git_hashes[repo] = []
......@@ -424,6 +489,7 @@ hooks = [
cmd.append('--listen=127.0.0.1')
logging.debug(cmd)
self.gitdaemon = Popen(cmd, cwd=self.repos_dir)
return True
def _commit_svn(self, tree):
self._genTree(self.svn_root, tree)
......
......@@ -44,7 +44,8 @@ class GClientSmokeBase(FakeReposTestBase):
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=sys.platform.startswith('win'))
(stdout, stderr) = process.communicate()
return (stdout, stderr, process.returncode)
return (stdout.replace('\r\n', '\n'), stderr.replace('\r\n', '\n'),
process.returncode)
class GClientSmoke(GClientSmokeBase):
......@@ -81,7 +82,7 @@ class GClientSmoke(GClientSmokeBase):
os.remove(p)
results = self.gclient(cmd)
self.check(('', '', 0), results)
self.checkString(expected, open(p, 'rb').read())
self.checkString(expected, open(p, 'rU').read())
test(['config', self.svn_base + 'trunk/src/'],
'solutions = [\n'
......@@ -137,13 +138,12 @@ class GClientSmokeSVN(GClientSmokeBase):
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[-1]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[-1]),
('trunk/third_party/foo', 'src/third_party/foo',
self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'other'), join('src', 'other'),
self.FAKE_REPOS.svn_revs[2]),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
)
tree[join('src', 'svn_hooked1')] = 'svn_hooked1'
tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree)
# Manually remove svn_hooked1 before synching to make sure it's not
......@@ -159,13 +159,11 @@ class GClientSmokeSVN(GClientSmokeBase):
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'),
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'other'), join('src', 'other'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]),
('trunk/third_party/foo', 'src/third_party/fpp',
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'),
join('src', 'third_party', 'prout'),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/prout',
self.FAKE_REPOS.svn_revs[2]),
)
self.assertTree(tree)
......@@ -177,18 +175,16 @@ class GClientSmokeSVN(GClientSmokeBase):
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/fpp',
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'),
('trunk/third_party/foo', 'src/third_party/foo',
self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'other'), join('src', 'other'),
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'),
join('src', 'third_party', 'prout'),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/prout',
self.FAKE_REPOS.svn_revs[2]),
)
tree[join('src', 'svn_hooked1')] = 'svn_hooked1'
tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree)
def testSyncIgnoredSolutionName(self):
......@@ -201,13 +197,12 @@ class GClientSmokeSVN(GClientSmokeBase):
'will soon considered an error.\n', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/foo',
self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'other'), join('src', 'other'),
self.FAKE_REPOS.svn_revs[2]),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
)
tree[join('src', 'svn_hooked1')] = 'svn_hooked1'
tree['src/svn_hooked1'] = 'svn_hooked1'
self.assertTree(tree)
def testSyncNoSolutionName(self):
......@@ -219,13 +214,11 @@ class GClientSmokeSVN(GClientSmokeBase):
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'),
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'other'), join('src', 'other'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]),
('trunk/third_party/foo', 'src/third_party/fpp',
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'),
join('src', 'third_party', 'prout'),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/prout',
self.FAKE_REPOS.svn_revs[2]),
)
self.assertTree(tree)
......@@ -236,13 +229,13 @@ class GClientSmokeSVN(GClientSmokeBase):
self.gclient(['sync', '--deps', 'mac'])
write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!')
results = self.gclient(['status'])
results = self.gclient(['status', '--deps', 'mac'])
out = results[0].splitlines(False)
self.assertEquals(out[0], '')
self.assertTrue(out[1].startswith('________ running \'svn status\' in \''))
self.assertEquals(out[2], '? svn_hooked1')
self.assertEquals(out[3], '? other')
self.assertEquals(out[4], '? third_party/foo')
self.assertEquals(out[4], '? ' + join('third_party', 'foo'))
self.assertEquals(out[5], '')
self.assertTrue(out[6].startswith('________ running \'svn status\' in \''))
self.assertEquals(out[7], '? hi')
......@@ -252,30 +245,32 @@ class GClientSmokeSVN(GClientSmokeBase):
# Revert implies --force implies running hooks without looking at pattern
# matching.
results = self.gclient(['revert'])
results = self.gclient(['revert', '--deps', 'mac'])
out = results[0].splitlines(False)
self.assertEquals(22, len(out))
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[-1]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[-1]),
('trunk/third_party/foo', 'src/third_party/foo',
self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'other'), join('src', 'other'),
self.FAKE_REPOS.svn_revs[2]),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
)
tree[join('src', 'svn_hooked1')] = 'svn_hooked1'
tree[join('src', 'svn_hooked2')] = 'svn_hooked2'
tree['src/svn_hooked1'] = 'svn_hooked1'
tree['src/svn_hooked2'] = 'svn_hooked2'
self.assertTree(tree)
results = self.gclient(['status'])
results = self.gclient(['status', '--deps', 'mac'])
out = results[0].splitlines(False)
self.assertEquals(out[0], '')
self.assertTrue(out[1].startswith('________ running \'svn status\' in \''))
self.assertEquals(out[2], '? svn_hooked1')
self.assertEquals(out[3], '? svn_hooked2')
self.assertEquals(out[4], '? other')
self.assertEquals(out[5], '? third_party/foo')
# I don't know why but on Windows they are reversed.
if (not (out[3] == '? other' and out[4] == '? svn_hooked2') and
not (out[3] == '? svn_hooked2' and out[4] == '? other')):
self.assertEquals(out[3], '? svn_hooked2')
self.assertEquals(out[4], '? other')
self.assertEquals(out[5], '? ' + join('third_party', 'foo'))
self.assertEquals(6, len(out))
self.checkString('', results[1])
self.assertEquals(0, results[2])
......@@ -291,8 +286,8 @@ class GClientSmokeSVN(GClientSmokeBase):
self.assertEquals(out[0], '')
self.assertTrue(out[1].startswith('________ running \'svn status\' in \''))
self.assertEquals(out[2], '? other')
self.assertEquals(out[3], '? third_party/fpp')
self.assertEquals(out[4], '? third_party/prout')
self.assertEquals(out[3], '? ' + join('third_party', 'fpp'))
self.assertEquals(out[4], '? ' + join('third_party', 'prout'))
self.assertEquals(out[5], '')
self.assertTrue(out[6].startswith('________ running \'svn status\' in \''))
self.assertEquals(out[7], '? hi')
......@@ -308,13 +303,11 @@ class GClientSmokeSVN(GClientSmokeBase):
self.checkString('', results[1])
self.assertEquals(0, results[2])
tree = mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'),
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'other'), join('src', 'other'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]),
('trunk/third_party/foo', 'src/third_party/fpp',
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'prout'),
join('src', 'third_party', 'prout'),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/prout', 'src/third_party/prout',
self.FAKE_REPOS.svn_revs[2]),
)
self.assertTree(tree)
......@@ -324,8 +317,8 @@ class GClientSmokeSVN(GClientSmokeBase):
self.assertEquals(out[0], '')
self.assertTrue(out[1].startswith('________ running \'svn status\' in \''))
self.assertEquals(out[2], '? other')
self.assertEquals(out[3], '? third_party/fpp')
self.assertEquals(out[4], '? third_party/prout')
self.assertEquals(out[3], '? ' + join('third_party', 'fpp'))
self.assertEquals(out[4], '? ' + join('third_party', 'prout'))
self.assertEquals(5, len(out))
self.checkString('', results[1])
self.assertEquals(0, results[2])
......@@ -333,16 +326,16 @@ class GClientSmokeSVN(GClientSmokeBase):
def testRunHooks(self):
self.gclient(['config', self.svn_base + 'trunk/src/'])
self.gclient(['sync', '--deps', 'mac'])
results = self.gclient(['runhooks'])
results = self.gclient(['runhooks', '--deps', 'mac'])
out = results[0].splitlines(False)
self.assertEquals(4, len(out))
self.assertEquals(out[0], '')
self.assertTrue(re.match(r'^________ running \'.*?python -c '
self.assertTrue(re.match(r'^________ running \'.*?python(.exe)? -c '
r'open\(\'src/svn_hooked1\', \'w\'\)\.write\(\'svn_hooked1\'\)\' in \'.*',
out[1]))
self.assertEquals(out[2], '')
# runhooks runs all hooks even if not matching by design.
self.assertTrue(re.match(r'^________ running \'.*?python -c '
self.assertTrue(re.match(r'^________ running \'.*?python(.exe)? -c '
r'open\(\'src/svn_hooked2\', \'w\'\)\.write\(\'svn_hooked2\'\)\' in \'.*',
out[3]))
self.checkString('', results[1])
......@@ -351,14 +344,14 @@ class GClientSmokeSVN(GClientSmokeBase):
def testRunHooksDepsOs(self):
self.gclient(['config', self.svn_base + 'trunk/src/'])
self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1'])
results = self.gclient(['runhooks'])
results = self.gclient(['runhooks', '--deps', 'mac'])
self.check(('', '', 0), results)
def testRevInfo(self):
# TODO(maruel): Test multiple solutions.
self.gclient(['config', self.svn_base + 'trunk/src/'])
self.gclient(['sync', '--deps', 'mac'])
results = self.gclient(['revinfo'])
results = self.gclient(['revinfo', '--deps', 'mac'])
out = ('src: %(base)s/src@2;\n'
'src/other: %(base)s/other@2;\n'
'src/third_party/foo: %(base)s/third_party/foo@1\n' %
......@@ -369,9 +362,11 @@ class GClientSmokeSVN(GClientSmokeBase):
class GClientSmokeGIT(GClientSmokeBase):
def setUp(self):
GClientSmokeBase.setUp(self)
self.FAKE_REPOS.setUpGIT()
self.enabled = self.FAKE_REPOS.setUpGIT()
def testSync(self):
if not self.enabled:
return
# TODO(maruel): safesync.
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
# Test unversioned checkout.
......@@ -384,12 +379,11 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
(join('src', 'repo2', 'repo_renamed'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
)
tree[join('src', 'git_hooked1')] = 'git_hooked1'
tree[join('src', 'git_hooked2')] = 'git_hooked2'
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
# Manually remove git_hooked1 before synching to make sure it's not
......@@ -407,12 +401,11 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
(join('src', 'repo2', 'repo3'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
(join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
)
tree[join('src', 'git_hooked2')] = 'git_hooked2'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
# Test incremental sync: delete-unversioned_trees isn't there.
results = self.gclient(['sync', '--deps', 'mac'])
......@@ -423,19 +416,19 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
(join('src', 'repo2', 'repo3'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
(join('src', 'repo2', 'repo_renamed'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
(join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
)
tree[join('src', 'git_hooked1')] = 'git_hooked1'
tree[join('src', 'git_hooked2')] = 'git_hooked2'
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
def testSyncIgnoredSolutionName(self):
"""TODO(maruel): This will become an error soon."""
if not self.enabled:
return
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
results = self.gclient([
'sync', '--deps', 'mac', '--revision',
......@@ -452,15 +445,17 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
(join('src', 'repo2', 'repo_renamed'),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
('src/repo2/repo_renamed',
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
)
tree[join('src', 'git_hooked1')] = 'git_hooked1'
tree[join('src', 'git_hooked2')] = 'git_hooked2'
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
def testSyncNoSolutionName(self):
if not self.enabled:
return
# When no solution name is provided, gclient uses the first solution listed.
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
results = self.gclient([
......@@ -475,21 +470,22 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
(join('src', 'repo2', 'repo3'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
(join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
)
self.assertTree(tree)
def testRevertAndStatus(self):
"""TODO(maruel): Remove this line once this test is fixed."""
if not self.enabled:
return
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
# Tested in testSync.
self.gclient(['sync', '--deps', 'mac'])
write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!')
results = self.gclient(['status'])
results = self.gclient(['status', '--deps', 'mac'])
out = results[0].splitlines(False)
# TODO(maruel): http://crosbug.com/3584 It should output the unversioned
# files.
......@@ -497,7 +493,7 @@ class GClientSmokeGIT(GClientSmokeBase):
# Revert implies --force implies running hooks without looking at pattern
# matching.
results = self.gclient(['revert'])
results = self.gclient(['revert', '--deps', 'mac'])
out = results[0].splitlines(False)
# TODO(maruel): http://crosbug.com/3583 It just runs the hooks right now.
self.assertEquals(7, len(out))
......@@ -505,26 +501,27 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
(join('src', 'repo2', 'repo_renamed'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
)
# TODO(maruel): http://crosbug.com/3583 This file should have been removed.
tree[join('src', 'repo2', 'hi')] = 'Hey!'
tree[join('src', 'git_hooked1')] = 'git_hooked1'
tree[join('src', 'git_hooked2')] = 'git_hooked2'
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
results = self.gclient(['status'])
results = self.gclient(['status', '--deps', 'mac'])
out = results[0].splitlines(False)
# TODO(maruel): http://crosbug.com/3584 It should output the unversioned
# files.
self.assertEquals(0, len(out))
def testRunHooks(self):
if not self.enabled:
return
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
self.gclient(['sync', '--deps', 'mac'])
results = self.gclient(['runhooks'])
results = self.gclient(['runhooks', '--deps', 'mac'])
logging.debug(results[0])
out = results[0].splitlines(False)
self.assertEquals(4, len(out))
......@@ -541,10 +538,12 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, results[2])
def testRevInfo(self):
if not self.enabled:
return
# TODO(maruel): Test multiple solutions.
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
self.gclient(['sync', '--deps', 'mac'])
results = self.gclient(['revinfo'])
results = self.gclient(['revinfo', '--deps', 'mac'])
out = ('src: %(base)srepo_1@%(hash1)s;\n'
'src/repo2: %(base)srepo_2@%(hash2)s;\n'
'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' %
......@@ -561,9 +560,11 @@ class GClientSmokeBoth(GClientSmokeBase):
def setUp(self):
GClientSmokeBase.setUp(self)
self.FAKE_REPOS.setUpSVN()
self.FAKE_REPOS.setUpGIT()
self.enabled = self.FAKE_REPOS.setUpGIT()
def testMultiSolutions(self):
if not self.enabled:
return
self.gclient(['config', '--spec',
'solutions=['
'{"name": "src",'
......@@ -579,24 +580,24 @@ class GClientSmokeBoth(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src-git', self.FAKE_REPOS.git_hashes['repo_1'][1][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
(join('src', 'repo2', 'repo_renamed'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]),
('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
)
tree.update(mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/foo',
self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'other'), join('src', 'other'),
self.FAKE_REPOS.svn_revs[2]),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
))
tree[join('src', 'git_hooked1')] = 'git_hooked1'
tree[join('src', 'git_hooked2')] = 'git_hooked2'
tree[join('src', 'svn_hooked1')] = 'svn_hooked1'
tree[join('src', 'svn_hooked2')] = 'svn_hooked2'
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
tree['src/svn_hooked1'] = 'svn_hooked1'
tree['src/svn_hooked2'] = 'svn_hooked2'
self.assertTree(tree)
def testMultiSolutionsMultiRev(self):
if not self.enabled:
return
self.gclient(['config', '--spec',
'solutions=['
'{"name": "src",'
......@@ -614,19 +615,16 @@ class GClientSmokeBoth(GClientSmokeBase):
self.assertEquals(0, results[2])
tree = mangle_git_tree(
('src-git', self.FAKE_REPOS.git_hashes['repo_1'][0][1]),
(join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
(join('src', 'repo2', 'repo3'),
self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
(join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]),
('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]),
('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]),
)
tree.update(mangle_svn_tree(
(join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]),
(join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'),
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'other'), join('src', 'other'),
('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]),
('trunk/third_party/foo', 'src/third_party/fpp',
self.FAKE_REPOS.svn_revs[2]),
(join('trunk', 'third_party', 'foo'),
join('src', 'third_party', 'prout'),
('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]),
('trunk/third_party/foo', 'src/third_party/prout',
self.FAKE_REPOS.svn_revs[2]),
))
self.assertTree(tree)
......
......@@ -750,7 +750,8 @@ class InputApiUnittest(PresubmitTestsBase):
self.assertEquals(results[i].LocalPath(),
presubmit.normpath(item[1][i]))
# Same number of expected results.
self.assertEquals(sorted([f.LocalPath() for f in results]),
self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/')
for f in results]),
sorted(item[1]))
def testCustomFilter(self):
......
......@@ -40,7 +40,7 @@ class TryChangeUnittest(TryChangeTestsBase):
"""General trychange.py tests."""
def testMembersChanged(self):
members = [
'EscapeDot', 'GIT', 'GuessVCS', 'GetMungedDiff',
'EPILOG', 'EscapeDot', 'GIT', 'GuessVCS', 'GetMungedDiff',
'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'PrintSuccess',
'SCM', 'SVN', 'TryChange', 'USAGE',
'breakpad', 'datetime', 'errno', 'gclient_utils', 'getpass', 'json',
......
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