-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·108 lines (88 loc) · 2.3 KB
/
Copy pathtest
File metadata and controls
executable file
·108 lines (88 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/swift sh
import Bake
import BakeXcode // https://codeberg.org/openbakery/bake.git == main
import Foundation
let xcodeVersion = 26
let scheme = "PinLayout"
let deviceName = "iPhone 17 Pro"
let onlyTesting = [String]()
if CommandLine.arguments.count > 1 {
if CommandLine.arguments[1] == "--result" {
await printResult()
exit(0)
}
}
@discardableResult
func handle(error: Error) -> Int32 {
if let commandError = error as? Command.CommandError {
switch commandError {
case .failedExecution(let terminationStatus, _):
print("error: \(commandError)")
return terminationStatus
}
}
return 0
}
func printResult(json: Bool = false) async {
do {
let commandRunner = CommandRunner()
var arguments = ["build/Logs/Test"]
if json {
arguments.append("--json")
}
try await commandRunner.run("./scripts/xcresult_parser.swift", arguments: arguments)
} catch {
handle(error: error)
}
}
func runCarthage(xcode: Xcode) async {
do {
let commandRunner = xcode.commandRunner
await try commandRunner.run(
"/opt/homebrew/bin/carthage", arguments: ["bootstrap", "--platform", "iOS", "--use-xcframeworks", "--cache-builds"])
} catch {
let code = handle(error: error)
if code > 0 {
exit(code)
}
}
}
func delete(url: URL) async {
let fileManager = FileManager.default
do {
try fileManager.removeItem(at: url)
print("Directory deleted successfully")
} catch {
print("Error deleting directory: \(error)")
}
}
func clean() async {
await delete(url: URL(fileURLWithPath: "build"))
}
guard let xcode = try await Xcode(version: xcodeVersion) else {
print("No Xcode \(xcodeVersion) found")
exit(1)
}
print("Using: \(xcode)")
await delete(url: URL(fileURLWithPath: "build/Logs/Test"))
let simulatorControl = SimulatorControl(commandRunner: xcode.commandRunner)
guard var simulator = try await simulatorControl.simulator(name: deviceName, fuzzy: false) else {
print("simulator not found for: \(deviceName)")
exit(1)
}
var exitCode: Int32 = 0
do {
let xcodebuild = Xcodebuild(
command: .test,
scheme: scheme,
destination: simulator.destination,
onlyTest: onlyTesting,
retryTestsOnFailure: true,
xcode: xcode)
print("Build output goes to: \(xcodebuild.path)")
try await xcodebuild.execute()
} catch {
exitCode = handle(error: error)
}
await printResult()
exit(exitCode)