test: read config before launching XCUIApplication

This commit is contained in:
Lars
2025-10-17 00:09:25 +02:00
committed by Mitchell Hashimoto
parent f7608d0b95
commit f088ce38d9
3 changed files with 14 additions and 14 deletions

View File

@@ -15,13 +15,6 @@ class GhosttyCustomConfigCase: XCTestCase {
var configFile: URL?
override func setUpWithError() throws {
continueAfterFailure = false
guard let customGhosttyConfig else {
return
}
let temporaryConfig = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("ghostty")
try customGhosttyConfig.write(to: temporaryConfig, atomically: true, encoding: .utf8)
configFile = temporaryConfig
}
override func tearDown() async throws {
@@ -34,10 +27,17 @@ class GhosttyCustomConfigCase: XCTestCase {
nil
}
func ghosttyApplication() -> XCUIApplication {
func ghosttyApplication() throws -> XCUIApplication {
let app = XCUIApplication()
app.launchEnvironment["GHOSTTY_CONFIG_PATH"] = configFile?.path
app.launchArguments.append(contentsOf: ["-ApplePersistenceIgnoreState", "YES"])
guard let customGhosttyConfig else {
return app
}
let temporaryConfig = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("ghostty")
try customGhosttyConfig.write(to: temporaryConfig, atomically: true, encoding: .utf8)
configFile = temporaryConfig
app.launchEnvironment["GHOSTTY_CONFIG_PATH"] = configFile?.path
return app
}
}

View File

@@ -15,7 +15,7 @@ final class GhosttyTitleUITests: GhosttyCustomConfigCase {
@MainActor
func testTitle() throws {
let app = ghosttyApplication()
let app = try ghosttyApplication()
app.launch()
XCTAssert(app.windows.firstMatch.title == "GhosttyUITestsLaunchTests", "Oops, `title=` doesn't work!")

View File

@@ -17,7 +17,7 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
@MainActor
func testCustomTitlebar() throws {
let app = ghosttyApplication()
let app = try ghosttyApplication()
app.launch()
// create a split
app.groups["Terminal pane"].typeKey("d", modifierFlags: .command)
@@ -31,7 +31,7 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
@MainActor
func testTabsGeometryInNormalWindow() throws {
let app = ghosttyApplication()
let app = try ghosttyApplication()
app.launch()
app.groups["Terminal pane"].typeKey("t", modifierFlags: .command)
XCTAssert(app.tabs.count == 2, "There should be 2 tabs")
@@ -40,7 +40,7 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
@MainActor
func testTabsGeometryInFullscreen() throws {
let app = ghosttyApplication()
let app = try ghosttyApplication()
app.launch()
app.typeKey("f", modifierFlags: [.command, .control])
// using app to type +t might not be able to create tabs
@@ -51,7 +51,7 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
@MainActor
func testTabsGeometryAfterMovingTabs() throws {
let app = ghosttyApplication()
let app = try ghosttyApplication()
app.launch()
// create 3 tabs
app.groups["Terminal pane"].typeKey("t", modifierFlags: .command)