diff --git a/.swiftlint.yml b/.swiftlint.yml index 56dce418..94fc2828 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -15,3 +15,6 @@ function_body_length: 50 included: - Sources - Tests + +excluded: + - Tests/Fixtures/TestApp/.build diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7568a1ca..ecb3258d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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", @@ -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", diff --git a/Sources/CartonCLI/Commands/Test.swift b/Sources/CartonCLI/Commands/Test.swift index 499b7f80..e3db460e 100644 --- a/Sources/CartonCLI/Commands/Test.swift +++ b/Sources/CartonCLI/Commands/Test.swift @@ -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) diff --git a/Sources/SwiftToolchain/Toolchain.swift b/Sources/SwiftToolchain/Toolchain.swift index 544942f3..6d20da08 100644 --- a/Sources/SwiftToolchain/Toolchain.swift +++ b/Sources/SwiftToolchain/Toolchain.swift @@ -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" @@ -263,7 +266,7 @@ public final class Toolchain { try Builder( arguments: builderArguments, mainWasmPath: testBundlePath, - environment: .other, + environment: environment, fileSystem, terminal ) diff --git a/Tests/CartonCommandTests/TestCommandTests.swift b/Tests/CartonCommandTests/TestCommandTests.swift index 4fca33c5..c9d2ae8b 100644 --- a/Tests/CartonCommandTests/TestCommandTests.swift +++ b/Tests/CartonCommandTests/TestCommandTests.swift @@ -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", diff --git a/Tests/Fixtures/carton-test/TestApp/CustomPathTarget/text.swift b/Tests/Fixtures/TestApp/CustomPathTarget/text.swift similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/CustomPathTarget/text.swift rename to Tests/Fixtures/TestApp/CustomPathTarget/text.swift diff --git a/Tests/Fixtures/carton-test/TestApp/Package.resolved b/Tests/Fixtures/TestApp/Package.resolved similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/Package.resolved rename to Tests/Fixtures/TestApp/Package.resolved diff --git a/Tests/Fixtures/carton-test/TestApp/Package.swift b/Tests/Fixtures/TestApp/Package.swift similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/Package.swift rename to Tests/Fixtures/TestApp/Package.swift diff --git a/Tests/Fixtures/carton-test/TestApp/Sources/TestApp/data.json b/Tests/Fixtures/TestApp/Sources/TestApp/data.json similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/Sources/TestApp/data.json rename to Tests/Fixtures/TestApp/Sources/TestApp/data.json diff --git a/Tests/Fixtures/carton-test/TestApp/Sources/TestApp/main.swift b/Tests/Fixtures/TestApp/Sources/TestApp/main.swift similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/Sources/TestApp/main.swift rename to Tests/Fixtures/TestApp/Sources/TestApp/main.swift diff --git a/Tests/Fixtures/carton-test/TestApp/Sources/TestLibrary/text.swift b/Tests/Fixtures/TestApp/Sources/TestLibrary/text.swift similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/Sources/TestLibrary/text.swift rename to Tests/Fixtures/TestApp/Sources/TestLibrary/text.swift diff --git a/Tests/Fixtures/carton-test/TestApp/Tests/Tests/TrivialTest.swift b/Tests/Fixtures/TestApp/Tests/Tests/TrivialTest.swift similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/Tests/Tests/TrivialTest.swift rename to Tests/Fixtures/TestApp/Tests/Tests/TrivialTest.swift diff --git a/Tests/Fixtures/carton-test/TestApp/index.html b/Tests/Fixtures/TestApp/index.html similarity index 100% rename from Tests/Fixtures/carton-test/TestApp/index.html rename to Tests/Fixtures/TestApp/index.html