Skip to content
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

Fix browser testing for Safari, update tasks.json #202

Merged
merged 2 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ function_body_length: 50
included:
- Sources
- Tests

excluded:
- Tests/Fixtures/TestApp/.build
30 changes: 15 additions & 15 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,57 @@
{
"label": "build and run dev",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton dev"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton dev"
},
{
"label": "build and run dev release",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton dev --release"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton dev --release"
},
{
"label": "build release and run dev",
"type": "shell",
"command": "swift build -c release && cd TestApp && ../.build/release/carton dev"
"command": "swift build -c release && cd Tests/Fixtures/TestApp && ../../../.build/release/carton dev"
},
{
"label": "build release and run dev verbose",
"type": "shell",
"command": "swift build -c release && cd TestApp && ../.build/release/carton dev -v"
"command": "swift build -c release && cd Tests/Fixtures/TestApp && ../../../.build/release/carton dev -v"
},
{
"label": "build and run dev on 9090 port",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton dev --port 9090"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton dev --port 9090"
},
{
"label": "build and run dev w/ custom index",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton dev --product TestApp --custom-index-page index.html"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton dev --product TestApp --custom-index-page index.html"
},
{
"label": "build and run dev in subdirectory",
"type": "shell",
"command": "swift build && cd TestApp/Sources/TestApp && ../../../.build/debug/carton dev --product TestApp"
"command": "swift build && cd Tests/Fixtures/TestApp/Sources/TestApp && ../../../.build/debug/carton dev --product TestApp"
},
{
"label": "build and run test",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton test"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton test"
},
{
"label": "build and run browser test",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton test --environment defaultBrowser"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton test --environment defaultBrowser"
},
{
"label": "build and run test list",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton test -l"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton test -l"
},
{
"label": "build and run test case",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton test Tests.Test/testTrivial"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton test Tests.Test/testTrivial"
},
{
"label": "build and hash static dependencies",
Expand All @@ -91,22 +91,22 @@
{
"label": "build and run bundle",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton bundle"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton bundle"
},
{
"label": "build and run bundle debug",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton bundle --debug"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton bundle --debug"
},
{
"label": "build and run bundle, log to file",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton bundle > .build/log"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton bundle > .build/log"
},
{
"label": "build and run bundle w/ custom index",
"type": "shell",
"command": "swift build && cd TestApp && ../.build/debug/carton bundle --custom-index-page index.html"
"command": "swift build && cd Tests/Fixtures/TestApp && ../../../.build/debug/carton bundle --custom-index-page index.html"
},
{
"type": "npm",
Expand Down
2 changes: 1 addition & 1 deletion Sources/CartonCLI/Commands/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct Test: ParsableCommand {

try Self.entrypoint.check(on: localFileSystem, terminal)
let toolchain = try Toolchain(localFileSystem, terminal)
let testBundlePath = try toolchain.buildTestBundle(isRelease: release)
let testBundlePath = try toolchain.buildTestBundle(isRelease: release, environment.destination)

if environment == .wasmer {
terminal.write("\nRunning the test bundle with wasmer:\n", inColor: .yellow)
Expand Down
7 changes: 5 additions & 2 deletions Sources/SwiftToolchain/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ public final class Toolchain {
}

/// Returns an absolute path to the resulting test bundle
public func buildTestBundle(isRelease: Bool) throws -> AbsolutePath {
public func buildTestBundle(
isRelease: Bool,
_ environment: DestinationEnvironment
) throws -> AbsolutePath {
let package = try self.package.get()
let binPath = try inferBinPath(isRelease: isRelease)
let testProductName = "\(package.name)PackageTests"
Expand All @@ -263,7 +266,7 @@ public final class Toolchain {
try Builder(
arguments: builderArguments,
mainWasmPath: testBundlePath,
environment: .other,
environment: environment,
fileSystem,
terminal
)
Expand Down
5 changes: 2 additions & 3 deletions Tests/CartonCommandTests/TestCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ extension TestCommandTests: Testable {}
final class TestCommandTests: XCTestCase {
func testWithNoArguments() throws {
// given I've created a directory
let package = "TestApp"
let packageDirectory = testFixturesDirectory.appending(components: "carton-test", package)
let packageDirectory = testFixturesDirectory.appending(components: "TestApp")

XCTAssertTrue(packageDirectory.exists, "The carton-test/TestApp directory does not exist")
XCTAssertTrue(packageDirectory.exists, "The TestApp directory does not exist")

AssertExecuteCommand(
command: "carton test",
Expand Down