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

Side by Side Diff: tools/bisect-perf-regression_test.py

Issue 256593004: [bisect] - Parse DEPS file manually if execfile fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 6 years, 8 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 | « tools/bisect-perf-regression.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 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import math 5 import math
6 import unittest 6 import unittest
7 7
8 # Special import necessary because filename contains dash characters. 8 # Special import necessary because filename contains dash characters.
9 bisect_perf_module = __import__('bisect-perf-regression') 9 bisect_perf_module = __import__('bisect-perf-regression')
10 10
11 11
12 class BisectPerfRegressionTest(unittest.TestCase): 12 class BisectPerfRegressionTest(unittest.TestCase):
13 """Test case for top-level functions in the bisect-perf-regrssion module.""" 13 """Test case for top-level functions in the bisect-perf-regrssion module."""
14 14
15 def setUp(self): 15 def setUp(self):
16 """Sets up the test environment before each test method.""" 16 """Sets up the test environment before each test method."""
17 pass 17 pass
18 18
19 def tearDown(self): 19 def tearDown(self):
20 """Cleans up the test environment after each test method.""" 20 """Cleans up the test environment after each test method."""
21 pass 21 pass
22 22
23 def testParseDEPSStringManually(self):
24 """Tests DEPS parsing."""
25 bisect_options = bisect_perf_module.BisectOptions()
26 bisect_instance = bisect_perf_module.BisectPerformanceMetrics(
27 None, bisect_options)
28
29 deps_file_contents = """
30 vars = {
31 'ffmpeg_hash':
32 '@ac4a9f31fe2610bd146857bbd55d7a260003a888',
33 'webkit_url':
34 'https://chromium.googlesource.com/chromium/blink.git',
35 'git_url':
36 'https://chromium.googlesource.com',
37 'webkit_rev':
38 '@e01ac0a267d1017288bc67fa3c366b10469d8a24',
39 'angle_revision':
40 '74697cf2064c0a2c0d7e1b1b28db439286766a05'
41 }"""
42
43 # Should only expect svn/git revisions to come through, and urls to be
44 # filtered out.
45 expected_vars_dict = {
46 'ffmpeg_hash': '@ac4a9f31fe2610bd146857bbd55d7a260003a888',
47 'webkit_rev': '@e01ac0a267d1017288bc67fa3c366b10469d8a24',
48 'angle_revision': '74697cf2064c0a2c0d7e1b1b28db439286766a05'
49 }
50 vars_dict = bisect_instance._ParseRevisionsFromDEPSFileManually(
51 deps_file_contents)
52 self.assertEqual(vars_dict, expected_vars_dict)
53
23 def testCalculateTruncatedMeanRaisesError(self): 54 def testCalculateTruncatedMeanRaisesError(self):
24 """CalculateTrunctedMean raises an error when passed an empty list.""" 55 """CalculateTrunctedMean raises an error when passed an empty list."""
25 with self.assertRaises(TypeError): 56 with self.assertRaises(TypeError):
26 bisect_perf_module.CalculateTruncatedMean([], 0) 57 bisect_perf_module.CalculateTruncatedMean([], 0)
27 58
28 def testCalculateMeanSingleNum(self): 59 def testCalculateMeanSingleNum(self):
29 """Tests the CalculateMean function with a single number.""" 60 """Tests the CalculateMean function with a single number."""
30 self.assertEqual(3.0, bisect_perf_module.CalculateMean([3])) 61 self.assertEqual(3.0, bisect_perf_module.CalculateMean([3]))
31 62
32 def testCalculateMeanShortList(self): 63 def testCalculateMeanShortList(self):
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 124
94 def testCalculateRelativeChangeWithNegatives(self): 125 def testCalculateRelativeChangeWithNegatives(self):
95 """Tests that relative change given is always positive.""" 126 """Tests that relative change given is always positive."""
96 self.assertEqual(3.0, bisect_perf_module.CalculateRelativeChange(-1, 2)) 127 self.assertEqual(3.0, bisect_perf_module.CalculateRelativeChange(-1, 2))
97 self.assertEqual(3.0, bisect_perf_module.CalculateRelativeChange(1, -2)) 128 self.assertEqual(3.0, bisect_perf_module.CalculateRelativeChange(1, -2))
98 self.assertEqual(1.0, bisect_perf_module.CalculateRelativeChange(-1, -2)) 129 self.assertEqual(1.0, bisect_perf_module.CalculateRelativeChange(-1, -2))
99 130
100 131
101 if __name__ == '__main__': 132 if __name__ == '__main__':
102 unittest.main() 133 unittest.main()
OLDNEW
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698