-
Notifications
You must be signed in to change notification settings - Fork 65
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
Suggestion: use server-side swift to run integration tests #306
Comments
No problem, glad you're poking around. Questions:
Yeah, enabling folks that don't have Apple hardware to run the test suite would be great. |
I believe it would require no changes to the swift code, only to the test harness. I've never used XCTest without XCode, but googling around it seems to be possible.
I don't know the answer to this, but given that the tests seem to be mostly pure swift, I can't imagine many would depend on xcode. Are there any tests using platform stuff like SwiftUI?
Some people like xcode, and they would (probably) have to drop to the command line to run the integration test suite. |
I was incorrect about this, so this may be the tricky bit. It should be possible to wrap a static |
Got it, thanks. I just did some quick research. Some Relevant Links
Looks like anyone with the Swift CLI can run Path forward:
|
A couple of our examples use swift-bridge/examples/async-functions/build.sh Lines 1 to 14 in 225380e
|
For what it's worth, this seems a bit wasteful/inconvenient to me. The value of the tests is that the generated swift code is correct, not that the test harness itself is portable.
Indeed, the important part here is to let swift know where the rust library lives and that it has to link to it. I believe what would work is to follow these instructions: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/Usage.md#requiring-a-system-library-without-pkg-config Here is an example from the internet of this being done with a static library: https://stackoverflow.com/questions/64958357/how-to-build-a-local-c-library-as-a-static-library-and-link-with-swift The crucial part being this:
|
My understanding is that Swift isn't fully cross platform yet, meaning it's possible for I vaguely recall trying to If the above is true, running the test suite on Linux and Windows would reduce the likelihood of us unknowingly making our generated code use features that aren't supported on all platforms. I'd have to do more research on this, but if it isn't actually true then yeah running the test suite on one OS would be fine. Ok great, looks like we have a the pieces we need. |
I'm having trouble because the generated swift bridge code (from For now, I will create a separate crate which is just the rust code used by the "swift calling into rust" tests. Or is the circular dependency / two-way bridge scenario supposed to work? |
I'm also getting some errors that are probably related to my swift version.
|
One more thing - I also noticed that a few tests are using SwiftUI: swift-bridge/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ContentView.swift Line 8 in 225380e
Those won't work on Linux, but we might be able to exclude them there. |
Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Ref. chinedufn#306
Ok, this was a slight misdiagnosis of the problem, but I was close. I'm going to head to bed now, but I got pretty close to getting this working. I'll push a draft PR in a minute. When running swift-on-the-server, you use Swift Package Manager (SPM) rather than Xcode to build. SPM uses
One big difference between xcode and SPM is that xcode allows shared-source targets, while SPM does not. From the docs:
The current design of swift-bridge's generated output requires mixed-source packages; the |
Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Ref. chinedufn#306
Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Ref. chinedufn#306
Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Ref. chinedufn#306
Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Fixes chinedufn#306
Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Fixes chinedufn#306
Pull request: |
Hi, thanks for the great library!
Currently, running the integration test suite (which is fantastic) requires xcodebuild. It seems to me that it should be easy to use server-side swift for this, which would allow running the integration tests on different platforms (for example, linux CI runners).
The text was updated successfully, but these errors were encountered: