treefmt / nix fmt (pull_request) Successful in 3s
test ebook search / test-ebook-search (pull_request) Failing after 8h50m21s
pytest / pytest (pull_request) Failing after 8h50m22s
build_systems / build-rhapsody-in-green (pull_request) Failing after 8h50m23s
build_systems / build-portal-1 (pull_request) Failing after 8h50m24s
build_systems / build-jeeves (pull_request) Failing after 8h50m24s
build_systems / build-brain (pull_request) Failing after 8h50m24s
build_systems / build-bob (pull_request) Failing after 8h50m24s
37 lines
1.4 KiB
Diff
37 lines
1.4 KiB
Diff
Subject: [PATCH] tests: finish parsing before inspecting editor state
|
|
|
|
EditorState creation has a 20 ms parsing budget. A descheduled test can
|
|
therefore observe an incomplete tree. Finish these small test documents
|
|
without an interactive deadline and publish the result with a transaction.
|
|
Keep the original completion and vector-matching assertions enabled.
|
|
|
|
--- a/module/codemirror-promql/src/test/utils-test.ts
|
|
+++ b/module/codemirror-promql/src/test/utils-test.ts
|
|
@@ -13,7 +13,7 @@
|
|
|
|
import { parser } from '@prometheus-io/lezer-promql';
|
|
import { EditorState } from '@codemirror/state';
|
|
-import { LRLanguage } from '@codemirror/language';
|
|
+import { ensureSyntaxTree, LRLanguage } from '@codemirror/language';
|
|
import nock from 'nock';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
@@ -23,10 +23,16 @@
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
export function createEditorState(expr: string): EditorState {
|
|
- return EditorState.create({
|
|
+ const state = EditorState.create({
|
|
doc: expr,
|
|
extensions: lightPromQLSyntax,
|
|
});
|
|
+ // These tests need a complete tree, independent of the editor's time budget.
|
|
+ if (!ensureSyntaxTree(state, state.doc.length, Infinity)) {
|
|
+ throw new Error('Unable to parse the test expression');
|
|
+ }
|
|
+ // Publish the completed parse so syntaxTree(state) sees it too.
|
|
+ return state.update({}).state;
|
|
}
|
|
|
|
export function mockPrometheusServer(): void {
|