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

Side by Side Diff: PRESUBMIT_test.py

Issue 841323002: Revert of Add PRESUBMIT check if modified UMA histogram name can be found (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 11 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 '=======', 263 '=======',
264 ' ScopedTempDir temp_dir_;', 264 ' ScopedTempDir temp_dir_;',
265 '>>>>>>> master'] 265 '>>>>>>> master']
266 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( 266 errors = PRESUBMIT._CheckForVersionControlConflictsInFile(
267 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) 267 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
268 self.assertEqual(3, len(errors)) 268 self.assertEqual(3, len(errors))
269 self.assertTrue('1' in errors[0]) 269 self.assertTrue('1' in errors[0])
270 self.assertTrue('3' in errors[1]) 270 self.assertTrue('3' in errors[1])
271 self.assertTrue('5' in errors[2]) 271 self.assertTrue('5' in errors[2])
272 272
273 class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
274 def testTypicalNotMatchedChange(self):
275 diff = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
276 mock_input_api = MockInputApi()
277 mock_input_api.files = [MockFile('some/path/foo.cc', diff)]
278 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
279 MockOutputApi())
280 self.assertEqual(1, len(warnings))
281 self.assertEqual('warning', warnings[0].type)
282
283 def testTypicalCorrectlyMatchedChange(self):
284 diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
285 diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>']
286 mock_input_api = MockInputApi()
287 mock_input_api.files = [
288 MockFile('some/path/foo.cc', diff_cc),
289 MockFile('tools/metrics/histograms/histograms.xml', diff_xml),
290 ]
291 warnings = []
292 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
293 MockOutputApi())
294 self.assertEqual(0, len(warnings))
295 273
296 class BadExtensionsTest(unittest.TestCase): 274 class BadExtensionsTest(unittest.TestCase):
297 def testBadRejFile(self): 275 def testBadRejFile(self):
298 mock_input_api = MockInputApi() 276 mock_input_api = MockInputApi()
299 mock_input_api.files = [ 277 mock_input_api.files = [
300 MockFile('some/path/foo.cc', ''), 278 MockFile('some/path/foo.cc', ''),
301 MockFile('some/path/foo.cc.rej', ''), 279 MockFile('some/path/foo.cc.rej', ''),
302 MockFile('some/path2/bar.h.rej', ''), 280 MockFile('some/path2/bar.h.rej', ''),
303 ] 281 ]
304 282
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 690 }
713 for master, bots in bots.iteritems(): 691 for master, bots in bots.iteritems():
714 for bot in bots: 692 for bot in bots:
715 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), 693 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot),
716 'bot=%s: expected %s, computed %s' % ( 694 'bot=%s: expected %s, computed %s' % (
717 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) 695 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot)))
718 696
719 697
720 if __name__ == '__main__': 698 if __name__ == '__main__':
721 unittest.main() 699 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