Skip to content

Commit

Permalink
Use Tests/.build directory for EndToEndTests instead of tmp directory
Browse files Browse the repository at this point in the history
 - This helps improve the time it takes to run the EndToEndTests since the generator does not need to be rebuild for each test.
  • Loading branch information
xtremekforever committed Jan 8, 2025
1 parent b9822fc commit 2e6bd28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
/.build
.build*
/.index-build
/Packages
/*.xcodeproj
Expand Down
11 changes: 3 additions & 8 deletions Tests/SwiftSDKGeneratorTests/EndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ extension FileManager {
}
}

// Building an SDK requires running the sdk-generator with `swift run swift-sdk-generator`.
// This takes a lock on `.build`, but if the tests are being run by `swift test` the outer Swift Package Manager
// instance will already hold this lock, causing the test to deadlock. We can work around this by giving
// the `swift run swift-sdk-generator` instance its own scratch directory.
func buildSDK(_ logger: Logger, scratchPath: String, withArguments runArguments: String) async throws -> String {
// This will build and run the generator in a separate .build directory from the main one
func buildSDK(_ logger: Logger, scratchPath: String = ".build", withArguments runArguments: String) async throws -> String {
var logger = logger
logger[metadataKey: "runArguments"] = "\"\(runArguments)\""
logger[metadataKey: "scratchPath"] = "\(scratchPath)"
Expand Down Expand Up @@ -230,9 +227,7 @@ func buildTestcases(config: SDKConfiguration) async throws {
}
}

let bundleName = try await FileManager.default.withTemporaryDirectory(logger: logger) { tempDir in
try await buildSDK(logger, scratchPath: tempDir.path, withArguments: config.sdkGeneratorArguments)
}
let bundleName = try await buildSDK(logger, withArguments: config.sdkGeneratorArguments)

logger.info("Built SDK")

Expand Down

0 comments on commit 2e6bd28

Please sign in to comment.