Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions packages/vscode/e2e/lint/suite-ancestor/ancestor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,38 @@ suite('rslint config above the workspace folder', function () {
diagnosticRuleIdIncludes(diagnostic, 'no-debugger'),
);

// On macOS, Node's directory `fs.watch` runs on one FSEventStream per
// process, and libuv destroys and recreates that stream (from
// `kFSEventStreamEventIdSinceNow`) whenever a directory watcher starts or
// stops. VS Code's non-recursive watchers share one watcher process, so an
// edit made while any other directory watcher starts can be lost by all of
// them. Startup still churns watchers right after the first diagnostics (Go
// registers its own ancestor watchers only once initialized), and macOS CI
// lost the first edit there: the diagnostics never changed. Writing the same
// content again, as a user saving twice would, re-signals the edit. The
// diagnostics must still follow the file within the overall timeout.
async function writeConfigUntilDiagnostics(
document: vscode.TextDocument,
filePath: string,
content: string,
predicate: (diagnostics: vscode.Diagnostic[]) => boolean,
): Promise<void> {
const deadline = Date.now() + 60_000;
for (;;) {
fs.writeFileSync(filePath, content);
try {
await waitForDiagnostics(
document,
predicate,
Math.max(0, Math.min(10_000, deadline - Date.now())),
);
return;
} catch (error) {
if (Date.now() >= deadline) throw error;
}
}
}

teardown(async () => {
fs.rmSync(nearerConfigPath(), { force: true });
fs.writeFileSync(rootConfigPath(), configWithNoDebugger('error'));
Expand All @@ -56,14 +88,19 @@ suite('rslint config above the workspace folder', function () {
const document = await openIndex();
await waitForDiagnostics(document, hasNoDebugger);

fs.writeFileSync(rootConfigPath(), configWithNoDebugger('off'));
await waitForDiagnostics(
await writeConfigUntilDiagnostics(
document,
rootConfigPath(),
configWithNoDebugger('off'),
(diagnostics) => !hasNoDebugger(diagnostics),
);

fs.writeFileSync(rootConfigPath(), configWithNoDebugger('error'));
await waitForDiagnostics(document, hasNoDebugger);
await writeConfigUntilDiagnostics(
document,
rootConfigPath(),
configWithNoDebugger('error'),
hasNoDebugger,
);
});

// The live runtime keeps its key; the extension's ancestor watchers send
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
"@vscode/test-electron": "^3.1.0",
"@vscode/vsce": "^3.9.2",
"birpc": "^4.2.0",
"core-js-pure": "^3.50.0",
"core-js-pure": "^3.51.0",
"mocha": "^11.8.0",
"ovsx": "^1.3.0",
"picomatch": "^4.0.7",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading