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

Side by Side Diff: tools/perf/measurements/measurement_smoke_test.py

Issue 789363002: TimelineBasedMeasurement(object) instead of TimelineBasedMeasurement(page_test.PageTest) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 11 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/perf/benchmarks/v8.py ('k') | tools/telemetry/telemetry/benchmark.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 # 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 """Measurement smoke test to make sure that no new action_name_to_run is 4 """Measurement smoke test to make sure that no new action_name_to_run is
5 defined.""" 5 defined."""
6 6
7 import os 7 import os
8 import logging 8 import logging
9 import unittest 9 import unittest
10 10
11 from telemetry import benchmark as benchmark_module 11 from telemetry import benchmark as benchmark_module
12 from telemetry.core import discover 12 from telemetry.core import discover
13 from telemetry.page import page_test 13 from telemetry.page import page_test
14 from telemetry.unittest_util import options_for_unittests 14 from telemetry.unittest_util import options_for_unittests
15 from telemetry.util import classes 15 from telemetry.util import classes
16 from telemetry.web_perf import timeline_based_measurement
16 17
17 18
18 # Do NOT add new items to this list! 19 # Do NOT add new items to this list!
19 # crbug.com/418375 20 # crbug.com/418375
20 _ACTION_NAMES_WHITE_LIST = ( 21 _ACTION_NAMES_WHITE_LIST = (
21 '', 22 '',
22 'RunPageInteractions', 23 'RunPageInteractions',
23 ) 24 )
24 25
25 26
(...skipping 11 matching lines...) Expand all
37 if classes.IsDirectlyConstructable(measurement_class): 38 if classes.IsDirectlyConstructable(measurement_class):
38 page_test_instances.append(measurement_class()) 39 page_test_instances.append(measurement_class())
39 40
40 all_benchmarks_classes = discover.DiscoverClasses( 41 all_benchmarks_classes = discover.DiscoverClasses(
41 benchmarks_dir, top_level_dir, benchmark_module.Benchmark).values() 42 benchmarks_dir, top_level_dir, benchmark_module.Benchmark).values()
42 43
43 # Get all page test instances from defined benchmarks. 44 # Get all page test instances from defined benchmarks.
44 # Note: since this depends on the command line options, there is no guaranteed 45 # Note: since this depends on the command line options, there is no guaranteed
45 # that this will generate all possible page test instances but it's worth 46 # that this will generate all possible page test instances but it's worth
46 # enough for smoke test purpose. 47 # enough for smoke test purpose.
47
48 for benchmark_class in all_benchmarks_classes: 48 for benchmark_class in all_benchmarks_classes:
49 options = options_for_unittests.GetCopy() 49 options = options_for_unittests.GetCopy()
50 parser = options.CreateParser() 50 parser = options.CreateParser()
51 benchmark_class.AddCommandLineArgs(parser) 51 benchmark_class.AddCommandLineArgs(parser)
52 benchmark_module.AddCommandLineArgs(parser) 52 benchmark_module.AddCommandLineArgs(parser)
53 benchmark_class.SetArgumentDefaults(parser) 53 benchmark_class.SetArgumentDefaults(parser)
54 options.MergeDefaultValues(parser.get_default_values()) 54 options.MergeDefaultValues(parser.get_default_values())
55 page_test_instances.append(benchmark_class().CreatePageTest(options)) 55 pt = benchmark_class().CreatePageTest(options)
56 if not isinstance(pt, timeline_based_measurement.TimelineBasedMeasurement):
57 page_test_instances.append(pt)
56 58
57 return page_test_instances 59 return page_test_instances
58 60
59 61
60 class MeasurementSmokeTest(unittest.TestCase): 62 class MeasurementSmokeTest(unittest.TestCase):
61 # TODO(nednguyen): Remove this test when crbug.com/418375 is marked fixed. 63 # TODO(nednguyen): Remove this test when crbug.com/418375 is marked fixed.
62 def testNoNewActionNameToRunUsed(self): 64 def testNoNewActionNameToRunUsed(self):
63 invalid_tests = [] 65 invalid_tests = []
64 for test in _GetAllPossiblePageTestInstances(): 66 for test in _GetAllPossiblePageTestInstances():
67 if not hasattr(test, 'action_name_to_run'):
68 invalid_tests.append(test)
69 logging.error('Test %s missing action_name_to_run attribute.',
70 test.__class__.__name__)
65 if test.action_name_to_run not in _ACTION_NAMES_WHITE_LIST: 71 if test.action_name_to_run not in _ACTION_NAMES_WHITE_LIST:
66 invalid_tests.append(test) 72 invalid_tests.append(test)
67 logging.error('Page test %s has invalid action_name_to_run: %s' % 73 logging.error('Page test %s has invalid action_name_to_run: %s' %
68 (test.__class__.__name__, repr(test.action_name_to_run))) 74 (test.__class__.__name__, repr(test.action_name_to_run)))
69 self.assertFalse( 75 self.assertFalse(
70 invalid_tests, 76 invalid_tests,
71 'New page tests with invalid action_name_to_run found. Please only use ' 77 'New page tests with invalid action_name_to_run found. Please only use '
72 'action_name_to_run="RunPageInteractions" (crbug.com/418375).') 78 'action_name_to_run="RunPageInteractions" (crbug.com/418375).')
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/v8.py ('k') | tools/telemetry/telemetry/benchmark.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698