Skip to content
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

Attachments! #770

Merged
merged 17 commits into from
Nov 1, 2024
Merged

Attachments! #770

merged 17 commits into from
Nov 1, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Oct 17, 2024

This PR introduces a new experimental feature, attachments. With this feature, you can "attach" values that conform to a new Test.Attachable protocol to a test. With the right command-line incantation (TBD), Swift Testing will automatically write attachments to disk for you.

Note

This PR does not teach Xcode or VS Code how to handle attachments produced by
Swift Testing, nor does it add the necessary command-line arguments to the
swift test command-line tool.

This PR is one of a series that I'll be posting to build out this feature.

As always, keep in mind that symbols marked @_spi(Experimental) are subject to change or removal without notice.

Resolves #714.
Resolves rdar://88648735.

Checklist:

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

@grynspan grynspan added enhancement New feature or request swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs public-api Affects public API attachments/activities 🖇️ Work related to attachments and/or activities labels Oct 17, 2024
@grynspan grynspan self-assigned this Oct 17, 2024
@grynspan grynspan force-pushed the jgrynspan/attachments branch from 4570404 to fd7e89d Compare October 17, 2024 21:08
@grynspan
Copy link
Contributor Author

@swift-ci test

1 similar comment
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan added this to the Swift 6.1 milestone Oct 17, 2024
Sources/Testing/Attachments/Test.Attachable.swift Outdated Show resolved Hide resolved
Documentation/ABI/JSON.md Outdated Show resolved Hide resolved
@plemarquand
Copy link

If there is no --attachment-path set we should warn/error if the user calls attach(). It will look like everything is working OK but nothing will be written.

@grynspan
Copy link
Contributor Author

We could also try to default to some benign location like /tmp, maybe.

@grynspan grynspan requested a review from plemarquand October 22, 2024 22:06
@grynspan grynspan force-pushed the jgrynspan/attachments branch from 6b6d78a to 510f445 Compare October 22, 2024 22:26
@grynspan
Copy link
Contributor Author

@swift-ci test

Documentation/ABI/JSON.md Outdated Show resolved Hide resolved
@grynspan grynspan force-pushed the jgrynspan/attachments branch from 510f445 to 7da28f0 Compare October 23, 2024 21:01
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan force-pushed the jgrynspan/attachments branch from 02b30c1 to 097944b Compare October 25, 2024 13:23
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan force-pushed the jgrynspan/attachments branch from ad35d3e to ed14512 Compare October 28, 2024 12:21
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Linux

@grynspan
Copy link
Contributor Author

@swift-ci test macOS

Copy link
Contributor

@stmontgomery stmontgomery left a comment

Choose a reason for hiding this comment

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

Very cool! Took a deep look and left many comments/questions

Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated Show resolved Hide resolved
Sources/Testing/ABI/EntryPoints/EntryPoint.swift Outdated Show resolved Hide resolved
Sources/Testing/Events/Event.swift Show resolved Hide resolved
Sources/Testing/Attachments/Test.Attachment.swift Outdated Show resolved Hide resolved
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Nov 1, 2024

@swift-ci test

@grynspan grynspan merged commit bb19b2a into main Nov 1, 2024
2 of 3 checks passed
@grynspan grynspan deleted the jgrynspan/attachments branch November 1, 2024 22:30
beccadax added a commit that referenced this pull request Nov 2, 2024
tshortli added a commit to tshortli/swift-testing that referenced this pull request Nov 2, 2024
@grynspan grynspan restored the jgrynspan/attachments branch November 2, 2024 17:09
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request Nov 9, 2024
Work in progress patch to support swift-testing attachments. Currently
prints the attachments out as a report at the end of a test run. In
order to leverage them we need to set the --attachment-path, which is
not available on the command line so we add a configuration json file.

There is still more work to do to allow the user to specify their own
attachment path on a per workspace basis.

This will currently only work with swiftlang/swift-testing#770
as it isn't merged yet.
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request Jan 10, 2025
Work in progress patch to support swift-testing attachments. Currently
prints the attachments out as a report at the end of a test run. In
order to leverage them we need to set the --attachment-path, which is
not available on the command line so we add a configuration json file.

There is still more work to do to allow the user to specify their own
attachment path on a per workspace basis.

This will currently only work with swiftlang/swift-testing#770
as it isn't merged yet.
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 enhancement New feature or request public-api Affects public API swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add attachments
4 participants