Skip to content

Commit fede9af

Browse files
committed
fix(test): fix intermittent terminal and PreferencesManager test timeouts
Terminal test: replace unreliable PS1-based terminal title check with direct `pwd` buffer output check. The title check depended on the shell having PS1 escape sequences that set the terminal title, which varies across CI environments. PreferencesManager test: increase awaitsFor timeouts from the default 2s to 10s in _verifySinglePreference, since loading projects and applying preferences can be slow in CI.
1 parent eac5cdd commit fede9af

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

test/spec/PreferencesManager-integ-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ define(function (require, exports, module) {
5858
await awaitsForDone(SpecRunnerUtils.openProjectFiles(fileName));
5959
await awaitsFor(()=>{
6060
return PreferencesManager.get("spaceUnits") === expectedSpaceUnits;
61-
}, "space units to be "+expectedSpaceUnits);
61+
}, "space units to be "+expectedSpaceUnits, 10000);
6262
await awaitsForDone(FileViewController.openAndSelectDocument(nonProjectFile,
6363
FileViewController.WORKING_SET_VIEW));
6464

6565
await awaitsFor(()=>{
6666
return PreferencesManager.get("spaceUnits") !== expectedSpaceUnits;
67-
}, "space non project file units not to be "+expectedSpaceUnits);
67+
}, "space non project file units not to be "+expectedSpaceUnits, 10000);
6868

6969
// Changing projects will force a change in the project scope.
7070
await SpecRunnerUtils.loadProjectInTestWindow(projectWithoutSettings);
7171
await awaitsForDone(SpecRunnerUtils.openProjectFiles("file_one.js"));
7272
await awaitsFor(()=>{
7373
return PreferencesManager.get("spaceUnits") !== expectedSpaceUnits;
74-
}, "space units not to be "+expectedSpaceUnits);
74+
}, "space units not to be "+expectedSpaceUnits, 10000);
7575
}
7676

7777
it("should find .phcode.json preferences in the project", async function () {

test/spec/Terminal-integ-test.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,40 @@ define(function (require, exports, module) {
222222
).attr("title") || "";
223223
expect(flyoutTitle).not.toBe("");
224224
} else {
225-
// On Linux, bash/zsh set the title to
226-
// include the cwd (e.g. "user@host: /path").
227-
// Wait for shell ready first, then trigger
228-
// a prompt refresh so PS1 title escapes fire.
225+
// On Linux, verify the cwd by running `pwd`
226+
// and checking the terminal buffer. This is
227+
// more reliable than checking the terminal
228+
// title, which depends on the shell's PS1
229+
// including title-setting escape sequences.
229230
await waitForShellReady();
230-
await writeToTerminal("echo\r");
231+
await writeToTerminal("pwd\r");
231232

232233
const expectedPath = getNativeProjectPath();
233234
const projectDirName = expectedPath
234235
.split("/").pop().split("\\").pop();
235236

237+
const termModule = testWindow.brackets
238+
.getModule(
239+
"extensionsIntegrated/Terminal/main"
240+
);
236241
await awaitsFor(function () {
237-
const title = testWindow.$(
238-
".terminal-flyout-item.active"
239-
).attr("title") || "";
240-
return title.indexOf(projectDirName) !== -1;
241-
}, "terminal title to contain project dir",
242-
10000);
243-
244-
const flyoutTitle = testWindow.$(
245-
".terminal-flyout-item.active"
246-
).attr("title") || "";
247-
expect(flyoutTitle).toContain(projectDirName);
242+
const active =
243+
termModule._getActiveTerminal();
244+
if (!active) {
245+
return false;
246+
}
247+
const buffer =
248+
active.terminal.buffer.active;
249+
for (let i = 0; i < buffer.length; i++) {
250+
const line = buffer.getLine(i);
251+
if (line && line.translateToString()
252+
.indexOf(projectDirName) !== -1) {
253+
return true;
254+
}
255+
}
256+
return false;
257+
}, "pwd output to contain project dir",
258+
15000);
248259
}
249260
});
250261

0 commit comments

Comments
 (0)