Skip to content

Add support for the --attachments-path CLI argument. #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Sources/Testing/ABI/EntryPoints/EntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ public struct __CommandLineArguments_v0: Sendable {
/// The value of the `--repeat-until` argument.
public var repeatUntil: String?

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

/// Whether or not the experimental warning issue severity feature should be
/// enabled.
Expand Down Expand Up @@ -314,7 +314,7 @@ extension __CommandLineArguments_v0: Codable {
case skip
case repetitions
case repeatUntil
case experimentalAttachmentsPath
case attachmentsPath
}
}

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

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

Expand Down Expand Up @@ -509,9 +510,9 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
}

// Attachment output.
if let attachmentsPath = args.experimentalAttachmentsPath {
if let attachmentsPath = args.attachmentsPath {
guard fileExists(atPath: attachmentsPath) else {
throw _EntryPointError.invalidArgument("--experimental-attachments-path", value: attachmentsPath)
throw _EntryPointError.invalidArgument("---attachments-path", value: attachmentsPath)
}
configuration.attachmentsPath = attachmentsPath
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/Testing/Attachments/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Atta
///
/// If a developer sets the ``Configuration/attachmentsPath`` property of the
/// current configuration before running tests, or if a developer passes
/// `--experimental-attachments-path` on the command line, then attachments
/// will be automatically written to disk when they are attached and the value
/// of this property will describe the path where they were written.
/// `--attachments-path` on the command line, then attachments will be
/// automatically written to disk when they are attached and the value of this
/// property will describe the path where they were written.
///
/// If no destination path is set, or if an error occurred while writing this
/// attachment to disk, the value of this property is `nil`.
Expand Down Expand Up @@ -412,9 +412,9 @@ extension Attachment where AttachableValue: ~Copyable {
/// The attachment is written to a file _within_ `directoryPath`, whose name
/// is derived from the value of the ``Attachment/preferredName`` property.
///
/// If you pass `--experimental-attachments-path` to `swift test`, the testing
/// library automatically uses this function to persist attachments to the
/// directory you specify.
/// If you pass `--attachments-path` to `swift test`, the testing library
/// automatically uses this function to persist attachments to the directory
/// you specify.
///
/// This function does not get or set the value of the attachment's
/// ``fileSystemPath`` property. The caller is responsible for setting the
Expand Down