def load_tests(loader, standard_tests, pattern): del loader, standard_tests, pattern # unused suite = progress_reporter.TestSuite() benchmarks_dir = os.path.dirname(__file__) top_level_dir = os.path.dirname(benchmarks_dir) # Using the default of |index_by_class_name=False| means that if a module # has multiple benchmarks, only the last one is returned. all_benchmarks = discover.DiscoverClasses( benchmarks_dir, top_level_dir, benchmark_module.Benchmark, index_by_class_name=False).values() for benchmark in all_benchmarks: if sys.modules[benchmark.__module__] in _BLACK_LIST_TEST_MODULES: continue # TODO(tonyg): Smoke doesn't work with session_restore yet. if (benchmark.Name().startswith('session_restore') or benchmark.Name().startswith('skpicture_printer')): continue if hasattr(benchmark, 'generated_profile_archive'): # We'd like to test these, but don't know how yet. continue class BenchmarkSmokeTest(unittest.TestCase): pass # tab_switching needs more than one page to test correctly. if 'tab_switching' in benchmark.Name(): method = SmokeTestGenerator(benchmark, num_pages=2) else: method = SmokeTestGenerator(benchmark) # Make sure any decorators are propagated from the original declaration. # (access to protected members) pylint: disable=protected-access # TODO(dpranke): Since we only pick the first test from every class # (above), if that test is disabled, we'll end up not running *any* # test from the class. We should probably discover all of the tests # in a class, and then throw the ones we don't need away instead. disabled_benchmark_attr = decorators.DisabledAttributeName(benchmark) disabled_method_attr = decorators.DisabledAttributeName(method) enabled_benchmark_attr = decorators.EnabledAttributeName(benchmark) enabled_method_attr = decorators.EnabledAttributeName(method) MergeDecorators(method, disabled_method_attr, benchmark, disabled_benchmark_attr) MergeDecorators(method, enabled_method_attr, benchmark, enabled_benchmark_attr) setattr(BenchmarkSmokeTest, benchmark.Name(), method) suite.addTest(BenchmarkSmokeTest(benchmark.Name())) return suite
def SetEnabledStrings(self, enabled_strings): enabled_attr_name = decorators.EnabledAttributeName(self) setattr(self, enabled_attr_name, enabled_strings)