Skip to content

Commit b2b13ff

Browse files
committed
wasm: improve handling of qljs_vscode_create_document crashes
Expose LintingCrashed from DocumentLinter, not ProcessCrashed. This fixes false positives in our test suite, allowing us to enable more tests for more coverage.
1 parent 2952ced commit b2b13ff

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

wasm/quick-lint-js.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,19 @@ class DocumentLinter {
6969
assertEqual(this._state, DocumentLinterState.NO_PARSER);
7070
this._state = DocumentLinterState.CREATING_PARSER;
7171
this._parserPromise = (async () => {
72-
let factory = await this._documentProcessManager._processFactoryPromise;
73-
// TODO(strager): Reuse processes across documents.
74-
let process = await factory.createProcessAsync();
75-
let parser = await process.createDocumentForVSCodeAsync();
72+
let parser;
73+
try {
74+
let factory = await this._documentProcessManager._processFactoryPromise;
75+
// TODO(strager): Reuse processes across documents.
76+
let process = await factory.createProcessAsync();
77+
parser = await process.createDocumentForVSCodeAsync();
78+
} catch (e) {
79+
if (e instanceof ProcessCrashed) {
80+
throw new LintingCrashed(e);
81+
} else {
82+
throw e;
83+
}
84+
}
7685

7786
if (this._state === DocumentLinterState.DISPOSED) {
7887
parser.dispose();
@@ -101,7 +110,7 @@ class DocumentLinter {
101110
} catch (e) {
102111
if (e instanceof DocumentLinterDisposed) {
103112
// Ignore.
104-
} else if (e instanceof ProcessCrashed) {
113+
} else if (e instanceof LintingCrashed) {
105114
// Ignore.
106115
} else {
107116
throw e;

wasm/test-document.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,11 @@ describe("DocumentLinter", () => {
207207
!crashedProcesses.has(process),
208208
"Should not use previously-crashed process"
209209
);
210-
// TODO(strager): Figure out why qljs_vscode_create_document failures
211-
// cause this test to fail.
212-
if (functionName !== "qljs_vscode_create_document") {
213-
let shouldCrash = rng.nextCoinFlip();
214-
coinFlips.push(shouldCrash);
215-
if (shouldCrash) {
216-
crashedProcesses.add(process);
217-
throw new ProcessCrashed("(injected fault)");
218-
}
210+
let shouldCrash = rng.nextCoinFlip();
211+
coinFlips.push(shouldCrash);
212+
if (shouldCrash) {
213+
crashedProcesses.add(process);
214+
throw new ProcessCrashed("(injected fault)");
219215
}
220216
};
221217

0 commit comments

Comments
 (0)