Skip to content

Allow running tests from a command plugin #4002

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

Conversation

abertelrud
Copy link
Contributor

@abertelrud abertelrud commented Jan 10, 2022

This wraps up the last piece for SE-0332, including support for filtering and for capturing code coverage while the tests are running.

Motivation:

This is specified in SE-0332 (it's the last part of SE-0332 that wasn't yet merged).

Modifications:

  • add support to running tests in a similar manner as SwiftTestTool, reusing much of the implementation of swift test
  • factor out some of the SwiftTestTool methods so they they can be invoked on request from plugins too
  • add a unit test

Comment

This uses most of the same implementation that existed in a very specify way in SwiftTestTool.swift, factoring it out into a new shared TestingSupport.swift file and making it more generic. Future refactoring should move it down to a new module that provides the shared test support for use from everywhere.

@abertelrud abertelrud self-assigned this Jan 10, 2022
@abertelrud abertelrud added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Jan 10, 2022
@abertelrud
Copy link
Contributor Author

@swift-ci smoke test

@@ -223,12 +223,12 @@ public final class UserToolchain: Toolchain {

/// Returns the path to llvm-cov tool.
public func getLLVMCov() throws -> AbsolutePath {
return try UserToolchain.getTool("llvm-cov", binDir: self.destination.binDir)
return try UserToolchain.getTool("llvm-cov", binDir: self.swiftCompilerPath.parentDirectory)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one and the one below were actually wrong and didn't work in debug builds of SwiftPM, as these tools come from the toolchain and are not built by SwiftPM. The new code is the same as for the symbol graph extraction tool and the other similar tools.

@abertelrud abertelrud force-pushed the eng/running-tests-from-command-plugins branch from dc18339 to 4b0827c Compare January 10, 2022 07:40
@abertelrud
Copy link
Contributor Author

@swift-ci smoke test

@tomerd tomerd self-requested a review January 11, 2022 22:00
@abertelrud
Copy link
Contributor Author

FYI: Working on some of the other feedback here. Will mark as WIP while I do. Should be done later today.

@abertelrud abertelrud marked this pull request as draft January 11, 2022 22:07
@abertelrud abertelrud force-pushed the eng/running-tests-from-command-plugins branch from 144b938 to 50c1f05 Compare January 11, 2022 22:25
@abertelrud abertelrud marked this pull request as ready for review January 11, 2022 22:30
@abertelrud
Copy link
Contributor Author

@swift-ci smoke test

This wraps up the last piece for SE-0332, including support for filtering and for capturing code coverage while the tests are running.

This uses most of the same implementation that existed in a very specify way in SwiftTestTool.swift, factoring it out into a new shared TestingSupport.swift file and making it more generic. Future refactoring should move it down to a new module that provides the shared test support for use from everywhere.
@abertelrud abertelrud force-pushed the eng/running-tests-from-command-plugins branch from 50c1f05 to d43183a Compare January 12, 2022 17:20
@abertelrud
Copy link
Contributor Author

@swift-ci smoke test

@abertelrud abertelrud merged commit beac985 into swiftlang:main Jan 12, 2022
@abertelrud abertelrud deleted the eng/running-tests-from-command-plugins branch January 12, 2022 23:08
abertelrud added a commit to abertelrud/swift-package-manager that referenced this pull request Jan 12, 2022
This wraps up the last piece for SE-0332, including support for filtering and for capturing code coverage while the tests are running.

This uses most of the same implementation that existed in a very specify way in SwiftTestTool.swift, factoring it out into a new shared TestingSupport.swift file and making it more generic. Future refactoring should move it down to a new module that provides the shared test support for use from everywhere.

(cherry picked from commit beac985)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants