Skip to content

Ensure attachments path directory is created - #1788

Merged
grynspan merged 1 commit into
swiftlang:mainfrom
bkhouri:t/main/gh1665_create_attachment-path-if-it-does-not-exists
Aug 18, 2026
Merged

Ensure attachments path directory is created#1788
grynspan merged 1 commit into
swiftlang:mainfrom
bkhouri:t/main/gh1665_create_attachment-path-if-it-does-not-exists

Conversation

@bkhouri

@bkhouri bkhouri commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

When running swift test --attachments-path /does/not/exist, the Swift Testing library will fail with an error like:

Invalid value "/path/does/not/exists" for argument ---attachments-path

Ensure the path specified by --attachments-path is created, and update the error message to remote the additional - in the argument name.

Closes #1665

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.
  • Update documentation to reflect behavioural changes

@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch from cb47ad0 to aab38cf Compare July 13, 2026 19:52

@grynspan grynspan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of new code just to create a directory. I'd suggest we just leverage Foundation for it unless we're doing it a lot. (So, yes, you did the right thing avoiding Foundation, but sometimes it's not worth the effort!)

@grynspan grynspan added tools integration 🛠️ Integration of swift-testing into tools/IDEs command-line experience ⌨️ enhancements to the command line interface attachments/activities 🖇️ Work related to attachments and/or activities labels Jul 15, 2026
@grynspan grynspan added this to the Swift 6.5.0 (main) milestone Jul 15, 2026
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch 2 times, most recently from 58f0c81 to 9b7fa6d Compare July 15, 2026 21:20
@bkhouri
bkhouri requested a review from grynspan July 15, 2026 21:20
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch 2 times, most recently from e919a0e to 0388251 Compare July 15, 2026 22:03
@bkhouri
bkhouri marked this pull request as ready for review July 15, 2026 22:04
@bkhouri
bkhouri marked this pull request as draft July 15, 2026 22:04
Comment thread Sources/Testing/Testing.docc/ReleaseNotes/Unreleased.md Outdated
Comment thread Sources/Testing/Testing.docc/Documentation.md Outdated
Comment thread Sources/Testing/Testing.docc/Attachments.md Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated
Comment thread Sources/Testing/Support/VersionNumber.swift Outdated
Comment thread Sources/Testing/Testing.docc/ReleaseNotes.md Outdated
Comment thread Tests/TestingTests/SwiftPMTests.swift Outdated
Comment thread Tests/TestingTests/SwiftPMTests.swift Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch from c23543e to e5321fb Compare July 16, 2026 19:56
@bkhouri
bkhouri requested a review from grynspan July 16, 2026 19:56
@bkhouri
bkhouri marked this pull request as ready for review July 16, 2026 19:56
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch 5 times, most recently from 3777f5e to f695ef9 Compare July 22, 2026 17:28
Comment thread .github/workflows/pull_request.yml Outdated
Comment thread Tests/TestingTests/Support/FileHandleTests.swift Outdated
Comment thread Tests/TestingTests/SwiftPMTests.swift
Comment thread Tests/TestingTests/SwiftPMTests.swift
Comment thread Tests/TestingTests/SwiftPMTests.swift Outdated
Comment thread Tests/TestingTests/SwiftPMTests.swift Outdated
Comment thread Tests/TestingTests/SwiftPMTests.swift Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated
Comment thread Sources/Testing/ABI/EntryPoints/EntryPoint.swift
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch 2 times, most recently from 388342c to 538de51 Compare August 17, 2026 20:07
@bkhouri
bkhouri requested a review from grynspan August 17, 2026 20:08
Comment thread .github/workflows/pull_request.yml Outdated
Comment thread Tests/TestingTests/Support/FileHandleTests.swift Outdated
Comment thread Tests/TestingTests/SwiftPMTests.swift Outdated
let actualPath = try #require(configuration.attachmentsPath, "Attachments path is not expected to be nil")
#expect(canonicalizePath(actualPath) == canonicalizePath(attachmentsPath))
#else
try Test.cancel("Test requires Foundation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just mark the whole block of tests as #if canImport(Foundation) please, as is done elsewhere in our test suites.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought to mark the test skipped to get a sense of which tests were may not have been executed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip a test when it otherwise would run, but some runtime condition prevents it from doing so. If a test is entirely invalid in some configuration, it does not need to exist in that configuration.

Please make this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I wrapped each test in a #if canImport(...) block to prevent adding a test case in between that should not be gated by said canImport. This makes it more explicit which tests should be gated by the #if canImport(...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not what I asked you to do, but it's sufficient for the purposes of this PR.

Comment thread Tests/TestingTests/SwiftPMTests.swift
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch 2 times, most recently from 89b95d1 to aa7c501 Compare August 17, 2026 23:03
When running `swift test --attachments-path /does/not/exist`, the Swift
Testing library will fail with an error like:

```
Invalid value "/path/does/not/exists" for argument ---attachments-path
```

Ensure the path specified by `--attachments-path` is created, and update
the error message to remote the additional `-` in the argument name.

Closes swiftlang#1665
@bkhouri
bkhouri force-pushed the t/main/gh1665_create_attachment-path-if-it-does-not-exists branch from aa7c501 to 97f477b Compare August 17, 2026 23:53
@bkhouri
bkhouri requested a review from grynspan August 18, 2026 00:01
@grynspan
grynspan merged commit 15f5c48 into swiftlang:main Aug 18, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attachments/activities 🖇️ Work related to attachments and/or activities command-line experience ⌨️ enhancements to the command line interface tools integration 🛠️ Integration of swift-testing into tools/IDEs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swift Testing should create the attachments-path if it does not exist

2 participants