| 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 presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1101,E1103 | 8 # pylint: disable=E1101,E1103 |
| 9 | 9 |
| 10 import StringIO | 10 import StringIO |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 join = presubmit.os.path.join | 210 join = presubmit.os.path.join |
| 211 files = [ | 211 files = [ |
| 212 'blat.cc', | 212 'blat.cc', |
| 213 join('foo', 'haspresubmit', 'yodle', 'smart.h'), | 213 join('foo', 'haspresubmit', 'yodle', 'smart.h'), |
| 214 join('moo', 'mat', 'gat', 'yo.h'), | 214 join('moo', 'mat', 'gat', 'yo.h'), |
| 215 join('foo', 'luck.h'), | 215 join('foo', 'luck.h'), |
| 216 ] | 216 ] |
| 217 inherit_path = presubmit.os.path.join(self.fake_root_dir, | 217 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 218 self._INHERIT_SETTINGS) | 218 self._INHERIT_SETTINGS) |
| 219 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 219 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 220 presubmit.os.listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 220 presubmit.os.path.isfile(join(self.fake_root_dir, | 221 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 221 'PRESUBMIT.py')).AndReturn(True) | 222 'PRESUBMIT.py')).AndReturn(True) |
| 222 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', | 223 presubmit.os.listdir(join(self.fake_root_dir, 'foo')).AndReturn([]) |
| 223 'PRESUBMIT.py')).AndReturn(False) | 224 presubmit.os.listdir(join(self.fake_root_dir, 'foo', |
| 224 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', 'haspresubmit', | 225 'haspresubmit')).AndReturn(['PRESUBMIT.py']) |
| 225 'PRESUBMIT.py')).AndReturn(True) | 226 presubmit.os.path.isfile( |
| 226 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', 'haspresubmit', | 227 join(self.fake_root_dir, 'foo', 'haspresubmit', |
| 227 'yodle', 'PRESUBMIT.py')).AndReturn(True) | 228 'PRESUBMIT.py')).AndReturn(True) |
| 228 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', | 229 presubmit.os.listdir( |
| 229 'PRESUBMIT.py')).AndReturn(False) | 230 join(self.fake_root_dir, 'foo', 'haspresubmit', 'yodle')).AndReturn( |
| 230 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', 'mat', | 231 ['PRESUBMIT.py']) |
| 231 'PRESUBMIT.py')).AndReturn(False) | 232 presubmit.os.path.isfile( |
| 232 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', 'mat', 'gat', | 233 join(self.fake_root_dir, 'foo', 'haspresubmit', 'yodle', |
| 233 'PRESUBMIT.py')).AndReturn(False) | 234 'PRESUBMIT.py')).AndReturn(True) |
| 235 presubmit.os.listdir(join(self.fake_root_dir, 'moo')).AndReturn([]) |
| 236 presubmit.os.listdir(join(self.fake_root_dir, 'moo', 'mat')).AndReturn([]) |
| 237 presubmit.os.listdir(join(self.fake_root_dir, 'moo', 'mat', |
| 238 'gat')).AndReturn([]) |
| 234 self.mox.ReplayAll() | 239 self.mox.ReplayAll() |
| 235 | 240 |
| 236 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, | 241 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, |
| 237 self.fake_root_dir) | 242 self.fake_root_dir) |
| 238 self.assertEqual(presubmit_files, | 243 self.assertEqual(presubmit_files, |
| 239 [ | 244 [ |
| 240 join(self.fake_root_dir, 'PRESUBMIT.py'), | 245 join(self.fake_root_dir, 'PRESUBMIT.py'), |
| 241 join(self.fake_root_dir, 'foo', 'haspresubmit', 'PRESUBMIT.py'), | 246 join(self.fake_root_dir, 'foo', 'haspresubmit', 'PRESUBMIT.py'), |
| 242 join(self.fake_root_dir, 'foo', 'haspresubmit', 'yodle', | 247 join(self.fake_root_dir, 'foo', 'haspresubmit', 'yodle', |
| 243 'PRESUBMIT.py') | 248 'PRESUBMIT.py') |
| 244 ]) | 249 ]) |
| 245 | 250 |
| 251 def testListUserPresubmitFiles(self): |
| 252 join = presubmit.os.path.join |
| 253 files = ['blat.cc',] |
| 254 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 255 self._INHERIT_SETTINGS) |
| 256 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 257 presubmit.os.listdir(self.fake_root_dir).AndReturn( |
| 258 ['PRESUBMIT.py', 'PRESUBMIT_test.py', 'PRESUBMIT-user.py']) |
| 259 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 260 'PRESUBMIT.py')).AndReturn(True) |
| 261 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 262 'PRESUBMIT_test.py')).AndReturn(True) |
| 263 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 264 'PRESUBMIT-user.py')).AndReturn(True) |
| 265 self.mox.ReplayAll() |
| 266 |
| 267 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, |
| 268 self.fake_root_dir) |
| 269 self.assertEqual(presubmit_files, [ |
| 270 join(self.fake_root_dir, 'PRESUBMIT.py'), |
| 271 join(self.fake_root_dir, 'PRESUBMIT-user.py'), |
| 272 ]) |
| 273 |
| 246 def testListRelevantPresubmitFilesInheritSettings(self): | 274 def testListRelevantPresubmitFilesInheritSettings(self): |
| 247 join = presubmit.os.path.join | 275 join = presubmit.os.path.join |
| 248 sys_root_dir = self._OS_SEP | 276 sys_root_dir = self._OS_SEP |
| 249 root_dir = join(sys_root_dir, 'foo', 'bar') | 277 root_dir = join(sys_root_dir, 'foo', 'bar') |
| 250 files = [ | 278 files = [ |
| 251 'test.cc', | 279 'test.cc', |
| 252 join('moo', 'test2.cc'), | 280 join('moo', 'test2.cc'), |
| 253 join('zoo', 'test3.cc') | 281 join('zoo', 'test3.cc') |
| 254 ] | 282 ] |
| 255 inherit_path = presubmit.os.path.join(root_dir, self._INHERIT_SETTINGS) | 283 inherit_path = presubmit.os.path.join(root_dir, self._INHERIT_SETTINGS) |
| 256 presubmit.os.path.isfile(inherit_path).AndReturn(True) | 284 presubmit.os.path.isfile(inherit_path).AndReturn(True) |
| 257 presubmit.os.path.isfile(join(sys_root_dir, | 285 presubmit.os.listdir(sys_root_dir).AndReturn([]) |
| 258 'PRESUBMIT.py')).AndReturn(False) | 286 presubmit.os.listdir(join(sys_root_dir, 'foo')).AndReturn(['PRESUBMIT.py']) |
| 259 presubmit.os.path.isfile(join(sys_root_dir, 'foo', | 287 presubmit.os.path.isfile(join(sys_root_dir, 'foo', |
| 260 'PRESUBMIT.py')).AndReturn(True) | 288 'PRESUBMIT.py')).AndReturn(True) |
| 261 presubmit.os.path.isfile(join(sys_root_dir, 'foo', 'bar', | 289 presubmit.os.listdir(join(sys_root_dir, 'foo', 'bar')).AndReturn([]) |
| 262 'PRESUBMIT.py')).AndReturn(False) | 290 presubmit.os.listdir(join(sys_root_dir, 'foo', 'bar', 'moo')).AndReturn( |
| 263 presubmit.os.path.isfile(join(sys_root_dir, 'foo', 'bar', 'moo', | 291 ['PRESUBMIT.py']) |
| 264 'PRESUBMIT.py')).AndReturn(True) | 292 presubmit.os.path.isfile( |
| 265 presubmit.os.path.isfile(join(sys_root_dir, 'foo', 'bar', 'zoo', | 293 join(sys_root_dir, 'foo', 'bar', 'moo', 'PRESUBMIT.py')).AndReturn(True) |
| 266 'PRESUBMIT.py')).AndReturn(False) | 294 presubmit.os.listdir(join(sys_root_dir, 'foo', 'bar', 'zoo')).AndReturn([]) |
| 267 self.mox.ReplayAll() | 295 self.mox.ReplayAll() |
| 268 | 296 |
| 269 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, root_dir) | 297 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, root_dir) |
| 270 self.assertEqual(presubmit_files, | 298 self.assertEqual(presubmit_files, |
| 271 [ | 299 [ |
| 272 join(sys_root_dir, 'foo', 'PRESUBMIT.py'), | 300 join(sys_root_dir, 'foo', 'PRESUBMIT.py'), |
| 273 join(sys_root_dir, 'foo', 'bar', 'moo', 'PRESUBMIT.py') | 301 join(sys_root_dir, 'foo', 'bar', 'moo', 'PRESUBMIT.py') |
| 274 ]) | 302 ]) |
| 275 | 303 |
| 276 def testTagLineRe(self): | 304 def testTagLineRe(self): |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 'this is a change', | 703 'this is a change', |
| 676 'STORY=http://tracker/123') | 704 'STORY=http://tracker/123') |
| 677 files = [ | 705 files = [ |
| 678 ['A', join('haspresubmit', 'blat.cc')], | 706 ['A', join('haspresubmit', 'blat.cc')], |
| 679 ] | 707 ] |
| 680 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') | 708 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') |
| 681 root_path = join(self.fake_root_dir, 'PRESUBMIT.py') | 709 root_path = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 682 inherit_path = presubmit.os.path.join(self.fake_root_dir, | 710 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 683 self._INHERIT_SETTINGS) | 711 self._INHERIT_SETTINGS) |
| 684 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 712 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 713 presubmit.os.listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 685 presubmit.os.path.isfile(root_path).AndReturn(True) | 714 presubmit.os.path.isfile(root_path).AndReturn(True) |
| 715 presubmit.os.listdir(os.path.join( |
| 716 self.fake_root_dir, 'haspresubmit')).AndReturn(['PRESUBMIT.py']) |
| 686 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) | 717 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) |
| 687 presubmit.gclient_utils.FileRead(root_path, | 718 presubmit.gclient_utils.FileRead(root_path, |
| 688 'rU').AndReturn(self.presubmit_text) | 719 'rU').AndReturn(self.presubmit_text) |
| 689 presubmit.gclient_utils.FileRead(haspresubmit_path, | 720 presubmit.gclient_utils.FileRead(haspresubmit_path, |
| 690 'rU').AndReturn(self.presubmit_text) | 721 'rU').AndReturn(self.presubmit_text) |
| 691 presubmit.random.randint(0, 4).AndReturn(1) | 722 presubmit.random.randint(0, 4).AndReturn(1) |
| 692 self.mox.ReplayAll() | 723 self.mox.ReplayAll() |
| 693 | 724 |
| 694 input_buf = StringIO.StringIO('y\n') | 725 input_buf = StringIO.StringIO('y\n') |
| 695 change = presubmit.Change( | 726 change = presubmit.Change( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 714 'NOSUCHKEY=http://tracker/123') | 745 'NOSUCHKEY=http://tracker/123') |
| 715 files = [ | 746 files = [ |
| 716 ['A', join('haspresubmit', 'blat.cc')], | 747 ['A', join('haspresubmit', 'blat.cc')], |
| 717 ] | 748 ] |
| 718 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') | 749 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 719 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') | 750 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') |
| 720 inherit_path = presubmit.os.path.join(self.fake_root_dir, | 751 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 721 self._INHERIT_SETTINGS) | 752 self._INHERIT_SETTINGS) |
| 722 for _ in range(2): | 753 for _ in range(2): |
| 723 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 754 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 755 presubmit.os.listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 724 presubmit.os.path.isfile(presubmit_path).AndReturn(True) | 756 presubmit.os.path.isfile(presubmit_path).AndReturn(True) |
| 757 presubmit.os.listdir(join(self.fake_root_dir, 'haspresubmit')).AndReturn( |
| 758 ['PRESUBMIT.py']) |
| 725 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) | 759 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) |
| 726 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' | 760 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' |
| 727 ).AndReturn(self.presubmit_text) | 761 ).AndReturn(self.presubmit_text) |
| 728 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU' | 762 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU' |
| 729 ).AndReturn(self.presubmit_text) | 763 ).AndReturn(self.presubmit_text) |
| 730 presubmit.random.randint(0, 4).AndReturn(1) | 764 presubmit.random.randint(0, 4).AndReturn(1) |
| 731 presubmit.random.randint(0, 4).AndReturn(1) | 765 presubmit.random.randint(0, 4).AndReturn(1) |
| 732 self.mox.ReplayAll() | 766 self.mox.ReplayAll() |
| 733 | 767 |
| 734 input_buf = StringIO.StringIO('n\n') # say no to the warning | 768 input_buf = StringIO.StringIO('n\n') # say no to the warning |
| (...skipping 26 matching lines...) Expand all Loading... |
| 761 'REALLYNOSUCHKEY=http://tracker/123') | 795 'REALLYNOSUCHKEY=http://tracker/123') |
| 762 files = [ | 796 files = [ |
| 763 ['A', join('haspresubmit', 'blat.cc')], | 797 ['A', join('haspresubmit', 'blat.cc')], |
| 764 ] | 798 ] |
| 765 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') | 799 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 766 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', | 800 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', |
| 767 'PRESUBMIT.py') | 801 'PRESUBMIT.py') |
| 768 inherit_path = presubmit.os.path.join(self.fake_root_dir, | 802 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 769 self._INHERIT_SETTINGS) | 803 self._INHERIT_SETTINGS) |
| 770 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 804 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 805 presubmit.os.listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 771 presubmit.os.path.isfile(presubmit_path).AndReturn(True) | 806 presubmit.os.path.isfile(presubmit_path).AndReturn(True) |
| 807 presubmit.os.listdir(join(self.fake_root_dir, 'haspresubmit')).AndReturn( |
| 808 ['PRESUBMIT.py']) |
| 772 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) | 809 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) |
| 773 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' | 810 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' |
| 774 ).AndReturn(self.presubmit_text) | 811 ).AndReturn(self.presubmit_text) |
| 775 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn( | 812 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn( |
| 776 self.presubmit_text) | 813 self.presubmit_text) |
| 777 presubmit.random.randint(0, 4).AndReturn(1) | 814 presubmit.random.randint(0, 4).AndReturn(1) |
| 778 self.mox.ReplayAll() | 815 self.mox.ReplayAll() |
| 779 | 816 |
| 780 change = presubmit.Change( | 817 change = presubmit.Change( |
| 781 'mychange', | 818 'mychange', |
| (...skipping 21 matching lines...) Expand all Loading... |
| 803 ] | 840 ] |
| 804 DEFAULT_SCRIPT = """ | 841 DEFAULT_SCRIPT = """ |
| 805 def CheckChangeOnUpload(input_api, output_api): | 842 def CheckChangeOnUpload(input_api, output_api): |
| 806 return [output_api.PresubmitError("!!")] | 843 return [output_api.PresubmitError("!!")] |
| 807 def CheckChangeOnCommit(input_api, output_api): | 844 def CheckChangeOnCommit(input_api, output_api): |
| 808 raise Exception("Test error") | 845 raise Exception("Test error") |
| 809 """ | 846 """ |
| 810 inherit_path = presubmit.os.path.join(self.fake_root_dir, | 847 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 811 self._INHERIT_SETTINGS) | 848 self._INHERIT_SETTINGS) |
| 812 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 849 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 813 presubmit.os.path.isfile(join(self.fake_root_dir, 'PRESUBMIT.py') | 850 presubmit.os.listdir(join(self.fake_root_dir) |
| 814 ).AndReturn(False) | 851 ).AndReturn([]) |
| 852 presubmit.os.listdir(join(self.fake_root_dir, 'haspresubmit') |
| 853 ).AndReturn(['PRESUBMIT.py']) |
| 815 presubmit.os.path.isfile(join(self.fake_root_dir, | 854 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 816 'haspresubmit', | 855 'haspresubmit', |
| 817 'PRESUBMIT.py')).AndReturn(False) | 856 'PRESUBMIT.py')).AndReturn(False) |
| 818 presubmit.random.randint(0, 4).AndReturn(0) | 857 presubmit.random.randint(0, 4).AndReturn(0) |
| 819 self.mox.ReplayAll() | 858 self.mox.ReplayAll() |
| 820 | 859 |
| 821 input_buf = StringIO.StringIO('y\n') | 860 input_buf = StringIO.StringIO('y\n') |
| 822 # Always fail. | 861 # Always fail. |
| 823 change = presubmit.Change( | 862 change = presubmit.Change( |
| 824 'mychange', | 863 'mychange', |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 def testDoGetTrySlaves(self): | 1030 def testDoGetTrySlaves(self): |
| 992 join = presubmit.os.path.join | 1031 join = presubmit.os.path.join |
| 993 filename = 'foo.cc' | 1032 filename = 'foo.cc' |
| 994 filename_linux = join('linux_only', 'penguin.cc') | 1033 filename_linux = join('linux_only', 'penguin.cc') |
| 995 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') | 1034 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 996 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') | 1035 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') |
| 997 inherit_path = presubmit.os.path.join(self.fake_root_dir, | 1036 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 998 self._INHERIT_SETTINGS) | 1037 self._INHERIT_SETTINGS) |
| 999 | 1038 |
| 1000 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 1039 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 1040 presubmit.os.listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 1001 presubmit.os.path.isfile(root_presubmit).AndReturn(True) | 1041 presubmit.os.path.isfile(root_presubmit).AndReturn(True) |
| 1002 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( | 1042 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( |
| 1003 self.presubmit_tryslave % '["win"]') | 1043 self.presubmit_tryslave % '["win"]') |
| 1004 | 1044 |
| 1005 presubmit.os.path.isfile(inherit_path).AndReturn(False) | 1045 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 1046 presubmit.os.listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 1006 presubmit.os.path.isfile(root_presubmit).AndReturn(True) | 1047 presubmit.os.path.isfile(root_presubmit).AndReturn(True) |
| 1048 presubmit.os.listdir(join(self.fake_root_dir, 'linux_only')).AndReturn( |
| 1049 ['PRESUBMIT.py']) |
| 1007 presubmit.os.path.isfile(linux_presubmit).AndReturn(True) | 1050 presubmit.os.path.isfile(linux_presubmit).AndReturn(True) |
| 1008 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( | 1051 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( |
| 1009 self.presubmit_tryslave % '["win"]') | 1052 self.presubmit_tryslave % '["win"]') |
| 1010 presubmit.gclient_utils.FileRead(linux_presubmit, 'rU').AndReturn( | 1053 presubmit.gclient_utils.FileRead(linux_presubmit, 'rU').AndReturn( |
| 1011 self.presubmit_tryslave % '["linux"]') | 1054 self.presubmit_tryslave % '["linux"]') |
| 1012 self.mox.ReplayAll() | 1055 self.mox.ReplayAll() |
| 1013 | 1056 |
| 1014 change = presubmit.Change( | 1057 change = presubmit.Change( |
| 1015 'mychange', '', self.fake_root_dir, [], 0, 0, None) | 1058 'mychange', '', self.fake_root_dir, [], 0, 0, None) |
| 1016 | 1059 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 | 1141 |
| 1099 def testDoGetTryMasters(self): | 1142 def testDoGetTryMasters(self): |
| 1100 root_text = (self.presubmit_trymaster | 1143 root_text = (self.presubmit_trymaster |
| 1101 % '{"t1.cr": {"win": set(["defaulttests"])}}') | 1144 % '{"t1.cr": {"win": set(["defaulttests"])}}') |
| 1102 linux_text = (self.presubmit_trymaster | 1145 linux_text = (self.presubmit_trymaster |
| 1103 % ('{"t1.cr": {"linux1": set(["t1"])},' | 1146 % ('{"t1.cr": {"linux1": set(["t1"])},' |
| 1104 ' "t2.cr": {"linux2": set(["defaulttests"])}}')) | 1147 ' "t2.cr": {"linux2": set(["defaulttests"])}}')) |
| 1105 | 1148 |
| 1106 join = presubmit.os.path.join | 1149 join = presubmit.os.path.join |
| 1107 isfile = presubmit.os.path.isfile | 1150 isfile = presubmit.os.path.isfile |
| 1151 listdir = presubmit.os.listdir |
| 1108 FileRead = presubmit.gclient_utils.FileRead | 1152 FileRead = presubmit.gclient_utils.FileRead |
| 1109 filename = 'foo.cc' | 1153 filename = 'foo.cc' |
| 1110 filename_linux = join('linux_only', 'penguin.cc') | 1154 filename_linux = join('linux_only', 'penguin.cc') |
| 1111 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') | 1155 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 1112 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') | 1156 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') |
| 1113 inherit_path = join(self.fake_root_dir, self._INHERIT_SETTINGS) | 1157 inherit_path = join(self.fake_root_dir, self._INHERIT_SETTINGS) |
| 1114 | 1158 |
| 1115 isfile(inherit_path).AndReturn(False) | 1159 isfile(inherit_path).AndReturn(False) |
| 1160 listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 1116 isfile(root_presubmit).AndReturn(True) | 1161 isfile(root_presubmit).AndReturn(True) |
| 1117 FileRead(root_presubmit, 'rU').AndReturn(root_text) | 1162 FileRead(root_presubmit, 'rU').AndReturn(root_text) |
| 1118 | 1163 |
| 1119 isfile(inherit_path).AndReturn(False) | 1164 isfile(inherit_path).AndReturn(False) |
| 1165 listdir(self.fake_root_dir).AndReturn(['PRESUBMIT.py']) |
| 1120 isfile(root_presubmit).AndReturn(True) | 1166 isfile(root_presubmit).AndReturn(True) |
| 1167 listdir(join(self.fake_root_dir, 'linux_only')).AndReturn(['PRESUBMIT.py']) |
| 1121 isfile(linux_presubmit).AndReturn(True) | 1168 isfile(linux_presubmit).AndReturn(True) |
| 1122 FileRead(root_presubmit, 'rU').AndReturn(root_text) | 1169 FileRead(root_presubmit, 'rU').AndReturn(root_text) |
| 1123 FileRead(linux_presubmit, 'rU').AndReturn(linux_text) | 1170 FileRead(linux_presubmit, 'rU').AndReturn(linux_text) |
| 1124 self.mox.ReplayAll() | 1171 self.mox.ReplayAll() |
| 1125 | 1172 |
| 1126 change = presubmit.Change( | 1173 change = presubmit.Change( |
| 1127 'mychange', '', self.fake_root_dir, [], 0, 0, None) | 1174 'mychange', '', self.fake_root_dir, [], 0, 0, None) |
| 1128 | 1175 |
| 1129 output = StringIO.StringIO() | 1176 output = StringIO.StringIO() |
| 1130 self.assertEqual({'t1.cr': {'win': ['defaulttests']}}, | 1177 self.assertEqual({'t1.cr': {'win': ['defaulttests']}}, |
| (...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 owners_check=False) | 3097 owners_check=False) |
| 3051 self.assertEqual(2, len(results)) | 3098 self.assertEqual(2, len(results)) |
| 3052 self.assertEqual( | 3099 self.assertEqual( |
| 3053 'Found line ending with white spaces in:', results[0]._message) | 3100 'Found line ending with white spaces in:', results[0]._message) |
| 3054 self.checkstdout('') | 3101 self.checkstdout('') |
| 3055 | 3102 |
| 3056 | 3103 |
| 3057 if __name__ == '__main__': | 3104 if __name__ == '__main__': |
| 3058 import unittest | 3105 import unittest |
| 3059 unittest.main() | 3106 unittest.main() |
| OLD | NEW |