-
Notifications
You must be signed in to change notification settings - Fork 86
Add Wasm Swift SDK checks for swift run
#166
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
Open
MaxDesiatov
wants to merge
7
commits into
main
Choose a base branch
from
maxd/wasm-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7fb1f30
Add Wasm Swift SDK checks for `swift run` and `swift test`
MaxDesiatov 501149e
Remove unused comments from `Package.swift`
MaxDesiatov 0c66dad
Add `REQUIRES: platform=Linux` to the new test
MaxDesiatov 2ca6911
Use `-mindepth 1 -maxdepth 1` in `wasm/swiftpm.md`
MaxDesiatov f1ac9b2
Exclude checks for `swift test` from `swiftpm.md` for now
MaxDesiatov d0f5b09
Use `-mindepth 1 -maxdepth 1` in step 4 of `swiftpm.md`
MaxDesiatov a24279b
wasm/swiftpm.md: clean up wording for every step
MaxDesiatov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// swift-tools-version: 6.2 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Hello", | ||
targets: [ | ||
.executableTarget( | ||
name: "Hello" | ||
), | ||
] | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import WASILibc | ||
|
||
@main | ||
struct Hello { | ||
static func main() { | ||
print("Hello, world!") | ||
puts("Hello from WASILibc!") | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Testing | ||
import XCTest | ||
@testable import Hello | ||
|
||
@Test func example() async throws { | ||
#expect(Int("42") == 42) | ||
} | ||
|
||
final class HelloTests: XCTestCase { | ||
func testExample() throws { | ||
XCTAssertEqual(Int("42") == 42) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# SwiftPM checks for Wasm Swift SDKs | ||
|
||
This test can only run on Linux CI as we only build Swift SDK for Wasm on Linux CI nodes. | ||
|
||
``` | ||
REQUIRES: platform=Linux | ||
``` | ||
|
||
1. Let's install Swift SDK for Wasm first: | ||
|
||
``` | ||
RUN: %{swift-sdk} list | %{FileCheck} --check-prefix CHECK-SDK-LIST-BEFORE %s | ||
CHECK-SDK-LIST-BEFORE: No Swift SDKs are currently installed. | ||
RUN: find "%{swift-sdk-generator_srcdir}/Bundles" -mindepth 1 -maxdepth 1 | xargs %{swift-sdk} install | %{FileCheck} --check-prefix CHECK-SDK-INSTALL %s | ||
CHECK-SDK-INSTALL: Swift SDK bundle at | ||
CHECK-SDK-INSTALL: successfully installed as | ||
RUN: %{swift-sdk} list | grep wasm | wc -l | %{FileCheck} --check-prefix CHECK-SDK-LIST-AFTER %s | ||
CHECK-SDK-LIST-AFTER: 2 | ||
``` | ||
|
||
2. Creating a package from `init` template: | ||
|
||
``` | ||
RUN: rm -rf %t.dir | ||
RUN: mkdir -p %t.dir | ||
RUN: cp -r %S/Hello %t.dir | ||
``` | ||
|
||
3. Building and running prepared `"Hello, world!"` executable from the newly created package: | ||
MaxDesiatov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
a) Non-embedded Swift SDK | ||
|
||
``` | ||
RUN: %{swift-sdk} list | grep -v embedded | xargs %{swift-run} --package-path %t.dir/Hello --swift-sdk | %{FileCheck} --check-prefix CHECK-RUN-OUTPUT %s | ||
CHECK-RUN-OUTPUT: Hello, world! | ||
CHECK-RUN-OUTPUT-NEXT: Hello from WASILibc! | ||
``` | ||
|
||
b) Embedded Swift SDK | ||
|
||
``` | ||
RUN: %{swift-sdk} list | grep embedded | xargs %{swift-run} --package-path %t.dir/Hello --swift-sdk | %{FileCheck} --check-prefix CHECK-EMBEDDED-RUN-OUTPUT %s | ||
CHECK-EMBEDDED-RUN-OUTPUT: Hello, world! | ||
CHECK-EMBEDDED-RUN-OUTPUT-NEXT: Hello from WASILibc! | ||
``` | ||
|
||
4. Clean up installed Swift SDK: | ||
MaxDesiatov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
``` | ||
RUN: find %{swiftpm_homedir}/ -mindepth 1 -maxdepth 1 | xargs rm -rf | ||
RUN: %{swift-sdk} list | %{FileCheck} --check-prefix CHECK-SDK-LIST-FINAL %s | ||
CHECK-SDK-LIST-FINAL: No Swift SDKs are currently installed. | ||
Comment on lines
+50
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit scary to remove the shared Swift SDK directory in a test tbh 😅 How about isolating SDK installation directory by |
||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.