OLD | NEW |
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 """Run the first page of one benchmark for every module. | 5 """Run the first page of one benchmark for every module. |
6 | 6 |
7 Only benchmarks that have a composable measurement are included. | 7 Only benchmarks that have a composable measurement are included. |
8 Ideally this test would be comprehensive, however, running one page | 8 Ideally this test would be comprehensive, however, running one page |
9 of every benchmark would run impractically long. | 9 of every benchmark would run impractically long. |
10 """ | 10 """ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 pass | 97 pass |
98 | 98 |
99 method = SmokeTestGenerator(benchmark) | 99 method = SmokeTestGenerator(benchmark) |
100 | 100 |
101 # Make sure any decorators are propagated from the original declaration. | 101 # Make sure any decorators are propagated from the original declaration. |
102 # (access to protected members) pylint: disable=W0212 | 102 # (access to protected members) pylint: disable=W0212 |
103 # TODO(dpranke): Since we only pick the first test from every class | 103 # TODO(dpranke): Since we only pick the first test from every class |
104 # (above), if that test is disabled, we'll end up not running *any* | 104 # (above), if that test is disabled, we'll end up not running *any* |
105 # test from the class. We should probably discover all of the tests | 105 # test from the class. We should probably discover all of the tests |
106 # in a class, and then throw the ones we don't need away instead. | 106 # in a class, and then throw the ones we don't need away instead. |
107 if hasattr(benchmark, '_enabled_strings'): | 107 |
108 method._enabled_strings = benchmark._enabled_strings | 108 # Merge decorators. |
109 if hasattr(benchmark, '_disabled_strings'): | 109 for attribute in ['_enabled_strings', '_disabled_strings']: |
110 method._disabled_strings = benchmark._disabled_strings | 110 # Do set union of attributes to eliminate duplicates. |
| 111 merged_attributes = list(set(getattr(method, attribute, []) + |
| 112 getattr(benchmark, attribute, []))) |
| 113 if merged_attributes: |
| 114 setattr(method, attribute, merged_attributes) |
| 115 |
| 116 # Handle the case where the benchmark is Enabled/Disabled everywhere. |
| 117 if (getattr(method, attribute, None) == [] or |
| 118 getattr(benchmark, attribute, None) == []): |
| 119 setattr(method, attribute, []) |
| 120 |
111 setattr(BenchmarkSmokeTest, benchmark.Name(), method) | 121 setattr(BenchmarkSmokeTest, benchmark.Name(), method) |
112 | 122 |
113 suite.addTest(BenchmarkSmokeTest(benchmark.Name())) | 123 suite.addTest(BenchmarkSmokeTest(benchmark.Name())) |
114 | 124 |
115 return suite | 125 return suite |
OLD | NEW |