Skip to content

Commit 4267736

Browse files
committed
Fixing some more tests
1 parent 3e508d1 commit 4267736

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

Sources/Pipeline/SwiftInterfaceProducer.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// File.swift
3-
//
4-
//
5-
// Created by Alexander Guretzki on 09/10/2024.
6-
//
7-
81
import Foundation
92

103
/// Allows building of the old & new project and returns the `.swiftinterface` files

Sources/public-api-diff.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ struct PublicApiDiff: AsyncParsableCommand {
2828
public func run() async throws {
2929

3030
let logLevel: LogLevel = .debug
31-
let projectType: ProjectType = .swiftPackage // Only needed when we have to produce the .swiftinterface files
31+
let projectType: ProjectType = { // Only needed when we have to produce the .swiftinterface files
32+
if let scheme { return .xcodeProject(scheme: scheme) }
33+
return .swiftPackage
34+
}()
3235
let swiftInterfaceType: SwiftInterfaceType = .public // Only needed when we have to produce the .swiftinterface files
3336

3437
let fileHandler: FileHandling = FileManager.default

Tests/UnitTests/LoggerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class LoggerTests: XCTestCase {
7171
let logFileLogger = LogFileLogger(fileHandler: fileHandler, outputFilePath: outputFilePath)
7272

7373
logFileLogger.log("log", from: "test")
74+
// Small sleep because the file manager calls are done on a detached Task and we want to guarantee the order
75+
try await Task.sleep(for: .milliseconds(10))
7476
logFileLogger.debug("debug", from: "test")
7577

7678
await fulfillment(of: [removeExpectation])

Tests/UnitTests/XcodeToolsTests.swift

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,45 @@ class XcodeToolsTests: XCTestCase {
1313

1414
let projectDirectoryPath = "PROJECT_DIRECTORY_PATH"
1515
let scheme = "SCHEME"
16-
let projectType = ProjectType.swiftPackage
16+
17+
try await testArchiving(
18+
projectDirectoryPath: projectDirectoryPath,
19+
scheme: scheme,
20+
projectType: .swiftPackage
21+
)
22+
}
23+
24+
func test_archive_xcodeProject() async throws {
25+
26+
let projectDirectoryPath = "PROJECT_DIRECTORY_PATH"
27+
let scheme = "SCHEME"
28+
29+
try await testArchiving(
30+
projectDirectoryPath: projectDirectoryPath,
31+
scheme: scheme,
32+
projectType: .xcodeProject(scheme: scheme)
33+
)
34+
}
35+
}
36+
37+
private extension XcodeToolsTests {
38+
39+
func testArchiving(
40+
projectDirectoryPath: String,
41+
scheme: String,
42+
projectType: ProjectType
43+
) async throws {
1744

1845
let archiveResult = "ARCHIVE_RESULT"
1946
let expectedDerivedDataPath = "\(projectDirectoryPath)/.build"
20-
var expectedHandleExecuteCalls = ["cd \(projectDirectoryPath); xcodebuild clean build -scheme \"\(scheme)\" -destination \"generic/platform=iOS\" -derivedDataPath .build -sdk `xcrun --sdk iphonesimulator --show-sdk-path` BUILD_LIBRARY_FOR_DISTRIBUTION=YES -skipPackagePluginValidation"]
47+
var expectedHandleExecuteCalls: [String] = {
48+
switch projectType {
49+
case .swiftPackage:
50+
["cd \(projectDirectoryPath); xcodebuild clean build -scheme \"\(scheme)\" -destination \"generic/platform=iOS\" -derivedDataPath .build -sdk `xcrun --sdk iphonesimulator --show-sdk-path` BUILD_LIBRARY_FOR_DISTRIBUTION=YES -skipPackagePluginValidation"]
51+
case .xcodeProject(let scheme):
52+
["cd \(projectDirectoryPath); xcodebuild clean build -scheme \"\(scheme)\" -destination \"generic/platform=iOS\" -derivedDataPath .build -sdk `xcrun --sdk iphonesimulator --show-sdk-path` BUILD_LIBRARY_FOR_DISTRIBUTION=YES"]
53+
}
54+
}()
2155
var expectedHandleLogCalls: [(message: String, subsystem: String)] = [
2256
("📦 Archiving SCHEME from PROJECT_DIRECTORY_PATH", "XcodeTools")
2357
]

0 commit comments

Comments
 (0)