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"
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue