-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Testing macros in the OSS toolchain snapshots for macOS don't seem to work with SDK bundles #8362
Comments
So the library is being built, but our CMake script installs it to a different location than it does on Linux. I'm not sure why that is or if it might be the root cause. @stmontgomery @rintaro does either of you have any insight? |
Oh, Marc also told me there's a |
Also I don't see a |
I don't think it is, as the upcoming 6.1 toolchain for linux only has |
Looks like this is, or at least was, a bug in Swift Package Manager: in 6.1, it was checking whether the target triple represented macOS, and only then included the necessary macro plugin search paths to locate However, this code all changed somewhat recently in #8295 and it might have affected this, or perhaps even fixed the issue. I'm not certain, but it would be worth trying using a Regardless, I'm going to transfer this to SwiftPM since it's something controlled at that layer. It may be a dupe, though. |
Thanks for likely finding the culprit, but my read of the code is that it is still broken in trunk for cross-compilation to non-mac platforms, because it checks the target triple instead of the host triple before applying the macOS plugin paths:
I think this was broken in #7920 last fall by @xedin, ironically when he was trying to fix cross-compilation to wasm. The issue appears to be that |
Just to add some data, I have a bare-bones repository https://github.com/marcprux/swift-testing-cross-compile-demo with CI that uses the same Android SDK on both macOS and Ubuntu. You can see the test build output for both hosts at: https://github.com/marcprux/swift-testing-cross-compile-demo/actions/runs/13816030659. Ubuntu passes, but macOS fails:
The locally-installed testing libraries on macOS are:
And on Ubuntu are:
Let me know if there is any jiggery-pokery I can do with file paths or toolchain config to experiment with getting it working. |
Just as a temporary experiment, you could try moving or copying |
My take is that it is incorrectly not passing in the |
….dylib to lib/swift/host/plugins/ (works around swiftlang/swift-package-manager#8362)
That worked!
I've also updated I will "un-apply" the workaround once the fix is available in the macOS toolchain. |
While the test package is now cross-compiling for Android with the aforementioned workaround, they are not actually getting executed by the This is likely a separate issue, but I'm mentioning it here to point out that fixing this issue won't entirely get testing working. @finagolfin, when you ran the |
I think a better short-term workaround may be manually passing the plugin search path using |
@marcprux I'm not that familiar with GitHub CI, but it looks like it's outright not running the .xctest executable a second time (which is how Swift Testing tests run.) |
Ah, yes:
Your script needs to also run |
That works too. I'll use that instead. Thanks. |
Thanks, that works as expected (in that the expected failure is now occurring). @grynspan, do I understand correctly that running If so, I now need to figure out when I should run the tests with that argument, since I don't want to invoke the tests a second time when all they contain are XCTest test cases. I'm guessing I'll just run |
Correct. The tool basically has two separate
If you run the two commands, they won't (shouldn't!) overlap output. :) |
Note also that if there are no Swift Testing tests, the library terminates the test process with a specific error code ( This is all, of course, normally handled by SwiftPM. The exact details of how SwiftPM and Swift Testing interoperate will be subject to change over time as we build out more of our infrastructure. |
I'm assuming that this is what I'm seeing when I run a test suite that doesn't use Testing (e.g., Yams), which outputs this error:
So I think I will want to probe the binary to see if it links to Testing in order to avoid that, since I expect it will be easier than special-casing certain exit codes to count as passing. |
This is a different problem. For historical reasons, test executables on Linux/etc. can specify a custom main function which prevents SwiftPM from emitting its own main function, and Yams is doing that here. I'd love to remove that feature but there are still a lot of packages that rely on it. You could still run into this problem if the binary does link to Testing. |
(By the end of this, you'll have reimplemented a third of SwiftPM. 😬) |
Spitballing here, perhaps we could teach |
Yeah, I just ran into that when testing swift-algorithms. My current solution (skiptools/swift-android-action@9a5ef58) seems to be working, although it ain't pretty:
Not quite a third, but I'm getting there 🙃 |
Description
I recently added the Testing library to my Android SDK bundles for Swift 6.1 and 6.2, finagolfin/swift-android-sdk@eb1567b1c, and it works well to cross-compile Testing tests using the latest linux snapshot toolchain and my CI-generated 6.1 SDK bundle, which I checked by cross-compiling @tayloraswift's swift-png and its tests. 😄
However, @marcprux tells me the same didn't work with the OSS mac toolchain snapshot when he tried it with another Testing repo, as he got errors saying:
suggesting there is some issue with how these Testing macros are installed on macOS.
Reproduction
Follow the instructions to use my Android SDK bundle on macOS, except using the 6.1 bundle linked above, not 6.0.3 as I have not backported the Android patches in this repo to that tag. An alternative would be to try the linux SDK bundle generated by swift-sdk-generator, if it supports this Testing library.
Expected behavior
Testing tests cross-compile fine using the mac toolchain's prebuilt macros, as they do on linux.
Environment
MacOS
Additional information
I have not reproduced this myself. Marc said he'd file this himself, but I'm doing it now so we don't forget and so somebody behind this repo can take a look in the meantime.
The text was updated successfully, but these errors were encountered: