使用 Swift 包管理器时的仅测试依赖项
Test-only Dependencies When Using the Swift Package Manager
我在使用 Swift 包管理器时看到了仅测试依赖项的提及,但无法让它们工作。例如:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005409.html
https://github.com/apple/swift-package-manager/pull/74
http://blog.krzyzanowskim.com/2016/08/09/package-swift-manual/#testDependencies
我想要的是在我的 XC 测试中使用依赖项(例如,针对特定目标),但不应用于已部署的包。
如果能指出工作示例,我们将不胜感激。
目前 "Test-only dependencies" 功能在 Swift 包管理器中被禁用。它最初实现了,但被删除了 in this commit.
来自提交的描述:
Remove testDependencies from PackageDescription
This feature was supposed to support dependencies only for the root
package but at some point it stopped working however the API still
remained open. This patch removes the public API. This is a valid and
desired feature which is supposed to come back after it goes through
proper review on swift evolution.
@Vadim 的回答是正确的,目前没有正式的 API 测试依赖,但有解决方法。 ReactiveSwift 例如使用 alternate Package.swift for tests that they overwrite the original one with when executing tests on the CI (see their travis config file)。它不是很优雅,但很好,在 SPM 恢复这个非常需要的功能之前它可以完成工作。
我在使用 Swift 包管理器时看到了仅测试依赖项的提及,但无法让它们工作。例如:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005409.html https://github.com/apple/swift-package-manager/pull/74 http://blog.krzyzanowskim.com/2016/08/09/package-swift-manual/#testDependencies
我想要的是在我的 XC 测试中使用依赖项(例如,针对特定目标),但不应用于已部署的包。
如果能指出工作示例,我们将不胜感激。
目前 "Test-only dependencies" 功能在 Swift 包管理器中被禁用。它最初实现了,但被删除了 in this commit.
来自提交的描述:
Remove testDependencies from PackageDescription This feature was supposed to support dependencies only for the root package but at some point it stopped working however the API still remained open. This patch removes the public API. This is a valid and desired feature which is supposed to come back after it goes through proper review on swift evolution.
@Vadim 的回答是正确的,目前没有正式的 API 测试依赖,但有解决方法。 ReactiveSwift 例如使用 alternate Package.swift for tests that they overwrite the original one with when executing tests on the CI (see their travis config file)。它不是很优雅,但很好,在 SPM 恢复这个非常需要的功能之前它可以完成工作。