| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 import unittest | 4 import unittest |
| 5 | 5 |
| 6 from core import perf_benchmark | 6 from core import perf_benchmark |
| 7 from core import perf_data_generator | 7 from core import perf_data_generator |
| 8 from core.perf_data_generator import BenchmarkMetadata | 8 from core.perf_data_generator import BenchmarkMetadata |
| 9 | 9 |
| 10 from telemetry import benchmark | 10 from telemetry import benchmark |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 }] | 268 }] |
| 269 }, | 269 }, |
| 270 'name': 'test', | 270 'name': 'test', |
| 271 }] | 271 }] |
| 272 self.assertEqual( | 272 self.assertEqual( |
| 273 perf_data_generator.remove_blacklisted_device_tests( | 273 perf_data_generator.remove_blacklisted_device_tests( |
| 274 tests, ['build1-b1', 'build2-b1']), ([], { | 274 tests, ['build1-b1', 'build2-b1']), ([], { |
| 275 'build1-b1': ['test'], | 275 'build1-b1': ['test'], |
| 276 'build2-b1': ['other_test', 'test'], | 276 'build2-b1': ['other_test', 'test'], |
| 277 })) | 277 })) |
| 278 |
| 279 def testExtraTestsAreLoadedFromFile(self): |
| 280 tests = { |
| 281 'Linux Perf': {} |
| 282 } |
| 283 |
| 284 mock_extras_json = ''' |
| 285 { |
| 286 "comment": [ "This is comment and therefore should be skipped." ], |
| 287 "Mojo Linux Perf": {} |
| 288 } |
| 289 ''' |
| 290 |
| 291 mock_waterfall_name = 'hello' |
| 292 |
| 293 def mockIsFile(path): |
| 294 return path.endswith('%s.extras.json' % mock_waterfall_name) |
| 295 |
| 296 with mock.patch('os.path.isfile', side_effect=mockIsFile): |
| 297 with mock.patch('__builtin__.open', |
| 298 mock.mock_open(read_data=mock_extras_json)): |
| 299 perf_data_generator.append_extra_tests({'name': mock_waterfall_name}, |
| 300 tests) |
| 301 |
| 302 self.assertTrue('Linux Perf' in tests) |
| 303 self.assertTrue('Mojo Linux Perf' in tests) |
| 304 self.assertFalse('comment' in tests) |
| OLD | NEW |