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

Unified Diff: PRESUBMIT_test.py

Issue 766713004: Add PRESUBMIT check if modified UMA histogram name can be found (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« PRESUBMIT.py ('K') | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 2f377084548507fa30d8de02ced24d803ef2e94d..1c97191755654d17440de816a3debdeb2d6ebf10 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -346,6 +346,28 @@ class VersionControlConflictsTest(unittest.TestCase):
self.assertTrue('3' in errors[1])
self.assertTrue('5' in errors[2])
+class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
+ def testTypicalNotMatchedChange(self):
+ diff = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [MockFile('some/path/foo.cc', diff)]
+ warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(warnings))
+ self.assertEqual('warning', warnings[0].type)
+
+ def testTypicalCorrectlyMatchedChange(self):
+ diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
+ diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>']
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockFile('some/path/foo.cc', diff_cc),
+ MockFile('tools/metrics/histograms/histograms.xml', diff_xml),
+ ]
+ warnings = []
+ warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(0, len(warnings))
class BadExtensionsTest(unittest.TestCase):
def testBadRejFile(self):
« PRESUBMIT.py ('K') | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698