Skip to content

Accept arbitrary strings in Swift Testing event stream version options #8944

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

Conversation

stmontgomery
Copy link
Contributor

This modifies the swift test command line @Option properties which represent a Swift Testing event stream version (primarily --event-stream-version <...>) to accept arbitrary String arguments.

Motivation:

In Swift Testing we are moving towards making the entry point and event stream versions aligned with the Swift version, rather than having an independent versioning scheme which users must look up or keep track of. Once this and other work lands, this means that in order to use the event stream format included in (for example) Swift 6.2, a user would pass --event-stream-version 6.2.

However, until now these CLI options have required an integer argument like --event-stream-version 0. This change relaxes this requirement so that any arbitrary string will be accepted. In a separate PR, the Swift Testing library will perform additional validation of the format of this string to ensure it's valid, but we will need to continue accepting the current integers (e.g. 0) in addition to newer Swift versions (e.g. 6.2, 6.3, …) going forward.

Modifications:

  • Replace Int? type of these options with String?.
  • Update the documentation.

Result:

In local testing, I'm able to pass any string argument now.

@stmontgomery
Copy link
Contributor Author

@swift-ci test

@stmontgomery stmontgomery merged commit 25fb01c into swiftlang:main Jul 17, 2025
6 checks passed
stmontgomery added a commit to swiftlang/swift-testing that referenced this pull request Jul 17, 2025
This adds validation of the user-specified `--event-stream-version` (or
`--experimental-event-stream-version`) command-line arguments when they
are passed, to ensure they have a valid format.

### Motivation:

Currently, these flags only accept integers like `0`, `1`, etc. But I am
moving towards making the entry point and event stream versions align
with the Swift version, rather than having an independent versioning
scheme which users must look up or keep track of. Once this effort is
finished, in order to use the event stream format included in (for
example) Swift 6.3, a user would pass `--event-stream-version 6.3`.

In swiftlang/swift-package-manager#8944, I
recently landed a SwiftPM change which will permit any arbitrary string
for these arguments, and this means we need to begin validating the
format of supported versions within the testing library. In a subsequent
PR, I plan to introduce support for non-integer versions, at which point
having some existing validation logic will be even more valuable.

### 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement swift test Changes impacting `swift test` tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants