diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de3289bf..a3654ce1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,11 +91,7 @@ jobs: rm -rf ~/Library/Developer/Xcode/DerivedData/GhosttyTabs-* - name: Run UI tests - env: - # Debug builds require CMUX_TAG to prevent accidental untagged launches. - # XCUITest launches the app as a separate process without XCTest env vars, - # so the app's isRunningUnderXCTest() check fails. Provide a tag explicitly. - CMUX_TAG: ci run: | set -euo pipefail + # Run directly on the self-hosted macOS runner. xcodebuild -project GhosttyTabs.xcodeproj -scheme cmux -configuration Debug -destination "platform=macOS" -only-testing:cmuxUITests/UpdatePillUITests test diff --git a/Sources/SocketControlSettings.swift b/Sources/SocketControlSettings.swift index da220b15..b9705095 100644 --- a/Sources/SocketControlSettings.swift +++ b/Sources/SocketControlSettings.swift @@ -230,6 +230,11 @@ struct SocketControlSettings { if isRunningUnderXCTest(environment: environment) { return false } + // XCUITest launches the app as a separate process without XCTest env vars, + // so isRunningUnderXCTest() misses it. Check for any CMUX_UI_TEST_ env var. + if environment.keys.contains(where: { $0.hasPrefix("CMUX_UI_TEST_") }) { + return false + } guard let bundleIdentifier = bundleIdentifier?.trimmingCharacters(in: .whitespacesAndNewlines), !bundleIdentifier.isEmpty else { diff --git a/cmuxTests/GhosttyConfigTests.swift b/cmuxTests/GhosttyConfigTests.swift index a788043b..0d912bb7 100644 --- a/cmuxTests/GhosttyConfigTests.swift +++ b/cmuxTests/GhosttyConfigTests.swift @@ -741,6 +741,18 @@ final class SocketControlSettingsTests: XCTestCase { ) ) } + + func testXCUITestLaunchEnvironmentIgnoresLaunchTagGate() { + // XCUITest launches the app as a separate process without XCTest env vars. + // The app receives CMUX_UI_TEST_* vars via XCUIApplication.launchEnvironment. + XCTAssertFalse( + SocketControlSettings.shouldBlockUntaggedDebugLaunch( + environment: ["CMUX_UI_TEST_MODE": "1"], + bundleIdentifier: "com.cmuxterm.app.debug", + isDebugBuild: true + ) + ) + } } final class PostHogAnalyticsPropertiesTests: XCTestCase {