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

Allow specifying testing libraries for swift package init #7186

Merged
merged 4 commits into from
Dec 12, 2023

Conversation

grynspan
Copy link
Contributor

This PR adds -enable-experimental-swift-testing (and -disable-xctest and their inverses) to swift package init. These options behave, broadly, the same as they do for swift test. They determine which testing library a new package will use and adjust the generated template to match.

It is important to note that any combination of the two libraries is supported: a developer may wish to use only one or the other, or both, or may wish to opt out of a test target entirely. All four combinations are supported, however for simplicity's sake if both libraries are enabled, we only generate example code for swift-testing.

Note that right now, correct macro target support is impeded by apple/swift-syntax#2400. I don't think that issue blocks a change here (since it's in an experimental feature anyway!) but it does mean that swift package init --type macro --enable-experimental-swift-testing produces some dead tests. Once that issue is resolved, we can revise the template to produce meaningful tests instead.

Resolves rdar://99279056.

This PR adds `-enable-experimental-swift-testing` (and `-disable-xctest` and their inverses) to `swift package init`. These options behave, broadly, the same as they do for `swift test`. They determine which testing library a new package will use and adjust the generated template to match.

It is important to note that any combination of the two libraries is supported: a developer may wish to use only one or the other, or both, or may wish to opt out of a test target entirely. All four combinations are supported, however for simplicity's sake if both libraries are enabled, we only generate example code for swift-testing.

Note that right now, correct macro target support is impeded by apple/swift-syntax#2400. I don't think that issue blocks a change here (since it's in an experimental feature anyway!) but it does mean that `swift package init --type macro --enable-experimental-swift-testing` produces some dead tests. Once that issue is resolved, we can revise the template to produce meaningful tests instead.

Resolves rdar://99279056.
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

Thinking about it, replacement API in swift-syntax won't have an associated tag for a while anyway, so we definitely shouldn't block on it.

@neonichu
Copy link
Member

I think swift package init --type macro --enable-experimental-swift-testing should probably just produce an error for now, I don't think it's useful to produce output that has broken tests.

@grynspan
Copy link
Contributor Author

We can certainly do that.

@grynspan
Copy link
Contributor Author

@swift-ci please test

@MaxDesiatov
Copy link
Member

@swift-ci test windows

Copy link
Member

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

LGTM, but I hope we can avoid using stream.send while we're at it.

@MaxDesiatov MaxDesiatov changed the title Add the ability to specify testing libraries when initing a package. Add the ability to specify testing libraries when initing a package Dec 12, 2023
@MaxDesiatov MaxDesiatov changed the title Add the ability to specify testing libraries when initing a package Allow specifying testing libraries for swift package init Dec 12, 2023
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@grynspan
Copy link
Contributor Author

@swift-ci please clean test Windows

@grynspan grynspan enabled auto-merge (squash) December 12, 2023 20:40
@grynspan grynspan merged commit 81526cf into main Dec 12, 2023
5 checks passed
@grynspan grynspan deleted the jgrynspan/99279056-package-template branch December 12, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants