Skip to content

Commit 2f0eeaa

Browse files
Check if editor is opened
1 parent f883ec7 commit 2f0eeaa

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
VSCODE_LOGS_DIR: ${{ github.workspace }}/artifacts/logs
3232
CURSORLESS_REPO_ROOT: ${{ github.workspace }}
3333
TEMP_DIR: ${{ github.workspace }}/temp
34-
NODE_OPTIONS: "--max-old-space-size=4096 --force-node-api-uncaught-exceptions-policy=true"
34+
NODE_OPTIONS: "--max-old-space-size=4096"
3535

3636
steps:
3737
- name: Checkout repository

packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from "@cursorless/vscode-common";
66
import assert from "assert";
77
import { window } from "vscode";
8-
import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup";
8+
import { endToEndTestSetup } from "../endToEndTestSetup";
99

1010
// Check that setSelection is able to focus the correct cell
1111
suite("Cross-cell set selection", async function () {
@@ -19,10 +19,6 @@ async function runTest() {
1919

2020
await openNewNotebookEditor(['"hello"', '"world"']);
2121

22-
// FIXME: There seems to be some timing issue when you create a notebook
23-
// editor
24-
await sleepWithBackoff(1000);
25-
2622
await hatTokenMap.allocateHats();
2723

2824
await runCursorlessCommand({

packages/cursorless-vscode-e2e/src/suite/editNewCell.vscode.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ async function runTest(
2828
const { hatTokenMap } = (await getCursorlessApi()).testHelpers!;
2929
const notebook = await openNewNotebookEditor(["hello"]);
3030

31-
// FIXME: There seems to be some timing issue when you create a notebook
32-
// editor
33-
await sleepWithBackoff(500);
34-
3531
await hatTokenMap.allocateHats();
3632

3733
assert.equal(notebook.cellCount, 1);

packages/cursorless-vscode-e2e/src/suite/intraCellSetSelection.vscode.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
getCursorlessApi,
33
openNewNotebookEditor,
4+
runCursorlessCommand,
45
} from "@cursorless/vscode-common";
56
import assert from "assert";
67
import { window } from "vscode";
7-
import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup";
8-
import { runCursorlessCommand } from "@cursorless/vscode-common";
8+
import { endToEndTestSetup } from "../endToEndTestSetup";
99

1010
// Check that setSelection is able to focus the correct cell
1111
suite("Within cell set selection", async function () {
@@ -19,10 +19,6 @@ async function runTest() {
1919

2020
await openNewNotebookEditor(['"hello world"']);
2121

22-
// FIXME: There seems to be some timing issue when you create a notebook
23-
// editor
24-
await sleepWithBackoff(1000);
25-
2622
await hatTokenMap.allocateHats();
2723

2824
await runCursorlessCommand({
@@ -40,7 +36,7 @@ async function runTest() {
4036
],
4137
});
4238

43-
const editor = window.activeTextEditor; // eslint-disable-line no-restricted-properties
39+
const editor = window.activeTextEditor;
4440

4541
if (editor == null) {
4642
assert(false, "No editor was focused");

packages/test-harness/src/launchVscodeAndRunTests.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ export async function launchVscodeAndRunTests(extensionTestsPath: string) {
8585
useLegacyVscode || os.platform() === "win32"
8686
? undefined
8787
: [`--crash-reporter-directory=${crashDir}`, `--logsPath=${logsDir}`],
88-
extensionTestsEnv: {
89-
["NODE_OPTIONS"]:
90-
"--max-old-space-size=4096 --force-node-api-uncaught-exceptions-policy=true",
91-
},
9288
});
9389

9490
console.log(`Returned from "runTests" with value: ${code}`);

packages/test-harness/src/runAllTests.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ async function runTestsInDir(
7171
// Add files to the test suite
7272
files.forEach((f) => mocha.addFile(path.resolve(testRoot, f)));
7373

74-
console.log(`Running tests in ${testRoot} for ${files.length} files`);
75-
console.log(JSON.stringify(process.argv, null, 2));
76-
console.log(JSON.stringify(process.execArgv, null, 2));
77-
console.log(JSON.stringify(process.env, null, 2));
78-
7974
try {
8075
// Run the mocha test
8176
await new Promise<void>((resolve, reject) => {

packages/vscode-common/src/testUtil/openNewEditor.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,27 @@ export async function openNewNotebookEditor(
9696

9797
await (await getParseTreeApi()).loadLanguage(language);
9898

99+
// FIXME: There seems to be some timing issue when you create a notebook
100+
// editor
101+
await waitForEditorToOpen();
102+
99103
return document;
100104
}
105+
106+
function waitForEditorToOpen() {
107+
return new Promise<void>((resolve, reject) => {
108+
let count = 0;
109+
const interval = setInterval(() => {
110+
if (vscode.window.activeTextEditor != null) {
111+
clearInterval(interval);
112+
resolve();
113+
} else {
114+
count++;
115+
if (count === 20) {
116+
clearInterval(interval);
117+
reject("Timed out waiting for editor to open");
118+
}
119+
}
120+
}, 100);
121+
});
122+
}

0 commit comments

Comments
 (0)