Skip to content

Use native VSCode coverage APIs, cover swift-testing tests #807

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

Merged
merged 16 commits into from
May 30, 2024

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented May 17, 2024

Move to the new VSCode coverage APIs that were introduced in VSCode version 1.88. This allows us to remove the coverage renderer and coverage report files. This functionality is now built in to the test explorer and VSCode's document rendering.

This patch also adds support for producing test coverage from swift-testing tests. XCTests and swift-testing tests are each run in their respective binaries and then the coverage data is merged into a profdata file before being exported to LCOV format.

Finally we transform the LCOV JSON into the coverage structures for VSCode and associate this data with the test run.

@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch from b171b9b to 8af5e10 Compare May 17, 2024 13:05
@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch 5 times, most recently from aa0fe65 to 6c0aa09 Compare May 23, 2024 17:52
@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch from 48d2dca to 12613c9 Compare May 27, 2024 13:50
Move to the new VSCode coverage APIs that were introduced in VSCode
version 1.88. This allows us to remove the coverage renderer and
coverage report files. This functionality is now built in to the test
explorer and VSCode's document rendering.

This patch also adds support for producing test coverage from
swift-testing tests. XCTests and swift-testing tests are each run in
their respective binaries and then the coverage data is merged into a
profdata file before being exported to LCOV format.

Finally we transform the LCOV JSON into the coverage structures for
VSCode and associate this data with the test run.
Refactor common debug config creation
Instead of a build followed by a test run with --skip-build, use a
SwiftExecution task to do swift test with the appropriate arguments.
This shows the build progress in the status bar.
@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch from 12613c9 to 4c44a38 Compare May 27, 2024 17:05
Copy link
Contributor

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

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

I'm not sure how ready this is for review, but I can get the coverage view to appear now which looks nice, I don't get inline rendering of coverage in the text editor though. Outside of coverage, parallel testing crashes VSCode which is quite impressive and debugging tests doesn't work anymore.

I think you are going to need to reimplement the two phase build and test instead of relying on swift test to do everything (outside of coverage testing), because you cannot use swift test when debugging tests.

Copy link
Contributor

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

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

Couple of minor things, otherwise I think we're pretty much there

@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch from bf0e5d8 to 1c3a35d Compare May 29, 2024 16:36
@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch 2 times, most recently from 686c1d6 to 40a6ff2 Compare May 29, 2024 17:37
Use a combination of the xunit xml output and the test output to capture
test pass/fail state and issues.
@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch from 40a6ff2 to b78d7a2 Compare May 29, 2024 18:07
@plemarquand plemarquand force-pushed the swift-testing-coverage-3 branch from 2aff937 to 1a0a3a3 Compare May 29, 2024 20:30
@plemarquand plemarquand marked this pull request as ready for review May 29, 2024 21:55
@plemarquand
Copy link
Contributor Author

plemarquand commented May 29, 2024

@adam-fowler thanks for taking such a thorough look. I think everything should be addressed.

Copy link
Contributor

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

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

Looking good

@plemarquand plemarquand merged commit 90f7641 into swiftlang:main May 30, 2024
8 checks passed
@plemarquand plemarquand deleted the swift-testing-coverage-3 branch May 30, 2024 12:24
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.

2 participants