Skip to content

Commit b500ac3

Browse files
committed
key -> label for consistency
1 parent d5c17c1 commit b500ac3

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -356,32 +356,32 @@ extension RandomAccessCollection<String> {
356356
/// Get the value of the command line argument with the given name.
357357
///
358358
/// - 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
361361
/// entire collection.
362362
///
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
364364
/// 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`.
366366
///
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? {
370370
guard let index else {
371371
return indices.lazy
372-
.compactMap { argumentValue(forKey: key, at: $0) }
372+
.compactMap { argumentValue(forLabel: label, at: $0) }
373373
.first
374374
}
375375

376376
let element = self[index]
377-
if element == key {
377+
if element == label {
378378
let nextIndex = self.index(after: index)
379379
if nextIndex < endIndex {
380380
return self[nextIndex]
381381
}
382382
} else {
383383
// Find an element equal to something like "--foo=bar" and split it.
384-
let prefix = "\(key)="
384+
let prefix = "\(label)="
385385
if element.hasPrefix(prefix), let equalsIndex = element.firstIndex(of: "=") {
386386
return String(element[equalsIndex...].dropFirst())
387387
}
@@ -414,7 +414,7 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
414414
// NOTE: While the output event stream is opened later, it is necessary to
415415
// open the configuration file early (here) in order to correctly construct
416416
// 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") {
418418
let file = try FileHandle(forReadingAtPath: path)
419419
let configurationJSON = try file.readToEnd()
420420
result = try configurationJSON.withUnsafeBufferPointer { configurationJSON in
@@ -427,17 +427,17 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
427427
}
428428

429429
// 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") {
431431
result.eventStreamOutputPath = path
432432
}
433433

434434
// Event stream version
435435
do {
436436
var versionString: String?
437437
var allowExperimental = false
438-
versionString = args.argumentValue(forKey: "--event-stream-version")
438+
versionString = args.argumentValue(forLabel: "--event-stream-version")
439439
if versionString == nil {
440-
versionString = args.argumentValue(forKey: "--experimental-event-stream-version")
440+
versionString = args.argumentValue(forLabel: "--experimental-event-stream-version")
441441
if versionString != nil {
442442
allowExperimental = true
443443
}
@@ -463,12 +463,12 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
463463
#endif
464464

465465
// XML output
466-
if let xunitOutputPath = args.argumentValue(forKey: "--xunit-output") {
466+
if let xunitOutputPath = args.argumentValue(forLabel: "--xunit-output") {
467467
result.xunitOutput = xunitOutputPath
468468
}
469469

470470
// 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") {
472472
result.attachmentsPath = attachmentsPath
473473
}
474474
#endif
@@ -487,12 +487,12 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
487487
}
488488

489489
// 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") {
491491
result.symbolicateBacktraces = symbolicateBacktraces
492492
}
493493

494494
// Verbosity
495-
if let verbosity = args.argumentValue(forKey: "--verbosity").flatMap(Int.init) {
495+
if let verbosity = args.argumentValue(forLabel: "--verbosity").flatMap(Int.init) {
496496
result.verbosity = verbosity
497497
}
498498
if args.contains("--verbose") || args.contains("-v") {
@@ -507,7 +507,7 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
507507

508508
// Filtering
509509
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) }
511511
}
512512
let filter = filterValues(forArgumentsWithLabel: "--filter")
513513
if !filter.isEmpty {
@@ -519,10 +519,10 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
519519
}
520520

521521
// 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) {
523523
result.repetitions = repetitions
524524
}
525-
if let repeatUntil = args.argumentValue(forKey: "--repeat-until") {
525+
if let repeatUntil = args.argumentValue(forLabel: "--repeat-until") {
526526
result.repeatUntil = repeatUntil
527527
}
528528

0 commit comments

Comments
 (0)