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

Side by Side Diff: scripts/slave/unittests/runtest_test.py

Issue 2330133002: Updating the SwarmingIsolatedScriptTest to upload chartjson results to the (Closed)
Patch Set: Updating steps.py to utilize new swarming api Created 4 years, 3 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """Unit tests for functions in runtest.py.""" 6 """Unit tests for functions in runtest.py."""
7 7
8 import unittest 8 import unittest
9 9
10 import test_env # pylint: disable=W0403,W0611 10 import test_env # pylint: disable=W0403,W0611
11 11
12 import mock 12 import mock
13 from slave import runtest 13 from slave import runtest
14 14
15 15
16 # Note: The git-svn id / cr pos is intentionally modified.
17 # Also commit messages modified to be < 80 char.
18 CHROMIUM_LOG = """
19 Update GPU rasterization device whitelist
20
21 This replaces the whitelisting of all Qualcomm GPUs on
22 Android 4.4 with whitelisting all Android 4.4 devices
23 with GL ES version >= 3.0.
24
25 BUG=405646
26
27 Review URL: https://codereview.chromium.org/468103003
28
29 Cr-Commit-Position: refs/heads/master@{#291141}
30 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291140 0039d316-1c4b-4281
31 """
32
33 BLINK_LOG = """
34 [Sheriff-o-matic] Remove race condition on the commit list.
35
36 By always modifying the same list of commits, we ensure that data binding
37
38 As well, renamed "revisionLog" to "commitLog" everywhere, to better reflect
39
40 BUG=405327
41 NOTRY=true
42
43 Review URL: https://codereview.chromium.org/485253004
44
45 git-svn-id: svn://svn.chromium.org/blink/trunk@180728 bbb929c8-8fbe-4397-9dbb-9
46 """
47
48
49 class FakeLogProcessor(object): 16 class FakeLogProcessor(object):
50 """A fake log processor to use in the test below.""" 17 """A fake log processor to use in the test below."""
51 18
52 def __init__(self, output): 19 def __init__(self, output):
53 self._output = output 20 self._output = output
54 21
55 def PerformanceLogs(self): 22 def PerformanceLogs(self):
56 return self._output 23 return self._output
57 24
58 25
(...skipping 29 matching lines...) Expand all
88 # If it doesn't meet this expectation, ignore that graph. 55 # If it doesn't meet this expectation, ignore that graph.
89 self.assertEqual({}, runtest._GetDataFromLogProcessor(log_processor)) 56 self.assertEqual({}, runtest._GetDataFromLogProcessor(log_processor))
90 57
91 def test_GetDataFromLogProcessor_InvalidJson(self): 58 def test_GetDataFromLogProcessor_InvalidJson(self):
92 log_processor = FakeLogProcessor({ 59 log_processor = FakeLogProcessor({
93 'graph-summary.dat': ['this string is not valid json'] 60 'graph-summary.dat': ['this string is not valid json']
94 }) 61 })
95 self.assertEqual({}, runtest._GetDataFromLogProcessor(log_processor)) 62 self.assertEqual({}, runtest._GetDataFromLogProcessor(log_processor))
96 63
97 64
98 class GetGitRevisionTest(unittest.TestCase):
99 """Tests related to getting revisions from a directory."""
100 def test_GitSvnCase(self):
101 # pylint: disable=W0212
102 self.assertEqual(runtest._GetGitCommitPositionFromLog(CHROMIUM_LOG),
103 '291141')
104 # pylint: disable=W0212
105 self.assertEqual(runtest._GetGitCommitPositionFromLog(BLINK_LOG),
106 '180728')
107
108 def test_GetCommitPosFromBuildPropTest(self):
109 """Tests related to getting a commit position from build properties."""
110 # pylint: disable=W0212
111 self.assertEqual(runtest._GetCommitPos(
112 {'got_revision_cp': 'refs/heads/master@{#12345}'}), 12345)
113 # pylint: disable=W0212
114 self.assertIsNone(runtest._GetCommitPos({'got_revision': 12345}))
115
116
117 class SendResultsToDashboardTest(unittest.TestCase): 65 class SendResultsToDashboardTest(unittest.TestCase):
118 """Tests related to sending requests and saving data from failed requests.""" 66 """Tests related to sending requests and saving data from failed requests."""
119 67
120 def setUp(self): 68 def setUp(self):
121 super(SendResultsToDashboardTest, self).setUp() 69 super(SendResultsToDashboardTest, self).setUp()
122 70
123 # Testing private method _GetDataFromLogProcessor. 71 # Testing private method _GetDataFromLogProcessor.
124 # Also, this test method doesn't reference self. 72 # Also, this test method doesn't reference self.
125 # pylint: disable=W0212,R0201 73 # pylint: disable=W0212,R0201
126 @mock.patch('slave.runtest._GetDataFromLogProcessor') 74 @mock.patch('slave.runtest._GetDataFromLogProcessor')
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 'buildnumber': 123, 173 'buildnumber': 123,
226 'revisions': {'rev': 343}, 174 'revisions': {'rev': 343},
227 'supplemental_columns': {}}) 175 'supplemental_columns': {}})
228 176
229 # Should not call functions to generate JSON and send to JSON if Telemetry 177 # Should not call functions to generate JSON and send to JSON if Telemetry
230 # did not return results. 178 # did not return results.
231 self.assertFalse(MakeDashboardJsonV1.called) 179 self.assertFalse(MakeDashboardJsonV1.called)
232 self.assertFalse(SendResults.called) 180 self.assertFalse(SendResults.called)
233 fake_results_tracker.Cleanup.assert_called_with() 181 fake_results_tracker.Cleanup.assert_called_with()
234 182
235 def test_GetTelemetryRevisions(self):
236 options = mock.MagicMock()
237 options.point_id = 1470050195
238 options.revision = '294850'
239 options.webkit_revision = '34f9d01'
240 options.build_properties = {
241 'got_webrtc_revision': None,
242 'got_v8_revision': 'undefined',
243 'git_revision': '9a7b354',
244 }
245 versions = runtest._GetTelemetryRevisions(options)
246 self.assertEqual(
247 {'rev': '294850', 'webkit_rev': '34f9d01', 'git_revision': '9a7b354',
248 'point_id': 1470050195},
249 versions)
250 183
251 if __name__ == '__main__': 184 if __name__ == '__main__':
252 unittest.main() 185 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698