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

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

Issue 2330133002: Updating the SwarmingIsolatedScriptTest to upload chartjson results to the (Closed)
Patch Set: Fixing presubmit issues Created 4 years, 2 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 | « scripts/slave/slave_utils.py ('k') | scripts/slave/unittests/slave_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 'buildnumber': 123, 215 'buildnumber': 123,
268 'revisions': {'rev': 343}, 216 'revisions': {'rev': 343},
269 'supplemental_columns': {}}) 217 'supplemental_columns': {}})
270 218
271 # Should not call functions to generate JSON and send to JSON if Telemetry 219 # Should not call functions to generate JSON and send to JSON if Telemetry
272 # did not return results. 220 # did not return results.
273 self.assertFalse(MakeDashboardJsonV1.called) 221 self.assertFalse(MakeDashboardJsonV1.called)
274 self.assertFalse(SendResults.called) 222 self.assertFalse(SendResults.called)
275 fake_results_tracker.Cleanup.assert_called_with() 223 fake_results_tracker.Cleanup.assert_called_with()
276 224
277 def test_GetTelemetryRevisions(self):
278 options = mock.MagicMock()
279 options.point_id = 1470050195
280 options.revision = '294850'
281 options.webkit_revision = '34f9d01'
282 options.build_properties = {
283 'got_webrtc_revision': None,
284 'got_v8_revision': 'undefined',
285 'git_revision': '9a7b354',
286 }
287 versions = runtest._GetTelemetryRevisions(options)
288 self.assertEqual(
289 {'rev': '294850', 'webkit_rev': '34f9d01', 'git_revision': '9a7b354',
290 'point_id': 1470050195},
291 versions)
292 225
293 if __name__ == '__main__': 226 if __name__ == '__main__':
294 unittest.main() 227 unittest.main()
OLDNEW
« no previous file with comments | « scripts/slave/slave_utils.py ('k') | scripts/slave/unittests/slave_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698