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
[SR-1276] swift tests fail to link library during test build when name doesn't match tested target #5302
Comments
The package manager will add an implicit dependency between the test suite and the target it assumes it is trying to test. In your case, however, your package module is named PlayingCard, and your test module is name CardTests (not PlayingCardTests) so it doesn't find that dependency. This leaves it without any dependencies, and so the link fails. That the build of the individual test files doesn't fail is because we don't yet have a good way to enforce your Swift code only see what it is allowed to. If you do: Keeping this bug open to track better diagnostics to help the user find this issue. |
Ah interesting. I was under the impression that ```@testable import xxxx``` would auto link the imported target.
|
Is this resolved, or do you feel that there is a SwiftPM issue still to fix here? |
I would like for us to find a way to help users discover the right convention here. One idea: maybe we could have a warning in cases where there is a Source module, and there is a Test module, but there is no dependency between them? It seems really unlikely that that is something would come up. If we do that, we should probably think about a way to suppress the warning (e.g., write an explicit |
Comment by Scott (JIRA) I'm so glad I came across this. This was one of those good 1/2 day head scratchers. I would second that I like the idea of the warning in this situation. There is a risk of not being familiar with this convention when you are primarily building in Xcode but want to include SPM support. |
We no longer have implicit dependencies. |
Attachment: Download
Environment
xcode 7.3
10.11.4 (15E65)
swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a
Same thing happens with 3-24 snapshotp
Additional Detail from JIRA
md5: e6ccdf7a6a1514b8239d5704eadfd7f9
Issue Description:
I added some test to a fork of the sample playing card.
https://github.com/masters3d/example-package-playingcard
It builds okay but the test do not link.
Log.
https://gist.github.com/masters3d/658fbaf009ef3b85b8509bf9dc6b2857
This seems similar to https://bugs.swift.org/browse/SR-151
but this is just happens for the test build.
Steps to reproduce:
swift build -v // See gist log.
swift test // See gist log.
The text was updated successfully, but these errors were encountered: