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

Side by Side Diff: PRESUBMIT_test.py

Issue 1839103002: Revert of Include isolate.py in data for Android unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « PRESUBMIT.py ('k') | PRESUBMIT_test_mocks.py » ('j') | 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 import glob
7 import json
8 import os
6 import re 9 import re
7 import subprocess 10 import subprocess
11 import sys
8 import unittest 12 import unittest
9 13
10 import PRESUBMIT 14 import PRESUBMIT
11 from PRESUBMIT_test_mocks import MockChange, MockFile, MockAffectedFile 15 from PRESUBMIT_test_mocks import MockChange, MockFile, MockAffectedFile
12 from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi 16 from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
13 17
14 _TEST_DATA_DIR = 'base/test/data/presubmit' 18 _TEST_DATA_DIR = 'base/test/data/presubmit'
15 19
16 class IncludeOrderTest(unittest.TestCase): 20 class IncludeOrderTest(unittest.TestCase):
17 def testSystemHeaderOrder(self): 21 def testSystemHeaderOrder(self):
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 829
826 output = PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi()) 830 output = PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi())
827 self.assertEqual( 831 self.assertEqual(
828 ('File %s line %d: %s is missing in ' 832 ('File %s line %d: %s is missing in '
829 'tools/metrics/actions/actions.xml. Please run ' 833 'tools/metrics/actions/actions.xml. Please run '
830 'tools/metrics/actions/extract_actions.py to update.' 834 'tools/metrics/actions/extract_actions.py to update.'
831 % (file_with_user_action, 1, 'NotInActionsXml')), 835 % (file_with_user_action, 1, 'NotInActionsXml')),
832 output[0].message) 836 output[0].message)
833 837
834 838
835 class PydepsNeedsUpdatingTest(unittest.TestCase):
836
837 class MockSubprocess(object):
838 CalledProcessError = subprocess.CalledProcessError
839
840 def setUp(self):
841 self.old_PYDEPS_FILES = PRESUBMIT._PYDEPS_FILES
842 PRESUBMIT._PYDEPS_FILES = ['A.pydeps', 'B.pydeps']
843 self.mock_input_api = MockInputApi()
844 self.mock_output_api = MockOutputApi()
845 self.mock_input_api.subprocess = PydepsNeedsUpdatingTest.MockSubprocess()
846 self.checker = PRESUBMIT.PydepsChecker(self.mock_input_api)
847 self.checker._file_cache = {
848 'A.pydeps': '# target: //A.py\n# root: //\nA.py\nC.py\n',
849 'B.pydeps': '# target: //B.py\n# root: //\nB.py\nC.py\n',
850 }
851
852 def tearDown(self):
853 PRESUBMIT._PYDEPS_FILES = self.old_PYDEPS_FILES
854
855 def _RunCheck(self):
856 return PRESUBMIT._CheckPydepsNeedsUpdating(self.mock_input_api,
857 self.mock_output_api,
858 checker_for_tests=self.checker)
859
860 def testAddedPydep(self):
861 self.mock_input_api.files = [
862 MockAffectedFile('new.pydeps', [], action='A'),
863 ]
864
865 results = self._RunCheck()
866 self.assertEqual(1, len(results))
867 self.assertTrue('PYDEPS_FILES' in str(results[0]))
868
869 def testRemovedPydep(self):
870 self.mock_input_api.files = [
871 MockAffectedFile(PRESUBMIT._PYDEPS_FILES[0], [], action='D'),
872 ]
873
874 results = self._RunCheck()
875 self.assertEqual(1, len(results))
876 self.assertTrue('PYDEPS_FILES' in str(results[0]))
877
878 def testRandomPyIgnored(self):
879 self.mock_input_api.files = [
880 MockAffectedFile('random.py', []),
881 ]
882
883 results = self._RunCheck()
884 self.assertEqual(0, len(results), 'Unexpected results: %r' % results)
885
886 def testRelevantPyNoChange(self):
887 self.mock_input_api.files = [
888 MockAffectedFile('A.py', []),
889 ]
890
891 def mock_check_output(cmd):
892 self.assertEqual('A.py', cmd[3])
893 return self.checker._file_cache['A.pydeps']
894
895 self.mock_input_api.subprocess.check_output = mock_check_output
896
897 results = self._RunCheck()
898 self.assertEqual(0, len(results), 'Unexpected results: %r' % results)
899
900 def testRelevantPyOneChange(self):
901 self.mock_input_api.files = [
902 MockAffectedFile('A.py', []),
903 ]
904
905 def mock_check_output(cmd):
906 self.assertEqual('A.py', cmd[3])
907 return 'changed data'
908
909 self.mock_input_api.subprocess.check_output = mock_check_output
910
911 results = self._RunCheck()
912 self.assertEqual(1, len(results))
913 self.assertTrue('File is stale' in str(results[0]))
914
915 def testRelevantPyTwoChanges(self):
916 self.mock_input_api.files = [
917 MockAffectedFile('C.py', []),
918 ]
919
920 def mock_check_output(cmd):
921 return 'changed data'
922
923 self.mock_input_api.subprocess.check_output = mock_check_output
924
925 results = self._RunCheck()
926 self.assertEqual(2, len(results))
927 self.assertTrue('File is stale' in str(results[0]))
928 self.assertTrue('File is stale' in str(results[1]))
929
930
931 class LogUsageTest(unittest.TestCase): 839 class LogUsageTest(unittest.TestCase):
932 840
933 def testCheckAndroidCrLogUsage(self): 841 def testCheckAndroidCrLogUsage(self):
934 mock_input_api = MockInputApi() 842 mock_input_api = MockInputApi()
935 mock_output_api = MockOutputApi() 843 mock_output_api = MockOutputApi()
936 844
937 mock_input_api.files = [ 845 mock_input_api.files = [
938 MockAffectedFile('RandomStuff.java', [ 846 MockAffectedFile('RandomStuff.java', [
939 'random stuff' 847 'random stuff'
940 ]), 848 ]),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 ['char* host = "https://www.aol.com"; // google.com']) 986 ['char* host = "https://www.aol.com"; // google.com'])
1079 ] 987 ]
1080 988
1081 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers( 989 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers(
1082 input_api, MockOutputApi()) 990 input_api, MockOutputApi())
1083 self.assertEqual(0, len(warnings)) 991 self.assertEqual(0, len(warnings))
1084 992
1085 993
1086 if __name__ == '__main__': 994 if __name__ == '__main__':
1087 unittest.main() 995 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698