From f088ce38d9f736130ff3b8f1a11aa0d353a27f1c Mon Sep 17 00:00:00 2001 From: Lars <134181853+bo2themax@users.noreply.github.com> Date: Fri, 17 Oct 2025 00:09:25 +0200 Subject: [PATCH] test: read config before launching XCUIApplication --- .../GhosttyCustomConfigCase.swift | 18 +++++++++--------- macos/GhosttyUITests/GhosttyTitleUITests.swift | 2 +- .../GhosttyTitlebarTabsUITests.swift | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/macos/GhosttyUITests/GhosttyCustomConfigCase.swift b/macos/GhosttyUITests/GhosttyCustomConfigCase.swift index a944e9f52..112dc1da4 100644 --- a/macos/GhosttyUITests/GhosttyCustomConfigCase.swift +++ b/macos/GhosttyUITests/GhosttyCustomConfigCase.swift @@ -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 } } diff --git a/macos/GhosttyUITests/GhosttyTitleUITests.swift b/macos/GhosttyUITests/GhosttyTitleUITests.swift index 5e9ade1c9..904f54220 100644 --- a/macos/GhosttyUITests/GhosttyTitleUITests.swift +++ b/macos/GhosttyUITests/GhosttyTitleUITests.swift @@ -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!") diff --git a/macos/GhosttyUITests/GhosttyTitlebarTabsUITests.swift b/macos/GhosttyUITests/GhosttyTitlebarTabsUITests.swift index f6d4563cc..949abe7e1 100644 --- a/macos/GhosttyUITests/GhosttyTitlebarTabsUITests.swift +++ b/macos/GhosttyUITests/GhosttyTitlebarTabsUITests.swift @@ -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)