Skip to content

Provide a JSON API to *just* list tests (via the callback, not stdout) #506

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

Closed
allevato opened this issue Jun 26, 2024 · 5 comments · Fixed by #511
Closed

Provide a JSON API to *just* list tests (via the callback, not stdout) #506

allevato opened this issue Jun 26, 2024 · 5 comments · Fixed by #511
Assignees
Labels
enhancement New feature or request swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs

Comments

@allevato
Copy link
Member

allevato commented Jun 26, 2024

Description

If the JSON ABI entry point is used with listTests: true in its configuration, then the framework prints the list of all tests to stdout and then continues on executing tests (implementation).

However, a client of the JSON entry point may want to query which tests are available without running anything yet. I think this can be hacked up today by passing in a filter regex that could not possibly match any test ID; then, the framework would terminate after running nothing. (Disclaimer: I haven't actually tried this.) However, doing so would still require the calling process to redirect stdout temporarily and then parse the output line-by-line.

Would it be possible for the JSON entry point to provide a mode where listTests: true (or something like it with a different name, if we need to preserve the current behavior) would report the list of tests back to the caller via the callback as a JSON payload instead, returning immediately without running anything?

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

swift-testing version/commit hash

main

Swift & OS version (output of swift --version && uname -a)

No response

@allevato allevato added the enhancement New feature or request label Jun 26, 2024
@grynspan
Copy link
Contributor

and then continues on executing tests (implementation).

It exits early, actually.

We have not defined a stable JSON interface for input yet. If and when we do, it will likely include some sort of "list only" flag that produces a sequence of test records but does not run them.

@grynspan grynspan closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
@allevato
Copy link
Member Author

It exits early, actually.

Thanks! You're right—I misread the following else and didn't realize it was surrounding the entirety of the remaining logic.

it will likely include some sort of "list only" flag that produces a sequence of test records but does not run them.

That sounds good to me! I should be able to work with the existing behavior until then.

@grynspan
Copy link
Contributor

Actually, I'm going to reopen this and use it to track an experimental implementation of the described functionality, assuming it won't break VS Code. @plemarquand are you passing any additional arguments when you call swift test list?

@grynspan grynspan reopened this Jun 27, 2024
@grynspan grynspan added swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs and removed invalid labels Jun 27, 2024
@grynspan grynspan self-assigned this Jun 27, 2024
@stmontgomery
Copy link
Contributor

Tracked internally with rdar://130627856

grynspan added a commit that referenced this issue Jun 28, 2024
This PR changes the behavior of `swift test list` and its various synonyms to allow reporting the list of tests via the ABI-stable JSON mechanism described in #479.

As it is not currently possible to directly call `swift test list --experimental-event-stream-output ... --experimental-event-stream-version 0`, it's a bit hard to test this code. However, it is possible to opt into this mode using `--experimental-configuration-path` and passing a path to a JSON file that includes `"listTests": true` (as noted by @allevato.)

Resolves #506.
Resolves rdar://130627856.
grynspan added a commit that referenced this issue Jun 28, 2024
This PR changes the behavior of `swift test list` and its various synonyms to allow reporting the list of tests via the ABI-stable JSON mechanism described in #479.

As it is not currently possible to directly call `swift test list --experimental-event-stream-output ... --experimental-event-stream-version 0`, it's a bit hard to test this code. However, it is possible to opt into this mode using `--experimental-configuration-path` and passing a path to a JSON file that includes `"listTests": true` (as noted by @allevato.)

Resolves #506.
Resolves rdar://130627856.
@plemarquand
Copy link
Contributor

@grynspan We call it with —skip-build, but otherwise no.

grynspan added a commit that referenced this issue Jul 10, 2024
This PR changes the behavior of `swift test list` and its various synonyms to allow reporting the list of tests via the ABI-stable JSON mechanism described in #479.

As it is not currently possible to directly call `swift test list --experimental-event-stream-output ... --experimental-event-stream-version 0`, it's a bit hard to test this code. However, it is possible to opt into this mode using `--experimental-configuration-path` and passing a path to a JSON file that includes `"listTests": true` (as noted by @allevato.)

Resolves #506.
Resolves rdar://130627856.
grynspan added a commit that referenced this issue Jul 10, 2024
This PR changes the behavior of `swift test list` and its various synonyms to allow reporting the list of tests via the ABI-stable JSON mechanism described in #479.

As it is not currently possible to directly call `swift test list --experimental-event-stream-output ... --experimental-event-stream-version 0`, it's a bit hard to test this code. However, it is possible to opt into this mode using `--experimental-configuration-path` and passing a path to a JSON file that includes `"listTests": true` (as noted by @allevato.)

Resolves #506.
Resolves rdar://130627856.
grynspan added a commit that referenced this issue Jul 10, 2024
This PR changes the behavior of `swift test list` and its various synonyms to allow reporting the list of tests via the ABI-stable JSON mechanism described in #479.

As it is not currently possible to directly call `swift test list --experimental-event-stream-output ... --experimental-event-stream-version 0`, it's a bit hard to test this code. However, it is possible to opt into this mode using `--experimental-configuration-path` and passing a path to a JSON file that includes `"listTests": true` (as noted by @allevato.)

Resolves #506.
Resolves rdar://130627856.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants