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

Unified Diff: Tools/AutoSheriff/analysis_unittest.py

Issue 398823008: WIP: Add auto-sheriff.appspot.com code to Blink Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
Index: Tools/AutoSheriff/analysis_unittest.py
diff --git a/Tools/AutoSheriff/analysis_unittest.py b/Tools/AutoSheriff/analysis_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..96fe33f8ebdfc24032508b2161dc52bdcf71dd8d
--- /dev/null
+++ b/Tools/AutoSheriff/analysis_unittest.py
@@ -0,0 +1,124 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+import analysis
+import json
+
+
+class FailureAnalysisTest(unittest.TestCase):
+ # v8 stays the same, chromium differs, nacl is reduced.
+ MERGE_REGRESSION_RANGES_JSON = """
+[
+ {
+ "failing_revisions": {
+ "v8": "22263",
+ "chromium": "282006",
+ "nacl": "13441"
+ },
+ "passing_revisions": {
+ "v8": "22263",
+ "chromium": "281980",
+ "nacl": "13441"
+ }
+ },
+ {
+ "failing_revisions": {
+ "v8": "22263",
+ "chromium": "282022",
+ "nacl": "13452"
+ },
+ "passing_revisions": {
+ "v8": "22263",
+ "chromium": "281989",
+ "nacl": "13441"
+ }
+ }
+]
+"""
+
+ MERGE_REGRESSION_RANGES_JSON_NULL = """
+[
+ {
+ "failing_revisions": {
+ "v8": "22263",
+ "nacl": "13441"
+ },
+ "passing_revisions": null
+ },
+ {
+ "failing_revisions": {
+ "v8": "22263",
+ "nacl": null
+ },
+ "passing_revisions": {
+ "v8": "22263",
+ "nacl": "13441"
+ }
+ }
+]
+"""
+
+ def test_merge_regression_ranges(self):
+ alerts = json.loads(self.MERGE_REGRESSION_RANGES_JSON)
+ passing, failing = analysis.merge_regression_ranges(alerts)
+ expected_pass = { 'v8': '22263', 'chromium': '281989', 'nacl': '13441' }
+ expected_fail = { 'v8': '22263', 'chromium': '282006', 'nacl': '13441' }
+ self.assertEquals(expected_fail, failing)
+ self.assertEquals(expected_pass, passing)
+
+ alerts = json.loads(self.MERGE_REGRESSION_RANGES_JSON_NULL)
+ passing, failing = analysis.merge_regression_ranges(alerts)
+ expected_pass = None
+ expected_fail = { 'v8': '22263', 'nacl': '13441' }
+ self.assertEquals(expected_fail, failing)
+ self.assertEquals(expected_pass, passing)
+
+
+ def test_flatten_to_commit_list(self):
+ passing = { 'v8': '1', 'chromium': '4'}
ojan 2014/07/22 02:01:23 Inconsistent spacing here and in a few places belo
+ failing = { 'v8': '2', 'chromium': '4'}
+ commit_list = analysis.flatten_to_commit_list(passing, failing)
+ self.assertEquals(commit_list, ['v8:2'])
+
+
+ def test_range_key_for_group(self):
+ failing = { 'v8': '2', 'chromium': '4'}
+ group = {
+ 'merged_last_passing': None,
+ 'merged_first_failing': failing,
+ 'sort_key': 'foobar',
+ }
+ range_key = analysis.range_key_for_group(group)
+ self.assertEquals(range_key, 'foo<=v8:2 <=chromium:4')
+
+ MERGE_BY_RANGE_JSON = """
+[
+ {
+ "merged_last_passing": { "v8": "1" },
+ "merged_first_failing": { "v8": "2" },
+ "sort_key": "dromaeo.domcoreattr",
+ "failure_keys": [
+ ]
+ },
+ {
+ "merged_last_passing": { "v8": "1" },
+ "merged_first_failing": { "v8": "2" },
+ "sort_key": "dromaeo.jslibmodifyprototype",
+ "failure_keys": [
+ ]
+ }
+]
+"""
+
+ def test_merge_by_range(self):
+ groups = json.loads(self.MERGE_BY_RANGE_JSON)
+ merged = analysis.merge_by_range(groups)
+ self.assertEquals(len(merged), 1)
+ self.assertEquals(merged[0]['sort_key'], 'dromaeo.')
+ self.assertEquals(analysis.merge_by_range([]), [])
+
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698