Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: tests/gclient_scm_test.py

Issue 6456010: Improve tests to support more git versions and different outputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Address review comment Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pylintrc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/gclient_scm_test.py
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 00ae0d8c667fa4df6cb744ae73ba2ef312a6333a..b864a85100209d3fe36895a1e97b76eb85a745f6 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -18,6 +18,7 @@ import __builtin__
# Fixes include path.
from super_mox import mox, StdoutCheck, TestCaseUtils, SuperMoxTestBase
+import logging
import sys
import gclient_scm
@@ -737,12 +738,25 @@ from :3
'069c602044c5388d2d15c3f875b057c852003458')
finally:
rmtree(root_dir)
- self.checkstdout(
- ('\n_____ foo at refs/heads/master\n\n'
- '________ running \'git clone -b master --verbose %s %s\' in \'%s\'\n'
- 'Initialized empty Git repository in %s\n') %
- (join(self.root_dir, '.', '.git'), join(root_dir, 'foo'), root_dir,
- join(gclient_scm.os.path.realpath(root_dir), 'foo', '.git') + '/'))
+ msg1 = (
+ "\n_____ foo at refs/heads/master\n\n"
+ "________ running 'git clone -b master --verbose %s %s' in '%s'\n"
+ "Initialized empty Git repository in %s\n") % (
+ join(self.root_dir, '.', '.git'),
+ join(root_dir, 'foo'),
+ root_dir,
+ join(gclient_scm.os.path.realpath(root_dir), 'foo', '.git') + '/')
+ msg2 = (
+ "\n_____ foo at refs/heads/master\n\n"
+ "________ running 'git clone -b master --verbose %s %s' in '%s'\n"
+ "Cloning into %s...\ndone.\n") % (
+ join(self.root_dir, '.', '.git'),
+ join(root_dir, 'foo'),
+ root_dir,
+ join(gclient_scm.os.path.realpath(root_dir), 'foo'))
+ out = sys.stdout.getvalue()
+ sys.stdout.close()
+ self.assertTrue(out in (msg1, msg2), (out, msg1, msg2))
def testUpdateUpdate(self):
if not self.enabled:
@@ -769,12 +783,17 @@ from :3
relpath=self.relpath)
file_path = join(self.base_path, 'b')
open(file_path, 'w').writelines('conflict\n')
- exception = (
- "error: Your local changes to 'b' would be overwritten by merge. "
- "Aborting.\n"
- "Please, commit your changes or stash them before you can merge.\n")
- self.assertRaisesError(exception, scm.update, options, (), [])
- self.checkstdout('\n_____ . at refs/heads/master\n')
+ try:
+ scm.update(options, (), [])
+ self.fail()
+ except gclient_scm.gclient_utils.CheckCallError:
+ # The exact exception text varies across git versions so it's not worth
+ # verifying it. It's fine as long as it throws.
+ pass
+ # Manually flush stdout since we can't verify it's content accurately across
+ # git versions.
+ sys.stdout.getvalue()
+ sys.stdout.close()
def testUpdateConflict(self):
if not self.enabled:
@@ -833,6 +852,11 @@ from :3
if __name__ == '__main__':
+ if '-v' in sys.argv:
+ logging.basicConfig(
+ level=logging.DEBUG,
+ format='%(asctime).19s %(levelname)s %(filename)s:'
+ '%(lineno)s %(message)s')
unittest.main()
# vim: ts=2:sw=2:tw=80:et:
« no previous file with comments | « pylintrc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698