@@ -356,32 +356,32 @@ extension RandomAccessCollection<String> {
356
356
/// Get the value of the command line argument with the given name.
357
357
///
358
358
/// - Parameters:
359
- /// - key : The key or name of the argument, e.g. `"--attachments-path"`.
360
- /// - index: The index where `key ` should be found, or `nil` to search the
359
+ /// - label : The label or name of the argument, e.g. `"--attachments-path"`.
360
+ /// - index: The index where `label ` should be found, or `nil` to search the
361
361
/// entire collection.
362
362
///
363
- /// - Returns: The value of the argument named by `key ` at `index`. If no
363
+ /// - Returns: The value of the argument named by `label ` at `index`. If no
364
364
/// value is available, or if `index` is not `nil` and the argument at
365
- /// `index` is not named `key `, returns `nil`.
365
+ /// `index` is not named `label `, returns `nil`.
366
366
///
367
- /// This function handles arguments of the form `--key value` and
368
- /// `--key =value`. Other argument syntaxes are not supported.
369
- fileprivate func argumentValue( forKey key : String , at index: Index ? = nil ) -> String ? {
367
+ /// This function handles arguments of the form `--label value` and
368
+ /// `--label =value`. Other argument syntaxes are not supported.
369
+ fileprivate func argumentValue( forLabel label : String , at index: Index ? = nil ) -> String ? {
370
370
guard let index else {
371
371
return indices. lazy
372
- . compactMap { argumentValue ( forKey : key , at: $0) }
372
+ . compactMap { argumentValue ( forLabel : label , at: $0) }
373
373
. first
374
374
}
375
375
376
376
let element = self [ index]
377
- if element == key {
377
+ if element == label {
378
378
let nextIndex = self . index ( after: index)
379
379
if nextIndex < endIndex {
380
380
return self [ nextIndex]
381
381
}
382
382
} else {
383
383
// Find an element equal to something like "--foo=bar" and split it.
384
- let prefix = " \( key ) = "
384
+ let prefix = " \( label ) = "
385
385
if element. hasPrefix ( prefix) , let equalsIndex = element. firstIndex ( of: " = " ) {
386
386
return String ( element [ equalsIndex... ] . dropFirst ( ) )
387
387
}
@@ -414,7 +414,7 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
414
414
// NOTE: While the output event stream is opened later, it is necessary to
415
415
// open the configuration file early (here) in order to correctly construct
416
416
// the resulting __CommandLineArguments_v0 instance.
417
- if let path = args. argumentValue ( forKey : " --configuration-path " ) ?? args. argumentValue ( forKey : " --experimental-configuration-path " ) {
417
+ if let path = args. argumentValue ( forLabel : " --configuration-path " ) ?? args. argumentValue ( forLabel : " --experimental-configuration-path " ) {
418
418
let file = try FileHandle ( forReadingAtPath: path)
419
419
let configurationJSON = try file. readToEnd ( )
420
420
result = try configurationJSON. withUnsafeBufferPointer { configurationJSON in
@@ -427,17 +427,17 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
427
427
}
428
428
429
429
// Event stream output
430
- if let path = args. argumentValue ( forKey : " --event-stream-output-path " ) ?? args. argumentValue ( forKey : " --experimental-event-stream-output " ) {
430
+ if let path = args. argumentValue ( forLabel : " --event-stream-output-path " ) ?? args. argumentValue ( forLabel : " --experimental-event-stream-output " ) {
431
431
result. eventStreamOutputPath = path
432
432
}
433
433
434
434
// Event stream version
435
435
do {
436
436
var versionString : String ?
437
437
var allowExperimental = false
438
- versionString = args. argumentValue ( forKey : " --event-stream-version " )
438
+ versionString = args. argumentValue ( forLabel : " --event-stream-version " )
439
439
if versionString == nil {
440
- versionString = args. argumentValue ( forKey : " --experimental-event-stream-version " )
440
+ versionString = args. argumentValue ( forLabel : " --experimental-event-stream-version " )
441
441
if versionString != nil {
442
442
allowExperimental = true
443
443
}
@@ -463,12 +463,12 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
463
463
#endif
464
464
465
465
// XML output
466
- if let xunitOutputPath = args. argumentValue ( forKey : " --xunit-output " ) {
466
+ if let xunitOutputPath = args. argumentValue ( forLabel : " --xunit-output " ) {
467
467
result. xunitOutput = xunitOutputPath
468
468
}
469
469
470
470
// Attachment output
471
- if let attachmentsPath = args. argumentValue ( forKey : " --attachments-path " ) ?? args. argumentValue ( forKey : " --experimental-attachments-path " ) {
471
+ if let attachmentsPath = args. argumentValue ( forLabel : " --attachments-path " ) ?? args. argumentValue ( forLabel : " --experimental-attachments-path " ) {
472
472
result. attachmentsPath = attachmentsPath
473
473
}
474
474
#endif
@@ -487,12 +487,12 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
487
487
}
488
488
489
489
// Whether or not to symbolicate backtraces in the event stream.
490
- if let symbolicateBacktraces = args. argumentValue ( forKey : " --symbolicate-backtraces " ) {
490
+ if let symbolicateBacktraces = args. argumentValue ( forLabel : " --symbolicate-backtraces " ) {
491
491
result. symbolicateBacktraces = symbolicateBacktraces
492
492
}
493
493
494
494
// Verbosity
495
- if let verbosity = args. argumentValue ( forKey : " --verbosity " ) . flatMap ( Int . init) {
495
+ if let verbosity = args. argumentValue ( forLabel : " --verbosity " ) . flatMap ( Int . init) {
496
496
result. verbosity = verbosity
497
497
}
498
498
if args. contains ( " --verbose " ) || args. contains ( " -v " ) {
@@ -507,7 +507,7 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
507
507
508
508
// Filtering
509
509
func filterValues( forArgumentsWithLabel label: String ) -> [ String ] {
510
- args. indices. compactMap { args. argumentValue ( forKey : label, at: $0) }
510
+ args. indices. compactMap { args. argumentValue ( forLabel : label, at: $0) }
511
511
}
512
512
let filter = filterValues ( forArgumentsWithLabel: " --filter " )
513
513
if !filter. isEmpty {
@@ -519,10 +519,10 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
519
519
}
520
520
521
521
// Set up the iteration policy for the test run.
522
- if let repetitions = args. argumentValue ( forKey : " --repetitions " ) . flatMap ( Int . init) {
522
+ if let repetitions = args. argumentValue ( forLabel : " --repetitions " ) . flatMap ( Int . init) {
523
523
result. repetitions = repetitions
524
524
}
525
- if let repeatUntil = args. argumentValue ( forKey : " --repeat-until " ) {
525
+ if let repeatUntil = args. argumentValue ( forLabel : " --repeat-until " ) {
526
526
result. repeatUntil = repeatUntil
527
527
}
528
528
0 commit comments