[swift-build-dev] [SwiftPM] [Proposal Draft] Add support for test-only dependencies
Ankit Aggarwal
ankit_aggarwal at apple.com
Mon Jan 9 03:32:44 CST 2017
Hi,
Thanks for driving this! Comments inline:
> The actual implementation of testDependencies will be nearly identical to the existing dependencies section. All the same subtypes can be used in either, and the syntax is exactly the same for both. The sole difference is that when running swift build, the testDependencies is ignored completely, but when running swift test, all the packages listed in testDependencies are effectively added to the dependencies list before compiling and testing occurs.
>
> Package.swift example with testDependencies:
>
> import PackageDescription
> let package = Package(
> name: "ExamplePackage",
> dependencies: [
> .Package(url: "https://github.com/user1/package1.git", majorVersion: 2),
> .Package(url: "https://github.com/user2/package2.git", majorVersion: 1, minor: 4),
> ],
> testDependencies: [
> .Package(url: "https://github.com/user3/test-package.git", majorVersion: 3),
> ]
> )
> In the above example example, running swift build would build the package ExamplePackage, including user1/package1 and user2/package2, but not user3/test-package.
>
> Running swift test, on the other hand, would build and test the package ExamplePackage, while including user1/package1 and user2/package2, and user3/test-package.
>
Once the product proposal <https://github.com/apple/swift-evolution/blob/master/proposals/0146-package-manager-product-definitions.md> is implemented it will be possible for individual targets to depend on products vended by external dependencies, and packages to vend fine grained targets (as products). That means we can create this feature such that a regular (non-test) target can also depend on a product coming from one of the testDependencies as long as that target is not vended to public via the new product API.
This could be a useful thing to have, consider swiftpm itself, it has an executable target called TestSupportExecutable which contains tests which needs to be run outside of the current binary. SwiftPM would probably never vend this as a product to outside world but that target should be able to use testDependencies (like Quick/Nimble).
This is a test related usecase but there could be non-test usecases. This is why instead of testDependencies I prefer localDependencies for this feature.
Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-build-dev/attachments/20170109/e8a68ea8/attachment.html>
More information about the swift-build-dev
mailing list