test: always use temporary config when running ui tests
parent
b66258806e
commit
a7eaecf929
|
|
@ -25,32 +25,24 @@ class GhosttyCustomConfigCase: XCTestCase {
|
|||
|
||||
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 {
|
||||
continueAfterFailure = false
|
||||
}
|
||||
|
||||
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 {
|
||||
if configFile == nil {
|
||||
let temporaryConfig = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
.appendingPathExtension("ghostty")
|
||||
configFile = temporaryConfig
|
||||
}
|
||||
try newConfig.write(to: configFile!, atomically: true, encoding: .utf8)
|
||||
try newConfig.write(to: configFile, atomically: true, encoding: .utf8)
|
||||
}
|
||||
|
||||
func ghosttyApplication(defaultsSuite: String = GhosttyCustomConfigCase.defaultsSuiteName) throws -> XCUIApplication {
|
||||
let app = XCUIApplication()
|
||||
app.launchArguments.append(contentsOf: ["-ApplePersistenceIgnoreState", "YES"])
|
||||
guard let configFile else {
|
||||
return app
|
||||
}
|
||||
app.launchEnvironment["GHOSTTY_CONFIG_PATH"] = configFile.path
|
||||
app.launchEnvironment["GHOSTTY_USER_DEFAULTS_SUITE"] = defaultsSuite
|
||||
return app
|
||||
|
|
|
|||
Loading…
Reference in New Issue