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

Side by Side Diff: tests/gclient_scm_test.py

Issue 1865403003: Revert "Add (another) argument to break git locks in gclient." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 4 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for gclient_scm.py.""" 6 """Unit tests for gclient_scm.py."""
7 7
8 # pylint: disable=E1103 8 # pylint: disable=E1103
9 9
10 # Import before super_mox to keep valid references. 10 # Import before super_mox to keep valid references.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 self.manually_grab_svn_rev = True 126 self.manually_grab_svn_rev = True
127 self.deps_os = None 127 self.deps_os = None
128 self.force = False 128 self.force = False
129 self.reset = False 129 self.reset = False
130 self.nohooks = False 130 self.nohooks = False
131 self.no_history = False 131 self.no_history = False
132 self.upstream = False 132 self.upstream = False
133 self.cache_dir = None 133 self.cache_dir = None
134 self.merge = False 134 self.merge = False
135 self.jobs = 1 135 self.jobs = 1
136 self.break_repo_locks = False
137 self.delete_unversioned_trees = False 136 self.delete_unversioned_trees = False
138 137
139 sample_git_import = """blob 138 sample_git_import = """blob
140 mark :1 139 mark :1
141 data 6 140 data 6
142 Hello 141 Hello
143 142
144 blob 143 blob
145 mark :2 144 mark :2
146 data 4 145 data 4
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 self.fail() 494 self.fail()
496 except (gclient_scm.gclient_utils.Error, subprocess2.CalledProcessError): 495 except (gclient_scm.gclient_utils.Error, subprocess2.CalledProcessError):
497 # The exact exception text varies across git versions so it's not worth 496 # The exact exception text varies across git versions so it's not worth
498 # verifying it. It's fine as long as it throws. 497 # verifying it. It's fine as long as it throws.
499 pass 498 pass
500 # Manually flush stdout since we can't verify it's content accurately across 499 # Manually flush stdout since we can't verify it's content accurately across
501 # git versions. 500 # git versions.
502 sys.stdout.getvalue() 501 sys.stdout.getvalue()
503 sys.stdout.close() 502 sys.stdout.close()
504 503
505 def testUpdateLocked(self):
506 if not self.enabled:
507 return
508 options = self.Options()
509 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
510 relpath=self.relpath)
511 file_path = join(self.base_path, '.git', 'index.lock')
512 with open(file_path, 'w'):
513 pass
514 with self.assertRaisesRegexp(subprocess2.CalledProcessError,
515 'Unable to create.*/index.lock'):
516 scm.update(options, (), [])
517 sys.stdout.close()
518
519 def testUpdateLockedBreak(self):
520 if not self.enabled:
521 return
522 options = self.Options()
523 options.break_repo_locks = True
524 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
525 relpath=self.relpath)
526 file_path = join(self.base_path, '.git', 'index.lock')
527 with open(file_path, 'w'):
528 pass
529 scm.update(options, (), [])
530 self.assertRegexpMatches(sys.stdout.getvalue(),
531 "breaking lock.*\.git/index\.lock")
532 self.assertFalse(os.path.exists(file_path))
533 sys.stdout.close()
534
535 def testUpdateConflict(self): 504 def testUpdateConflict(self):
536 if not self.enabled: 505 if not self.enabled:
537 return 506 return
538 options = self.Options() 507 options = self.Options()
539 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 508 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
540 relpath=self.relpath) 509 relpath=self.relpath)
541 file_path = join(self.base_path, 'b') 510 file_path = join(self.base_path, 'b')
542 open(file_path, 'w').writelines('conflict\n') 511 open(file_path, 'w').writelines('conflict\n')
543 scm._Run(['commit', '-am', 'test'], options) 512 scm._Run(['commit', '-am', 'test'], options)
544 scm._AskForData = self._GetAskForDataCallback( 513 scm._AskForData = self._GetAskForDataCallback(
(...skipping 21 matching lines...) Expand all
566 535
567 class ManagedGitWrapperTestCaseMox(BaseTestCase): 536 class ManagedGitWrapperTestCaseMox(BaseTestCase):
568 class OptionsObject(object): 537 class OptionsObject(object):
569 def __init__(self, verbose=False, revision=None, force=False): 538 def __init__(self, verbose=False, revision=None, force=False):
570 self.verbose = verbose 539 self.verbose = verbose
571 self.revision = revision 540 self.revision = revision
572 self.deps_os = None 541 self.deps_os = None
573 self.force = force 542 self.force = force
574 self.reset = False 543 self.reset = False
575 self.nohooks = False 544 self.nohooks = False
576 self.break_repo_locks = False
577 # TODO(maruel): Test --jobs > 1. 545 # TODO(maruel): Test --jobs > 1.
578 self.jobs = 1 546 self.jobs = 1
579 547
580 def Options(self, *args, **kwargs): 548 def Options(self, *args, **kwargs):
581 return self.OptionsObject(*args, **kwargs) 549 return self.OptionsObject(*args, **kwargs)
582 550
583 def checkstdout(self, expected): 551 def checkstdout(self, expected):
584 value = sys.stdout.getvalue() 552 value = sys.stdout.getvalue()
585 sys.stdout.close() 553 sys.stdout.close()
586 # pylint: disable=E1101 554 # pylint: disable=E1101
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 939
972 if __name__ == '__main__': 940 if __name__ == '__main__':
973 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL 941 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL
974 logging.basicConfig( 942 logging.basicConfig(
975 level=level, 943 level=level,
976 format='%(asctime).19s %(levelname)s %(filename)s:' 944 format='%(asctime).19s %(levelname)s %(filename)s:'
977 '%(lineno)s %(message)s') 945 '%(lineno)s %(message)s')
978 unittest.main() 946 unittest.main()
979 947
980 # vim: ts=2:sw=2:tw=80:et: 948 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698