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

Side by Side Diff: PRESUBMIT_test.py

Issue 1403673003: Add additional hosts to hard-coded service URL presubmit check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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') | 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 import glob 6 import glob
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 self.assertTrue('HasAndroidLog.java:3' in msgs[3].items) 937 self.assertTrue('HasAndroidLog.java:3' in msgs[3].items)
938 self.assertTrue('IsInBasePackageButImportsLog.java:4' in msgs[3].items) 938 self.assertTrue('IsInBasePackageButImportsLog.java:4' in msgs[3].items)
939 939
940 # Tag must not contain 940 # Tag must not contain
941 nb = len(msgs[4].items) 941 nb = len(msgs[4].items)
942 self.assertEqual(2, nb, 942 self.assertEqual(2, nb,
943 'Expected %d items, found %d: %s' % (2, nb, msgs[4].items)) 943 'Expected %d items, found %d: %s' % (2, nb, msgs[4].items))
944 self.assertTrue('HasDottedTag.java' in msgs[4].items) 944 self.assertTrue('HasDottedTag.java' in msgs[4].items)
945 self.assertTrue('HasOldTag.java' in msgs[4].items) 945 self.assertTrue('HasOldTag.java' in msgs[4].items)
946 946
947 class HardcodedGoogleHostsTest(unittest.TestCase):
948
949 def testWarnOnAssignedLiterals(self):
950 input_api = MockInputApi()
951 input_api.files = [
952 MockFile('content/file.cc',
953 ['char* host = "https://www.google.com";']),
954 MockFile('content/file.cc',
955 ['char* host = "https://www.googleapis.com";']),
956 MockFile('content/file.cc',
957 ['char* host = "https://clients1.google.com";']),
958 ]
959
960 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers(
961 input_api, MockOutputApi())
962 self.assertEqual(1, len(warnings))
963 self.assertEqual(3, len(warnings[0].items))
964
965 def testAllowInComment(self):
966 input_api = MockInputApi()
967 input_api.files = [
968 MockFile('content/file.cc',
969 ['char* host = "https://www.aol.com"; // google.com'])
970 ]
971
972 warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers(
973 input_api, MockOutputApi())
974 self.assertEqual(0, len(warnings))
975
947 976
948 if __name__ == '__main__': 977 if __name__ == '__main__':
949 unittest.main() 978 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698