test: always use temporary config when running ui tests

pull/12473/head
Lukas 2026-04-26 13:52:58 +02:00
parent b66258806e
commit a7eaecf929
No known key found for this signature in database
GPG Key ID: 1944A0A77B561220
1 changed files with 5 additions and 13 deletions

View File

@ -25,32 +25,24 @@ class GhosttyCustomConfigCase: XCTestCase {
static let defaultsSuiteName: String = "GHOSTTY_UI_TESTS" static let defaultsSuiteName: String = "GHOSTTY_UI_TESTS"
var configFile: URL? private let configFile: URL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("ghostty")
override func setUpWithError() throws { override func setUpWithError() throws {
continueAfterFailure = false continueAfterFailure = false
} }
override func tearDown() async throws { override func tearDown() async throws {
if let configFile { try? FileManager.default.removeItem(at: configFile)
try FileManager.default.removeItem(at: configFile)
}
} }
func updateConfig(_ newConfig: String) throws { func updateConfig(_ newConfig: String) throws {
if configFile == nil { try newConfig.write(to: configFile, atomically: true, encoding: .utf8)
let temporaryConfig = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("ghostty")
configFile = temporaryConfig
}
try newConfig.write(to: configFile!, atomically: true, encoding: .utf8)
} }
func ghosttyApplication(defaultsSuite: String = GhosttyCustomConfigCase.defaultsSuiteName) throws -> XCUIApplication { func ghosttyApplication(defaultsSuite: String = GhosttyCustomConfigCase.defaultsSuiteName) throws -> XCUIApplication {
let app = XCUIApplication() let app = XCUIApplication()
app.launchArguments.append(contentsOf: ["-ApplePersistenceIgnoreState", "YES"]) app.launchArguments.append(contentsOf: ["-ApplePersistenceIgnoreState", "YES"])
guard let configFile else {
return app
}
app.launchEnvironment["GHOSTTY_CONFIG_PATH"] = configFile.path app.launchEnvironment["GHOSTTY_CONFIG_PATH"] = configFile.path
app.launchEnvironment["GHOSTTY_USER_DEFAULTS_SUITE"] = defaultsSuite app.launchEnvironment["GHOSTTY_USER_DEFAULTS_SUITE"] = defaultsSuite
return app return app