@@ -107,9 +107,12 @@ struct TestConfig {
107
107
/// The filters applied to our test names.
108
108
var filters = [ String] ( )
109
109
110
- /// The tag that we want to run
110
+ /// The tags that we want to run
111
111
var tags = Set < BenchmarkCategory > ( )
112
112
113
+ /// Tests tagged with any of these will not be executed
114
+ var skipTags : Set < BenchmarkCategory > = [ . unstable, . String]
115
+
113
116
/// The scalar multiple of the amount of times a test should be run. This
114
117
/// enables one to cause tests to run for N iterations longer than they
115
118
/// normally would. This is useful when one wishes for a test to run for a
@@ -127,14 +130,6 @@ struct TestConfig {
127
130
/// Is verbose output enabled?
128
131
var verbose : Bool = false
129
132
130
- /// Should we only run the "pre-commit" tests?
131
- var onlyPrecommit : Bool = true
132
-
133
- /// Temporary option to only run tests that have been registered with
134
- /// BenchmarkInfo. This will go away as soon as the benchmarks have been
135
- /// categorized.
136
- var onlyRegistered : Bool = false
137
-
138
133
/// After we run the tests, should the harness sleep to allow for utilities
139
134
/// like leaks that require a PID to run on the test harness.
140
135
var afterRunSleep : Int ?
@@ -145,8 +140,8 @@ struct TestConfig {
145
140
mutating func processArguments( ) -> TestAction {
146
141
let validOptions = [
147
142
" --iter-scale " , " --num-samples " , " --num-iters " ,
148
- " --verbose " , " --delim " , " --run-all " , " -- list" , " --sleep " ,
149
- " --registered " , " --tags "
143
+ " --verbose " , " --delim " , " --list " , " --sleep " ,
144
+ " --tags " , " --skip -tags "
150
145
]
151
146
let maybeBenchArgs : Arguments ? = parseArgs ( validOptions)
152
147
if maybeBenchArgs == nil {
@@ -198,8 +193,21 @@ struct TestConfig {
198
193
}
199
194
}
200
195
201
- if let _ = benchArgs. optionalArgsMap [ " --run-all " ] {
202
- onlyPrecommit = false
196
+ if let x = benchArgs. optionalArgsMap [ " --skip-tags " ] {
197
+ if x. isEmpty { return . fail( " --skip-tags requires a value " ) }
198
+
199
+ // We support specifying multiple tags by splitting on comma, i.e.:
200
+ //
201
+ // --skip-tags=array,set
202
+ //
203
+ // FIXME: If we used Error instead of .fail, then we could have a cleaner
204
+ // impl here using map on x and tags.formUnion.
205
+ for t in x. split ( separator: " , " ) {
206
+ guard let cat = BenchmarkCategory ( rawValue: String ( t) ) else {
207
+ return . fail( " Unknown benchmark category: ' \( t) ' " )
208
+ }
209
+ skipTags. insert ( cat)
210
+ }
203
211
}
204
212
205
213
if let x = benchArgs. optionalArgsMap [ " --sleep " ] {
@@ -217,47 +225,34 @@ struct TestConfig {
217
225
return . listTests
218
226
}
219
227
220
- if let _ = benchArgs. optionalArgsMap [ " --registered " ] {
221
- onlyRegistered = true
222
- }
223
-
224
228
return . run
225
229
}
226
230
227
231
mutating func findTestsToRun( ) {
228
232
// Begin by creating a set of our non-legacy registeredBenchmarks
229
233
var allTests = Set ( registeredBenchmarks)
230
234
231
- // If we are supposed to only run registered tests there isn't anything
232
- // further to do (in the future anyways).
233
- if onlyRegistered {
234
- // FIXME: for now unstable/extra benchmarks are not registered at all, but
235
- // soon they will be handled with a default exclude list.
236
- onlyPrecommit = false
237
- } else {
238
- // Merge legacy benchmark info into allTests. If we already have a
239
- // registered benchmark info, formUnion leaves this alone. This allows for
240
- // us to perform incremental work.
241
- for testList in [ precommitTests, otherTests, stringTests] {
242
- allTests. formUnion ( testList)
243
- }
235
+ // Merge legacy benchmark info into allTests. If we already have a
236
+ // registered benchmark info, formUnion leaves this alone. This allows for
237
+ // us to perform incremental work.
238
+ for testList in [ precommitTests, otherTests, stringTests] {
239
+ allTests. formUnion ( testList)
244
240
}
245
241
246
- let benchmarkNameFilter : Set < String > = {
247
- if onlyPrecommit {
248
- return Set ( precommitTests. map { $0. name } )
249
- }
250
-
251
- return Set ( filters)
252
- } ( )
242
+ let benchmarkNameFilter = Set ( filters)
253
243
254
244
// t is needed so we don't capture an ivar of a mutable inout self.
255
245
let t = tags
246
+ let st = skipTags
256
247
let filteredTests = Array ( allTests. filter { benchInfo in
257
248
if !t. isSubset ( of: benchInfo. tags) {
258
249
return false
259
250
}
260
251
252
+ if !st. isDisjoint ( with: benchInfo. tags) {
253
+ return false
254
+ }
255
+
261
256
// If the user did not specified a benchmark name filter and our tags are
262
257
// a subset of the specified tags by the user, return true. We want to run
263
258
// this test.
0 commit comments