Skip to content

Commit 197d6b3

Browse files
authored
Add support for the --attachments-path CLI argument. (#1074)
This PR adds support for the `--attachments-path` CLI argument on `swift test` as approved in [ST-0009](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0009-attachments.md). We will maintain support for the older `--experimental-attachments-path` version through Swift 6.2. Resolves rdar://147753783. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent d8d20a5 commit 197d6b3

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Sources/Testing/ABI/EntryPoints/EntryPoint.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ public struct __CommandLineArguments_v0: Sendable {
285285
/// The value of the `--repeat-until` argument.
286286
public var repeatUntil: String?
287287

288-
/// The value of the `--experimental-attachments-path` argument.
289-
public var experimentalAttachmentsPath: String?
288+
/// The value of the `--attachments-path` argument.
289+
public var attachmentsPath: String?
290290

291291
/// Whether or not the experimental warning issue severity feature should be
292292
/// enabled.
@@ -314,7 +314,7 @@ extension __CommandLineArguments_v0: Codable {
314314
case skip
315315
case repetitions
316316
case repeatUntil
317-
case experimentalAttachmentsPath
317+
case attachmentsPath
318318
}
319319
}
320320

@@ -396,8 +396,9 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
396396
}
397397

398398
// Attachment output
399-
if let attachmentsPathIndex = args.firstIndex(of: "--experimental-attachments-path"), !isLastArgument(at: attachmentsPathIndex) {
400-
result.experimentalAttachmentsPath = args[args.index(after: attachmentsPathIndex)]
399+
if let attachmentsPathIndex = args.firstIndex(of: "--attachments-path") ?? args.firstIndex(of: "--experimental-attachments-path"),
400+
!isLastArgument(at: attachmentsPathIndex) {
401+
result.attachmentsPath = args[args.index(after: attachmentsPathIndex)]
401402
}
402403
#endif
403404

@@ -509,9 +510,9 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
509510
}
510511

511512
// Attachment output.
512-
if let attachmentsPath = args.experimentalAttachmentsPath {
513+
if let attachmentsPath = args.attachmentsPath {
513514
guard fileExists(atPath: attachmentsPath) else {
514-
throw _EntryPointError.invalidArgument("--experimental-attachments-path", value: attachmentsPath)
515+
throw _EntryPointError.invalidArgument("---attachments-path", value: attachmentsPath)
515516
}
516517
configuration.attachmentsPath = attachmentsPath
517518
}

Sources/Testing/Attachments/Attachment.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Atta
3030
///
3131
/// If a developer sets the ``Configuration/attachmentsPath`` property of the
3232
/// current configuration before running tests, or if a developer passes
33-
/// `--experimental-attachments-path` on the command line, then attachments
34-
/// will be automatically written to disk when they are attached and the value
35-
/// of this property will describe the path where they were written.
33+
/// `--attachments-path` on the command line, then attachments will be
34+
/// automatically written to disk when they are attached and the value of this
35+
/// property will describe the path where they were written.
3636
///
3737
/// If no destination path is set, or if an error occurred while writing this
3838
/// attachment to disk, the value of this property is `nil`.
@@ -412,9 +412,9 @@ extension Attachment where AttachableValue: ~Copyable {
412412
/// The attachment is written to a file _within_ `directoryPath`, whose name
413413
/// is derived from the value of the ``Attachment/preferredName`` property.
414414
///
415-
/// If you pass `--experimental-attachments-path` to `swift test`, the testing
416-
/// library automatically uses this function to persist attachments to the
417-
/// directory you specify.
415+
/// If you pass `--attachments-path` to `swift test`, the testing library
416+
/// automatically uses this function to persist attachments to the directory
417+
/// you specify.
418418
///
419419
/// This function does not get or set the value of the attachment's
420420
/// ``fileSystemPath`` property. The caller is responsible for setting the

0 commit comments

Comments
 (0)