Skip to content

[5.6] Allow running tests from a command plugin (#4002) #4008

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

abertelrud
Copy link
Contributor

@abertelrud abertelrud commented Jan 12, 2022

This is a cherry-pick of #4002.

Explanation: This cherrypicks the change to allow package command plugins to run tests in SwiftPM and get the results back in structured form. This change is on the main branch but should be included in the 5.6 release as command plugins are available in SwiftPM 5.6 for the first time.

Scope of Issue: This applies to command plugins that want to use the PackageManager.test(_:parameters:) function.

Reason for Nominating to 5.6: This allows command plugins to use the new PackageManager.test(_:parameters:) function in SE-0332.

Risk: Low — the material changes affects only a new code path that was introduced for command plugins, so only plugins that use PackageManager.test(_:parameters:) are affected.

Reviewed By: @tomerd

Automated Testing: A new unit test verifies the information sent to the plugin.

Dependencies: None

Impact on CI: None

How to Verify: Create a command package plugin that calls PackageManager.test(_:parameters:) and verify the return results. See the new unit test for an example.

rdar://87529139

@abertelrud abertelrud marked this pull request as draft January 12, 2022 23:20
@abertelrud
Copy link
Contributor Author

@swift-ci test

@abertelrud
Copy link
Contributor Author

@swift-ci please test

@abertelrud abertelrud force-pushed the eng/5.6-running-tests-from-command-plugins branch from 91ab64f to c49cf4a Compare January 13, 2022 05:06
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.

rdar://87529139

(cherry picked from commit d43183a)
@abertelrud abertelrud force-pushed the eng/5.6-running-tests-from-command-plugins branch from c49cf4a to 14a6f94 Compare January 13, 2022 05:07
@abertelrud
Copy link
Contributor Author

@swift-ci please test

@abertelrud abertelrud marked this pull request as ready for review January 13, 2022 16:57
@@ -461,70 +461,6 @@ public struct SwiftTestTool: SwiftCommand {
}
}

/// Locates XCTestHelper tool inside the libexec directory and bin directory.
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 code is not removed but is moved out into a separate file where it can be used by both SwiftTestTool and SwiftPackageTool.

import Workspace


/// Internal helper functionality for the SwiftTestTool command and for the
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 code is not new but is moved out from SwiftTestTool into a separate file where it can be used by both SwiftTestTool and SwiftPackageTool.

@abertelrud abertelrud added 5.6 ready Author believes the PR is ready to be merged & any feedback has been addressed labels Jan 14, 2022
@abertelrud abertelrud merged commit 347df6e into swiftlang:release/5.6 Jan 15, 2022
@abertelrud abertelrud deleted the eng/5.6-running-tests-from-command-plugins branch January 15, 2022 01:25
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.

3 participants