Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 commit refs/heads/origin | 745 commit refs/heads/origin |
| 746 mark :6 | 746 mark :6 |
| 747 author Alice <alice@example.com> 1253744424 -0700 | 747 author Alice <alice@example.com> 1253744424 -0700 |
| 748 committer Alice <alice@example.com> 1253744424 -0700 | 748 committer Alice <alice@example.com> 1253744424 -0700 |
| 749 data 13 | 749 data 13 |
| 750 Personalized | 750 Personalized |
| 751 from :3 | 751 from :3 |
| 752 M 100644 :4 a | 752 M 100644 :4 a |
| 753 M 100644 :5 b | 753 M 100644 :5 b |
| 754 | 754 |
| 755 blob | |
| 756 mark :7 | |
| 757 data 5 | |
| 758 Mooh | |
| 759 | |
| 760 commit refs/heads/feature | |
| 761 mark :8 | |
| 762 author Bob <bob@example.com> 1390311986 -0000 | |
| 763 committer Bob <bob@example.com> 1390311986 -0000 | |
| 764 data 6 | |
| 765 Add C | |
| 766 from :3 | |
| 767 M 100644 :7 c | |
| 768 | |
| 755 reset refs/heads/master | 769 reset refs/heads/master |
| 756 from :3 | 770 from :3 |
| 757 """ | 771 """ |
| 758 def Options(self, *args, **kwargs): | 772 def Options(self, *args, **kwargs): |
| 759 return self.OptionsObject(*args, **kwargs) | 773 return self.OptionsObject(*args, **kwargs) |
| 760 | 774 |
| 761 @staticmethod | 775 @staticmethod |
| 762 def CreateGitRepo(git_import, path): | 776 def CreateGitRepo(git_import, path): |
| 763 """Do it for real.""" | 777 """Do it for real.""" |
| 764 try: | 778 try: |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 expected_file_list = [join(self.base_path, x) for x in ['a', 'b']] | 974 expected_file_list = [join(self.base_path, x) for x in ['a', 'b']] |
| 961 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 975 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 962 relpath=self.relpath) | 976 relpath=self.relpath) |
| 963 file_list = [] | 977 file_list = [] |
| 964 scm.update(options, (), file_list) | 978 scm.update(options, (), file_list) |
| 965 self.assertEquals(file_list, expected_file_list) | 979 self.assertEquals(file_list, expected_file_list) |
| 966 self.assertEquals(scm.revinfo(options, (), None), | 980 self.assertEquals(scm.revinfo(options, (), None), |
| 967 'a7142dc9f0009350b96a11f372b6ea658592aa95') | 981 'a7142dc9f0009350b96a11f372b6ea658592aa95') |
| 968 sys.stdout.close() | 982 sys.stdout.close() |
| 969 | 983 |
| 984 def testUpdateMerge(self): | |
| 985 if not self.enabled: | |
| 986 return | |
| 987 options = self.Options() | |
| 988 options.merge = True | |
| 989 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | |
| 990 relpath=self.relpath) | |
| 991 scm._Run(['checkout', '-q', 'feature'], options) | |
| 992 rev = scm.revinfo(options, (), None) | |
| 993 file_list = [] | |
| 994 scm.update(options, (), file_list) | |
| 995 self.assertEquals(file_list, [join(self.base_path, x) | |
| 996 for x in ['a', 'b', 'c']]) | |
| 997 # The actual commit that is created is unstable, so we verify its tree and | |
| 998 # parents instead. | |
| 999 self.assertEquals(scm._Capture(['show', '--format=%T', '-s']), | |
| 1000 'd2e35c10ac24d6c621e14a1fcadceb533155627d') | |
|
iannucci
2014/01/21 21:40:47
Isn't this the same as `git rev-parse HEAD:`?
Bernhard Bauer
2014/01/21 23:03:54
No, this is the tree (i.e. without the commit meta
iannucci
2014/01/21 23:23:29
Right, hence the trailing colon :)
HEAD:path refe
Bernhard Bauer
2014/01/22 15:59:50
Ooh, that's neat! Done.
| |
| 1001 self.assertEquals(scm._Capture(['rev-parse', 'HEAD^1']), rev) | |
| 1002 self.assertEquals(scm._Capture(['rev-parse', 'HEAD^2']), | |
| 1003 scm._Capture(['rev-parse', 'origin/master'])) | |
| 1004 sys.stdout.close() | |
| 1005 | |
| 1006 def testUpdateRebase(self): | |
| 1007 if not self.enabled: | |
| 1008 return | |
| 1009 options = self.Options() | |
| 1010 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | |
| 1011 relpath=self.relpath) | |
| 1012 scm._Run(['checkout', '-q', 'feature'], options) | |
| 1013 rev = scm.revinfo(options, (), None) | |
| 1014 file_list = [] | |
| 1015 # Fake a 'y' key press. | |
| 1016 __builtin__.raw_input = lambda x: 'y' | |
|
iannucci
2014/01/21 21:40:47
scary :). Does this automatically get set back to
Bernhard Bauer
2014/01/21 23:03:54
I have to admit, I stole this from updateConflict
iannucci
2014/01/21 23:23:29
Heh, fair enough... as long as they're both the sa
Bernhard Bauer
2014/01/22 15:59:50
OK, I made it a method on |scm| which I can overri
| |
| 1017 scm.update(options, (), file_list) | |
| 1018 self.assertEquals(file_list, [join(self.base_path, x) | |
| 1019 for x in ['a', 'b', 'c']]) | |
| 1020 # The actual commit that is created is unstable, so we verify its tree and | |
| 1021 # parent instead. | |
| 1022 self.assertEquals(scm._Capture(['show', '--format=%T', '-s']), | |
| 1023 'd2e35c10ac24d6c621e14a1fcadceb533155627d') | |
| 1024 self.assertEquals(scm._Capture(['rev-parse', 'HEAD^']), | |
| 1025 scm._Capture(['rev-parse', 'origin/master'])) | |
| 1026 sys.stdout.close() | |
| 1027 | |
| 970 def testUpdateReset(self): | 1028 def testUpdateReset(self): |
| 971 if not self.enabled: | 1029 if not self.enabled: |
| 972 return | 1030 return |
| 973 options = self.Options() | 1031 options = self.Options() |
| 974 options.reset = True | 1032 options.reset = True |
| 975 | 1033 |
| 976 dir_path = join(self.base_path, 'c') | 1034 dir_path = join(self.base_path, 'c') |
| 977 os.mkdir(dir_path) | 1035 os.mkdir(dir_path) |
| 978 open(join(dir_path, 'nested'), 'w').writelines('new\n') | 1036 open(join(dir_path, 'nested'), 'w').writelines('new\n') |
| 979 | 1037 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 | 1263 |
| 1206 if __name__ == '__main__': | 1264 if __name__ == '__main__': |
| 1207 if '-v' in sys.argv: | 1265 if '-v' in sys.argv: |
| 1208 logging.basicConfig( | 1266 logging.basicConfig( |
| 1209 level=logging.DEBUG, | 1267 level=logging.DEBUG, |
| 1210 format='%(asctime).19s %(levelname)s %(filename)s:' | 1268 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 1211 '%(lineno)s %(message)s') | 1269 '%(lineno)s %(message)s') |
| 1212 unittest.main() | 1270 unittest.main() |
| 1213 | 1271 |
| 1214 # vim: ts=2:sw=2:tw=80:et: | 1272 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |