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

Side by Side Diff: telemetry/telemetry/internal/story_runner_unittest.py

Issue 3001873002: [Telemetry] Add CanRunOnPlatform to story_runner and benchmark class. (Closed)
Patch Set: Make Method Private Created 3 years, 4 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 # 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 json 5 import json
6 import math 6 import math
7 import os 7 import os
8 import shutil 8 import shutil
9 import StringIO 9 import StringIO
10 import sys 10 import sys
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 options.results_label = None 1245 options.results_label = None
1246 options.reset_results = False 1246 options.reset_results = False
1247 options.use_live_sites = False 1247 options.use_live_sites = False
1248 options.max_failures = 100 1248 options.max_failures = 100
1249 options.pause = None 1249 options.pause = None
1250 options.pageset_repeat = 1 1250 options.pageset_repeat = 1
1251 options.output_formats = ['chartjson'] 1251 options.output_formats = ['chartjson']
1252 options.run_disabled_tests = False 1252 options.run_disabled_tests = False
1253 return options 1253 return options
1254 1254
1255 def testRunBenchmarkDisabledBenchmarkViaCanRunonPlatform(self):
1256 fake_benchmark = FakeBenchmark()
1257 fake_benchmark.SUPPORTED_PLATFORMS = []
1258 options = self._GenerateBaseBrowserFinderOptions()
1259 tmp_path = tempfile.mkdtemp()
1260 try:
1261 options.output_dir = tmp_path
1262 story_runner.RunBenchmark(fake_benchmark, options)
1263 with open(os.path.join(tmp_path, 'results-chart.json')) as f:
1264 data = json.load(f)
1265 self.assertFalse(data['enabled'])
1266 finally:
1267 shutil.rmtree(tmp_path)
1268
1269 # TODO(rnephew): Remove this test when we no longer use
charliea (OOO until 10-5) 2017/08/22 17:22:18 Won't "PermanentlyDisableBenchmark" just become "T
rnephew (Reviews Here) 2017/08/22 17:33:20 Reworded to Refactor instead of Remove.
1270 # expectations.PermanentlyDisableBenchmark() to disable benchmarks.
1255 def testRunBenchmarkDisabledBenchmark(self): 1271 def testRunBenchmarkDisabledBenchmark(self):
1256 fake_benchmark = FakeBenchmark() 1272 fake_benchmark = FakeBenchmark()
1257 fake_benchmark.disabled = True 1273 fake_benchmark.disabled = True
1258 options = self._GenerateBaseBrowserFinderOptions() 1274 options = self._GenerateBaseBrowserFinderOptions()
1259 tmp_path = tempfile.mkdtemp() 1275 tmp_path = tempfile.mkdtemp()
1260 try: 1276 try:
1261 options.output_dir = tmp_path 1277 options.output_dir = tmp_path
1262 story_runner.RunBenchmark(fake_benchmark, options) 1278 story_runner.RunBenchmark(fake_benchmark, options)
1263 with open(os.path.join(tmp_path, 'results-chart.json')) as f: 1279 with open(os.path.join(tmp_path, 'results-chart.json')) as f:
1264 data = json.load(f) 1280 data = json.load(f)
1265 self.assertFalse(data['enabled']) 1281 self.assertFalse(data['enabled'])
1266 finally: 1282 finally:
1267 shutil.rmtree(tmp_path) 1283 shutil.rmtree(tmp_path)
1268 1284
1285 # TODO(rnephew): Remove this test when we no longer use
1286 # expectations.PermanentlyDisableBenchmark() to disable benchmarks.
1269 def testRunBenchmarkDisabledBenchmarkCannotOverriddenByCommandLine(self): 1287 def testRunBenchmarkDisabledBenchmarkCannotOverriddenByCommandLine(self):
1270 fake_benchmark = FakeBenchmark() 1288 fake_benchmark = FakeBenchmark()
1271 fake_benchmark.disabled = True 1289 fake_benchmark.disabled = True
1272 options = self._GenerateBaseBrowserFinderOptions() 1290 options = self._GenerateBaseBrowserFinderOptions()
1273 options.run_disabled_tests = True 1291 options.run_disabled_tests = True
1274 temp_path = tempfile.mkdtemp() 1292 temp_path = tempfile.mkdtemp()
1275 try: 1293 try:
1276 options.output_dir = temp_path 1294 options.output_dir = temp_path
1277 story_runner.RunBenchmark(fake_benchmark, options) 1295 story_runner.RunBenchmark(fake_benchmark, options)
1278 with open(os.path.join(temp_path, 'results-chart.json')) as f: 1296 with open(os.path.join(temp_path, 'results-chart.json')) as f:
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 fake_benchmark.story_disabled = True 1403 fake_benchmark.story_disabled = True
1386 options = self._GenerateBaseBrowserFinderOptions() 1404 options = self._GenerateBaseBrowserFinderOptions()
1387 tmp_path = tempfile.mkdtemp() 1405 tmp_path = tempfile.mkdtemp()
1388 try: 1406 try:
1389 options.output_dir = tmp_path 1407 options.output_dir = tmp_path
1390 rc = story_runner.RunBenchmark(fake_benchmark, options) 1408 rc = story_runner.RunBenchmark(fake_benchmark, options)
1391 # Test should return 0 since only error messages are logged. 1409 # Test should return 0 since only error messages are logged.
1392 self.assertEqual(rc, 0) 1410 self.assertEqual(rc, 0)
1393 finally: 1411 finally:
1394 shutil.rmtree(tmp_path) 1412 shutil.rmtree(tmp_path)
OLDNEW
« telemetry/telemetry/internal/story_runner.py ('K') | « telemetry/telemetry/internal/story_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698