Skip to content

Commit 2555ee3

Browse files
committed
test: emit probe-chain diagnostics when the branch never arrives on CI
Three hardening strategies failed against these tests on hosted runners; on the next failure the message reports the prober's resolved git path, its synchronous inline snapshot, and the live probe state, so the failing link is identified from the CI log instead of guessed.
1 parent 45f3b8b commit 2555ee3

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

programaTests/TabManagerUnitTests.swift

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,29 @@ final class TabManagerPullRequestProbeTests: XCTestCase {
603603
}
604604

605605
XCTAssertNotEqual(manager.selectedTabId, backgroundWorkspace.id)
606-
XCTAssertTrue(
607-
// Real git subprocess + GitMetadataProber round trip, not a fixed dispatch
608-
// delay — needs the same headroom as testRemoteSplitSkipsInitialGitMetadataProbe
609-
// below under a full serial suite run's CPU contention.
610-
waitForCondition(timeout: 12.0) {
611-
backgroundWorkspace.panelGitBranches[backgroundPanelId]?.branch == "main"
612-
}
613-
)
606+
// Real git subprocess + GitMetadataProber round trip, not a fixed dispatch
607+
// delay — needs the same headroom as testRemoteSplitSkipsInitialGitMetadataProbe
608+
// below under a full serial suite run's CPU contention.
609+
let branchArrived = waitForCondition(timeout: 12.0) {
610+
backgroundWorkspace.panelGitBranches[backgroundPanelId]?.branch == "main"
611+
}
612+
if !branchArrived {
613+
// CI diagnostic: distinguish subprocess/env failure from async-apply failure.
614+
let gitPath = GitMetadataProber.resolvedCommandPathForTesting(
615+
executable: "git",
616+
environment: ProcessInfo.processInfo.environment,
617+
fallbackDirectories: ["/usr/bin", "/opt/homebrew/bin", "/usr/local/bin", "/opt/local/bin"]
618+
) ?? "UNRESOLVED"
619+
let inlineSnapshot = GitMetadataProber.initialWorkspaceGitMetadataSnapshot(for: repoURL.path)
620+
let probePanels = manager.activeWorkspaceGitProbePanelIdsForTesting(workspaceId: backgroundWorkspace.id)
621+
XCTFail(
622+
"branch never arrived. gitPath=\(gitPath) " +
623+
"inlineSnapshot(branch=\(inlineSnapshot.branch ?? "nil"), dirty=\(inlineSnapshot.isDirty)) " +
624+
"modelBranch=\(backgroundWorkspace.panelGitBranches[backgroundPanelId]?.branch ?? "nil") " +
625+
"activeProbes=\(probePanels.count) " +
626+
"bgWorkspaceDir=\(backgroundWorkspace.currentDirectory ?? "nil") repo=\(repoURL.path)"
627+
)
628+
}
614629
XCTAssertEqual(backgroundWorkspace.sidebarGitBranchesInDisplayOrder().map(\.branch), ["main"])
615630
}
616631

0 commit comments

Comments
 (0)