Merge pull request #468 from omochi/reduce-test-utils
Cleanup unnecessary test utilities
This commit is contained in:
commit
b62424fc6f
|
@ -22,14 +22,16 @@ import XCTest
|
|||
|
||||
final class BundleCommandTests: XCTestCase {
|
||||
func testWithNoArguments() async throws {
|
||||
let fs = localFileSystem
|
||||
|
||||
try await withFixture("EchoExecutable") { packageDirectory in
|
||||
let bundleDirectory = packageDirectory.appending(component: "Bundle")
|
||||
|
||||
let result = try await swiftRun(["carton", "bundle"], packageDirectory: packageDirectory.url)
|
||||
let result = try await swiftRun(["carton", "bundle"], packageDirectory: packageDirectory.asURL)
|
||||
try result.checkNonZeroExit()
|
||||
|
||||
// Confirm that the files are actually in the folder
|
||||
XCTAssertTrue(bundleDirectory.exists, "The Bundle directory should exist")
|
||||
XCTAssertTrue(fs.isDirectory(bundleDirectory), "The Bundle directory should exist")
|
||||
XCTAssertTrue(bundleDirectory.ls().contains("index.html"), "Bundle does not have index.html")
|
||||
XCTAssertFalse(
|
||||
(bundleDirectory.ls().filter { $0.contains("wasm") }).isEmpty,
|
||||
|
@ -45,7 +47,7 @@ final class BundleCommandTests: XCTestCase {
|
|||
func testWithDebugInfo() async throws {
|
||||
try await withFixture("EchoExecutable") { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "bundle", "--debug-info"], packageDirectory: packageDirectory.url
|
||||
["carton", "bundle", "--debug-info"], packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
|
||||
|
@ -64,7 +66,7 @@ final class BundleCommandTests: XCTestCase {
|
|||
func testWithoutContentHash() async throws {
|
||||
try await withFixture("EchoExecutable") { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "bundle", "--no-content-hash", "--wasm-optimizations", "none"], packageDirectory: packageDirectory.url
|
||||
["carton", "bundle", "--no-content-hash", "--wasm-optimizations", "none"], packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
|
||||
|
@ -84,7 +86,7 @@ final class BundleCommandTests: XCTestCase {
|
|||
|
||||
let result = try await swiftRun(
|
||||
["carton", "bundle", "--wasm-optimizations", wasmOptimizations.rawValue],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ final class DevCommandTests: XCTestCase {
|
|||
try await withFixture("EchoExecutable") { packageDirectory in
|
||||
let process = try swiftRunProcess(
|
||||
["carton", "dev", "--verbose", "--skip-auto-open"],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
|
||||
try await checkForExpectedContent(process: process, at: "http://127.0.0.1:8080")
|
||||
|
@ -43,7 +43,7 @@ final class DevCommandTests: XCTestCase {
|
|||
try await withFixture("EchoExecutable") { packageDirectory in
|
||||
let process = try swiftRunProcess(
|
||||
["carton", "dev", "--verbose", "--port", "8081", "--skip-auto-open"],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
|
||||
try await checkForExpectedContent(process: process, at: "http://127.0.0.1:8081")
|
||||
|
|
|
@ -31,7 +31,7 @@ final class TestCommandTests: XCTestCase {
|
|||
func testWithNoArguments() async throws {
|
||||
try await withFixture(Constants.testAppPackageName) { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "test"], packageDirectory: packageDirectory.url
|
||||
["carton", "test"], packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ final class TestCommandTests: XCTestCase {
|
|||
func testEnvironmentNodeNoJSKit() async throws {
|
||||
try await withFixture(Constants.testAppPackageName) { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.url
|
||||
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ final class TestCommandTests: XCTestCase {
|
|||
func testEnvironmentNodeJSKit() async throws {
|
||||
try await withFixture(Constants.nodeJSKitPackageName) { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.url
|
||||
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ final class TestCommandTests: XCTestCase {
|
|||
func testSkipBuild() async throws {
|
||||
try await withFixture(Constants.nodeJSKitPackageName) { packageDirectory in
|
||||
var result = try await swiftRun(
|
||||
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.url
|
||||
["carton", "test", "--environment", "node"], packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
|
||||
|
@ -68,7 +68,7 @@ final class TestCommandTests: XCTestCase {
|
|||
"--prebuilt-test-bundle-path",
|
||||
"./.build/carton/wasm32-unknown-wasi/debug/NodeJSKitTestPackageTests.wasm",
|
||||
],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ final class TestCommandTests: XCTestCase {
|
|||
try await withFixture(Constants.testAppPackageName) { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "test", "--environment", "browser", "--headless"],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ final class TestCommandTests: XCTestCase {
|
|||
try await withFixture(fixture) { packageDirectory in
|
||||
let result = try await swiftRun(
|
||||
["carton", "test", "--environment", "browser", "--headless"],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
XCTAssertNotEqual(result.exitStatus, .terminated(code: 0))
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ final class TestCommandTests: XCTestCase {
|
|||
// FIXME: Don't assume a specific port is available since it can be used by others or tests
|
||||
let result = try await swiftRun(
|
||||
["carton", "test", "--environment", "browser", "--port", "8082"],
|
||||
packageDirectory: packageDirectory.url
|
||||
packageDirectory: packageDirectory.asURL
|
||||
)
|
||||
try result.checkNonZeroExit()
|
||||
let output = try result.utf8Output()
|
||||
|
|
|
@ -58,14 +58,6 @@ func withFixture(_ name: String, _ body: (AbsolutePath) async throws -> Void) as
|
|||
}
|
||||
|
||||
extension AbsolutePath {
|
||||
var url: URL {
|
||||
URL(fileURLWithPath: pathString)
|
||||
}
|
||||
|
||||
var exists: Bool {
|
||||
FileManager.default.fileExists(atPath: pathString)
|
||||
}
|
||||
|
||||
func ls() -> [String] {
|
||||
guard let paths = try? FileManager.default.subpathsOfDirectory(atPath: pathString)
|
||||
else { return [] }
|
||||
|
|
Loading…
Reference in New Issue