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

Unified Diff: PRESUBMIT_test.py

Issue 885783007: Add PRESUBMIT check if modified UMA histogram name can be found (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Third round of asvitkine@ comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 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 6daae169563d4fb92cdaa78b838fadc0fdbfa98b..8127a43db87c0ec31f65564a6bdb53f4ca8aeb1b 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -270,6 +270,73 @@ class VersionControlConflictsTest(unittest.TestCase):
self.assertTrue('3' in errors[1])
self.assertTrue('5' in errors[2])
+class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
+ 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 = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(0, len(warnings))
+
+ def testTypicalNotMatchedChange(self):
+ diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [MockFile('some/path/foo.cc', diff_cc)]
+ warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(warnings))
+ self.assertEqual('warning', warnings[0].type)
+
+ def testTypicalNotMatchedChangeViaSuffixes(self):
+ diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
+ diff_xml = ['<histogram_suffixes name="SuperHistogram">',
+ ' <suffix name="Dummy"/>',
+ ' <affected-histogram name="Snafu.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 = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(warnings))
+ self.assertEqual('warning', warnings[0].type)
+
+ def testTypicalCorrectlyMatchedChangeViaSuffixes(self):
+ diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
+ diff_xml = ['<histogram_suffixes name="SuperHistogram">',
+ ' <suffix name="Dummy"/>',
+ ' <affected-histogram name="Bla.Foo"/>',
+ '</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 = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(0, len(warnings))
+
+ def testTypicalCorrectlyMatchedChangeViaSuffixesWithSeparator(self):
+ diff_cc = ['UMA_HISTOGRAM_BOOL("Snafu_Dummy", true)']
+ diff_xml = ['<histogram_suffixes name="SuperHistogram" separator="_">',
+ ' <suffix name="Dummy"/>',
+ ' <affected-histogram name="Snafu"/>',
+ '</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 = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(0, len(warnings))
class BadExtensionsTest(unittest.TestCase):
def testBadRejFile(self):
« 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