Skip to content

Commit dd7929d

Browse files
authored
tests: Build on Linux even though tests are not currently run (#81)
The 'EndToEndTests' are only run on Linux but testing is currently disabled in CI. This makes it likely that the tests will not be built often and allows them to drift out of sync with the code they test without being noticed. * Use `--build-tests` in the CI wrapper script to ensure that the tests are built in CI, even if they are not run. * Fix EndToEnd test compilation failures caused by changes in `Shell.readStdout` after PR #77. * URL.appending(path:) is not available on Linux. CI runs EndToEnd tests on Linux, so we must use URL.appendingPathComponent()
1 parent c846d28 commit dd7929d

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Tests/SwiftSDKGeneratorTests/EndToEndTests.swift

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ final class EndToEndTests: XCTestCase {
5757

5858
for runArguments in possibleArguments {
5959
let generatorOutput = try await Shell.readStdout(
60-
"swift run swift-sdk-generator \(runArguments)",
61-
currentDirectory: packageDirectory
60+
"cd \(packageDirectory) && swift run swift-sdk-generator \(runArguments)"
6261
)
6362

6463
let installCommand = try XCTUnwrap(generatorOutput.split(separator: "\n").first {
@@ -80,26 +79,22 @@ final class EndToEndTests: XCTestCase {
8079
XCTAssertTrue(installOutput.contains("successfully installed"))
8180

8281
for testcase in testcases {
83-
let testPackageURL = FileManager.default.temporaryDirectory.appending(path: "swift-sdk-generator-test")
82+
let testPackageURL = FileManager.default.temporaryDirectory.appendingPathComponent("swift-sdk-generator-test")
8483
let testPackageDir = FilePath(testPackageURL.path)
8584
try? fm.removeItem(atPath: testPackageDir.string)
8685
try fm.createDirectory(atPath: testPackageDir.string, withIntermediateDirectories: true)
8786

88-
try await Shell.run("swift package init --type executable", currentDirectory: testPackageDir)
89-
let main_swift = testPackageURL.appending(path: "Sources/main.swift")
87+
try await Shell.run("swift package --package-path \(testPackageDir) init --type executable")
88+
let main_swift = testPackageURL.appendingPathComponent("Sources/main.swift")
9089
try testcase.write(to: main_swift, atomically: true, encoding: .utf8)
9190

9291
var buildOutput = try await Shell.readStdout(
93-
"swift build --experimental-swift-sdk \(bundleName)",
94-
currentDirectory: testPackageDir
92+
"swift build --package-path \(testPackageDir) --experimental-swift-sdk \(bundleName)"
9593
)
9694
XCTAssertTrue(buildOutput.contains("Build complete!"))
97-
98-
try await Shell.run("rm -rf .build", currentDirectory: testPackageDir)
99-
95+
try await Shell.run("rm -rf \(testPackageDir.appending(".build"))")
10096
buildOutput = try await Shell.readStdout(
101-
"swift build --experimental-swift-sdk \(bundleName) --static-swift-stdlib",
102-
currentDirectory: testPackageDir
97+
"swift build --package-path \(testPackageDir) --experimental-swift-sdk \(bundleName) --static-swift-stdlib"
10398
)
10499
XCTAssertTrue(buildOutput.contains("Build complete!"))
105100
}

Utilities/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ set -ex
1616
if [ "$(uname)" = Darwin ]; then
1717
swift test $@
1818
else
19-
swift build --vv $@
19+
swift build --build-tests --vv $@
2020
fi

0 commit comments

Comments
 (0)