Skip to content

Commit 9d0c4f1

Browse files
committed
fix(test): fix terminal integration test timeout on Mac CI
Await _createNewTerminal() in _showTerminal() so the VIEW_TERMINAL command completes only after PTY spawn finishes, eliminating a race where waitForShellReady() started its timer before the shell was spawned. Also add a fail-fast isAlive check in waitForShellReady() and an afterEach cleanup for leftover dialogs.
1 parent 0c7ce1f commit 9d0c4f1

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/extensionsIntegrated/Terminal/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ define(function (require, exports, module) {
541541
* are 2+ terminals, cycles to the next one. Otherwise just shows and
542542
* focuses the active terminal.
543543
*/
544-
function _showTerminal() {
544+
async function _showTerminal() {
545545
if (terminalInstances.length === 0) {
546-
_createNewTerminal();
546+
await _createNewTerminal();
547547
return;
548548
}
549549
const active = _getActiveTerminal();

test/spec/Terminal-integ-test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*/
2020

21-
/*global describe, it, expect, beforeAll, afterAll, awaitsFor, spyOn */
21+
/*global describe, it, expect, beforeAll, afterAll, afterEach, awaitsFor, spyOn */
2222

2323
define(function (require, exports, module) {
2424

@@ -81,6 +81,22 @@ define(function (require, exports, module) {
8181
await SpecRunnerUtils.closeTestWindow();
8282
}, 30000);
8383

84+
afterEach(async function () {
85+
// If a test failed and left a dialog open, dismiss it
86+
// so the next test starts from a clean state.
87+
if (testWindow && isDialogOpen()) {
88+
testWindow.$(".modal.instance .dialog-button")
89+
.last().click();
90+
try {
91+
await awaitsFor(function () {
92+
return !isDialogOpen();
93+
}, "dialog to close", 3000);
94+
} catch (e) {
95+
// ignore — best-effort cleanup
96+
}
97+
}
98+
});
99+
84100
// --- Helpers ---
85101

86102
async function openTerminal() {
@@ -136,6 +152,16 @@ define(function (require, exports, module) {
136152
* shell name (e.g. "bash") once process info is fetched.
137153
*/
138154
async function waitForShellReady() {
155+
const termModule = testWindow.brackets.getModule(
156+
"extensionsIntegrated/Terminal/main"
157+
);
158+
// Fail fast if the PTY never started
159+
await awaitsFor(function () {
160+
const active = termModule._getActiveTerminal();
161+
return active && active.isAlive;
162+
}, "terminal PTY to be alive", 10000);
163+
164+
// Then wait for process info
139165
await awaitsFor(function () {
140166
triggerFlyoutRefresh();
141167
const title = testWindow.$(

0 commit comments

Comments
 (0)