From b66258806e1a6f9204c322d7bb2dbdb3fc464a17 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 26 Apr 2026 13:52:30 +0200 Subject: [PATCH 1/3] test: only change themes in theme tests --- macos/GhosttyUITests/GhosttyCommandPaletteTests.swift | 1 - macos/GhosttyUITests/GhosttyCustomConfigCase.swift | 4 ---- macos/GhosttyUITests/GhosttyMouseStateTests.swift | 2 -- macos/GhosttyUITests/GhosttyThemeTests.swift | 4 ++++ macos/GhosttyUITests/GhosttyWindowPositionUITests.swift | 2 -- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/macos/GhosttyUITests/GhosttyCommandPaletteTests.swift b/macos/GhosttyUITests/GhosttyCommandPaletteTests.swift index 428682b4f..8ebdaf6f0 100644 --- a/macos/GhosttyUITests/GhosttyCommandPaletteTests.swift +++ b/macos/GhosttyUITests/GhosttyCommandPaletteTests.swift @@ -8,7 +8,6 @@ import XCTest final class GhosttyCommandPaletteTests: GhosttyCustomConfigCase { - override static var runsForEachTargetApplicationUIConfiguration: Bool { false } @MainActor func testDismissingCommandPalette() async throws { let app = try ghosttyApplication() app.activate() diff --git a/macos/GhosttyUITests/GhosttyCustomConfigCase.swift b/macos/GhosttyUITests/GhosttyCustomConfigCase.swift index ca3f56677..645848095 100644 --- a/macos/GhosttyUITests/GhosttyCustomConfigCase.swift +++ b/macos/GhosttyUITests/GhosttyCustomConfigCase.swift @@ -23,10 +23,6 @@ class GhosttyCustomConfigCase: XCTestCase { } } - override class var runsForEachTargetApplicationUIConfiguration: Bool { - true - } - static let defaultsSuiteName: String = "GHOSTTY_UI_TESTS" var configFile: URL? diff --git a/macos/GhosttyUITests/GhosttyMouseStateTests.swift b/macos/GhosttyUITests/GhosttyMouseStateTests.swift index b8f202617..68317f076 100644 --- a/macos/GhosttyUITests/GhosttyMouseStateTests.swift +++ b/macos/GhosttyUITests/GhosttyMouseStateTests.swift @@ -8,8 +8,6 @@ import XCTest final class GhosttyMouseStateTests: GhosttyCustomConfigCase { - override static var runsForEachTargetApplicationUIConfiguration: Bool { false } - // https://github.com/ghostty-org/ghostty/pull/11276 @MainActor func testSelectionFocusChange() async throws { let app = XCUIApplication() diff --git a/macos/GhosttyUITests/GhosttyThemeTests.swift b/macos/GhosttyUITests/GhosttyThemeTests.swift index f8f5286fb..eb5b78a09 100644 --- a/macos/GhosttyUITests/GhosttyThemeTests.swift +++ b/macos/GhosttyUITests/GhosttyThemeTests.swift @@ -9,6 +9,10 @@ import AppKit import XCTest final class GhosttyThemeTests: GhosttyCustomConfigCase { + override static var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + let windowTitle = "GhosttyThemeTests" private func assertTitlebarAppearance( _ appearance: XCUIDevice.Appearance, diff --git a/macos/GhosttyUITests/GhosttyWindowPositionUITests.swift b/macos/GhosttyUITests/GhosttyWindowPositionUITests.swift index 399c2531a..b5739edf6 100644 --- a/macos/GhosttyUITests/GhosttyWindowPositionUITests.swift +++ b/macos/GhosttyUITests/GhosttyWindowPositionUITests.swift @@ -8,8 +8,6 @@ import XCTest final class GhosttyWindowPositionUITests: GhosttyCustomConfigCase { - override static var runsForEachTargetApplicationUIConfiguration: Bool { false } - // MARK: - Cascading @MainActor func testWindowCascading() async throws { From a7eaecf929b9a060962d3491d926f7d6b8fd0c63 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 26 Apr 2026 13:52:58 +0200 Subject: [PATCH 2/3] test: always use temporary config when running ui tests --- .../GhosttyCustomConfigCase.swift | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/macos/GhosttyUITests/GhosttyCustomConfigCase.swift b/macos/GhosttyUITests/GhosttyCustomConfigCase.swift index 645848095..5df4b432a 100644 --- a/macos/GhosttyUITests/GhosttyCustomConfigCase.swift +++ b/macos/GhosttyUITests/GhosttyCustomConfigCase.swift @@ -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 From df365baf18180577e099c66c23858dab3fd3eeb2 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 26 Apr 2026 14:45:05 +0200 Subject: [PATCH 3/3] test: add test plan and override default config when running tests --- macos/Ghostty.xcodeproj/project.pbxproj | 2 + .../xcshareddata/xcschemes/Ghostty.xcscheme | 9 +++- macos/Ghostty.xctestplan | 49 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 macos/Ghostty.xctestplan diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index fb24d0813..c4ac0cdf2 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -73,6 +73,7 @@ 3B39CAA42B33949B00DABEB8 /* GhosttyReleaseLocal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GhosttyReleaseLocal.entitlements; sourceTree = ""; }; 55154BDF2B33911F001622DC /* ghostty */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ghostty; path = "../zig-out/share/ghostty"; sourceTree = ""; }; 552964E52B34A9B400030505 /* vim */ = {isa = PBXFileReference; lastKnownFileType = folder; name = vim; path = "../zig-out/share/vim"; sourceTree = ""; }; + 80B155F32F9E3FF90040F9D8 /* Ghostty.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ghostty.xctestplan; sourceTree = ""; }; 810ACC9F2E9D3301004F8F92 /* GhosttyUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GhosttyUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8193244D2F24E6C000A9ED8F /* DockTilePlugin.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DockTilePlugin.plugin; sourceTree = BUILT_PRODUCTS_DIR; }; 8F3A9B4B2FA6B88000A18D13 /* Ghostty.sdef */ = {isa = PBXFileReference; lastKnownFileType = text.sdef; path = Ghostty.sdef; sourceTree = ""; }; @@ -337,6 +338,7 @@ A5B30528299BEAAA0047F10C = { isa = PBXGroup; children = ( + 80B155F32F9E3FF90040F9D8 /* Ghostty.xctestplan */, A571AB1C2A206FC600248498 /* Ghostty-Info.plist */, 8F3A9B4B2FA6B88000A18D13 /* Ghostty.sdef */, A5B30538299BEAAB0047F10C /* Assets.xcassets */, diff --git a/macos/Ghostty.xcodeproj/xcshareddata/xcschemes/Ghostty.xcscheme b/macos/Ghostty.xcodeproj/xcshareddata/xcschemes/Ghostty.xcscheme index 2b4f815ea..16be46d67 100644 --- a/macos/Ghostty.xcodeproj/xcshareddata/xcschemes/Ghostty.xcscheme +++ b/macos/Ghostty.xcodeproj/xcshareddata/xcschemes/Ghostty.xcscheme @@ -26,8 +26,13 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES" - shouldAutocreateTestPlan = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES"> + + + +