@hydranium/core 1.0.0-next.4 → 1.0.0-next.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/documents/ast-document-manager.d.ts +42 -5
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +9 -12
- package/lib/documents/ast-document-manager.js.map +1 -1
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +41 -9
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/documents/language-client-text-shadow.d.ts +24 -1
- package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
- package/lib/documents/language-client-text-shadow.js +36 -2
- package/lib/documents/language-client-text-shadow.js.map +1 -1
- package/lib/documents/self-save-registry.d.ts +37 -6
- package/lib/documents/self-save-registry.d.ts.map +1 -1
- package/lib/documents/self-save-registry.js +28 -15
- package/lib/documents/self-save-registry.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.d.ts +32 -9
- package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.js +60 -22
- package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
- package/lib/langium/bootstrap.d.ts.map +1 -1
- package/lib/langium/bootstrap.js +16 -9
- package/lib/langium/bootstrap.js.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts +13 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.js +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
- package/lib/langium/document-builder/build-session.d.ts +93 -0
- package/lib/langium/document-builder/build-session.d.ts.map +1 -0
- package/lib/langium/document-builder/build-session.js +72 -0
- package/lib/langium/document-builder/build-session.js.map +1 -0
- package/lib/langium/document-builder/document-builder.d.ts +150 -7
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +298 -11
- package/lib/langium/document-builder/document-builder.js.map +1 -1
- package/lib/langium/document-builder/index.d.ts +1 -0
- package/lib/langium/document-builder/index.d.ts.map +1 -1
- package/lib/langium/document-builder/index.js +1 -0
- package/lib/langium/document-builder/index.js.map +1 -1
- package/lib/langium/integration-services.d.ts +45 -1
- package/lib/langium/integration-services.d.ts.map +1 -1
- package/lib/langium/integration-services.js +10 -5
- package/lib/langium/integration-services.js.map +1 -1
- package/lib/langium/integrity/integrity-service.d.ts +5 -0
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-service.js +34 -1
- package/lib/langium/integrity/integrity-service.js.map +1 -1
- package/lib/langium/keys/containment.d.ts +64 -0
- package/lib/langium/keys/containment.d.ts.map +1 -0
- package/lib/langium/keys/containment.js +53 -0
- package/lib/langium/keys/containment.js.map +1 -0
- package/lib/langium/keys/index.d.ts +1 -0
- package/lib/langium/keys/index.d.ts.map +1 -1
- package/lib/langium/keys/index.js +1 -0
- package/lib/langium/keys/index.js.map +1 -1
- package/lib/langium/keys/name-based-key-provider.d.ts +4 -0
- package/lib/langium/keys/name-based-key-provider.d.ts.map +1 -1
- package/lib/langium/keys/name-based-key-provider.js +4 -0
- package/lib/langium/keys/name-based-key-provider.js.map +1 -1
- package/lib/langium/model-service/model-service.d.ts +103 -7
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +70 -89
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +82 -13
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +21 -12
- package/lib/langium/module.js.map +1 -1
- package/lib/langium/naming/name-provider.d.ts +10 -0
- package/lib/langium/naming/name-provider.d.ts.map +1 -1
- package/lib/langium/naming/name-provider.js.map +1 -1
- package/lib/langium/naming/name-separator-validation.d.ts +23 -0
- package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
- package/lib/langium/naming/name-separator-validation.js +30 -1
- package/lib/langium/naming/name-separator-validation.js.map +1 -1
- package/lib/langium/residency/cst-residency-service.d.ts +31 -9
- package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
- package/lib/langium/residency/cst-residency-service.js +13 -56
- package/lib/langium/residency/cst-residency-service.js.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.d.ts +32 -13
- package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.js +37 -20
- package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
- package/lib/langium/shared-services.d.ts +15 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/shared-services.js.map +1 -1
- package/lib/langium/transfer/transfer-encoder.d.ts +33 -2
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +14 -3
- package/lib/langium/transfer/transfer-encoder.js.map +1 -1
- package/lib/langium/validation/document-validator.d.ts +145 -6
- package/lib/langium/validation/document-validator.d.ts.map +1 -1
- package/lib/langium/validation/document-validator.js +211 -4
- package/lib/langium/validation/document-validator.js.map +1 -1
- package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
- package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
- package/lib/langium/workspace/document-uri-policy.js +3 -4
- package/lib/langium/workspace/document-uri-policy.js.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
- package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +8 -0
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.js +11 -2
- package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/initialize-workspace.d.ts +22 -2
- package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
- package/lib/langium/workspace/initialize-workspace.js +13 -5
- package/lib/langium/workspace/initialize-workspace.js.map +1 -1
- package/lib/langium/workspace/langium-documents.d.ts +79 -17
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +83 -28
- package/lib/langium/workspace/langium-documents.js.map +1 -1
- package/lib/locale/index.d.ts +10 -0
- package/lib/locale/index.d.ts.map +1 -0
- package/lib/locale/index.js +10 -0
- package/lib/locale/index.js.map +1 -0
- package/lib/locale/server-locale.d.ts +73 -0
- package/lib/locale/server-locale.d.ts.map +1 -0
- package/lib/locale/server-locale.js +61 -0
- package/lib/locale/server-locale.js.map +1 -0
- package/lib/lsp/hydranium-document-update-handler.js +1 -1
- package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
- package/lib/messages/carriers.d.ts +54 -0
- package/lib/messages/carriers.d.ts.map +1 -0
- package/lib/messages/carriers.js +62 -0
- package/lib/messages/carriers.js.map +1 -0
- package/lib/messages/index.d.ts +25 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +25 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/renderer.d.ts +136 -0
- package/lib/messages/renderer.d.ts.map +1 -0
- package/lib/messages/renderer.js +159 -0
- package/lib/messages/renderer.js.map +1 -0
- package/lib/node/node-file-system-provider.d.ts.map +1 -1
- package/lib/node/node-file-system-provider.js +1 -40
- package/lib/node/node-file-system-provider.js.map +1 -1
- package/lib/node/rename-over-open-readers.d.ts +52 -0
- package/lib/node/rename-over-open-readers.d.ts.map +1 -0
- package/lib/node/rename-over-open-readers.js +66 -0
- package/lib/node/rename-over-open-readers.js.map +1 -0
- package/lib/testing/fake-document.d.ts +14 -3
- package/lib/testing/fake-document.d.ts.map +1 -1
- package/lib/testing/fake-document.js +18 -3
- package/lib/testing/fake-document.js.map +1 -1
- package/lib/testing/make-noop-shared-services.d.ts +14 -0
- package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
- package/lib/testing/make-noop-shared-services.js +28 -2
- package/lib/testing/make-noop-shared-services.js.map +1 -1
- package/lib/testing/make-test-services.d.ts +31 -4
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +19 -3
- package/lib/testing/make-test-services.js.map +1 -1
- package/lib/testing/playwright/server-log-capture.d.ts +14 -4
- package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-capture.js +21 -4
- package/lib/testing/playwright/server-log-capture.js.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
- package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
- package/lib/testing/stub-ast-document-manager.d.ts +3 -4
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js +2 -5
- package/lib/testing/stub-ast-document-manager.js.map +1 -1
- package/lib/testing/stub-document-builder.d.ts +8 -0
- package/lib/testing/stub-document-builder.d.ts.map +1 -1
- package/lib/testing/stub-document-builder.js +22 -3
- package/lib/testing/stub-document-builder.js.map +1 -1
- package/lib/testing/stub-model-service.d.ts +1 -1
- package/lib/testing/stub-model-service.d.ts.map +1 -1
- package/lib/testing/stub-model-service.js +2 -2
- package/lib/testing/stub-model-service.js.map +1 -1
- package/package.json +17 -8
- package/src/documents/ast-document-manager.ts +55 -14
- package/src/documents/hydranium-text-documents.ts +41 -9
- package/src/documents/language-client-text-shadow.ts +38 -2
- package/src/documents/self-save-registry.ts +52 -13
- package/src/index.ts +5 -0
- package/src/langium/ast-extension/ast-node-builder.ts +66 -22
- package/src/langium/bootstrap.ts +16 -9
- package/src/langium/document-builder/build-pipeline-integration.ts +14 -1
- package/src/langium/document-builder/build-session.ts +87 -0
- package/src/langium/document-builder/document-builder.ts +339 -11
- package/src/langium/document-builder/index.ts +1 -0
- package/src/langium/integration-services.ts +67 -6
- package/src/langium/integrity/integrity-service.ts +35 -1
- package/src/langium/keys/containment.ts +87 -0
- package/src/langium/keys/index.ts +1 -0
- package/src/langium/keys/name-based-key-provider.ts +4 -0
- package/src/langium/model-service/model-service.ts +145 -22
- package/src/langium/module.ts +99 -19
- package/src/langium/naming/name-provider.ts +10 -0
- package/src/langium/naming/name-separator-validation.ts +34 -5
- package/src/langium/residency/cst-residency-service.ts +36 -12
- package/src/langium/scope/hydranium-scope-provider.ts +40 -22
- package/src/langium/shared-services.ts +19 -2
- package/src/langium/transfer/transfer-encoder.ts +45 -3
- package/src/langium/validation/document-validator.ts +255 -8
- package/src/langium/workspace/document-uri-policy.ts +3 -4
- package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
- package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
- package/src/langium/workspace/in-memory-file-system-provider.ts +13 -3
- package/src/langium/workspace/initialize-workspace.ts +34 -5
- package/src/langium/workspace/langium-documents.ts +106 -33
- package/src/locale/index.ts +10 -0
- package/src/locale/server-locale.ts +86 -0
- package/src/lsp/hydranium-document-update-handler.ts +1 -1
- package/src/messages/carriers.ts +78 -0
- package/src/messages/index.ts +27 -0
- package/src/messages/renderer.ts +204 -0
- package/src/node/node-file-system-provider.ts +1 -41
- package/src/node/rename-over-open-readers.ts +78 -0
- package/src/testing/fake-document.ts +22 -4
- package/src/testing/make-noop-shared-services.ts +50 -2
- package/src/testing/make-test-services.ts +49 -7
- package/src/testing/playwright/server-log-capture.ts +24 -5
- package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
- package/src/testing/stub-ast-document-manager.ts +5 -10
- package/src/testing/stub-document-builder.ts +32 -3
- package/src/testing/stub-model-service.ts +2 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
/**
|
|
10
|
+
* Errnos Windows raises when a replacing `rename` meets a handle already on the
|
|
11
|
+
* destination open. POSIX renames are unaffected by open handles, so these
|
|
12
|
+
* cannot fire there and the retry below costs nothing.
|
|
13
|
+
*/
|
|
14
|
+
export declare const RENAME_CONTENTION_CODES: Set<string>;
|
|
15
|
+
/**
|
|
16
|
+
* How long a replacing rename may keep retrying before it gives up.
|
|
17
|
+
*
|
|
18
|
+
* BOUNDED, not open-ended: a genuine permission fault raises the same errno as
|
|
19
|
+
* contention and is distinguishable from it only by never clearing, so an
|
|
20
|
+
* unbounded wait would convert a hard error into a hang.
|
|
21
|
+
*
|
|
22
|
+
* The figure is a judgement, not a measurement, and the honest bound on it is
|
|
23
|
+
* that the previous 2s was observed EXHAUSTED on a loaded Windows CI runner
|
|
24
|
+
* while no upper bound has been established. What would settle it is recording
|
|
25
|
+
* how long a real contended rename takes to clear. graceful-fs tolerates 60s
|
|
26
|
+
* for Windows rename contention, but that is weaker support than it looks: it
|
|
27
|
+
* retries only where the destination has GONE, which is the opposite of
|
|
28
|
+
* replacing one a reader holds open.
|
|
29
|
+
*/
|
|
30
|
+
export declare const RENAME_BUDGET_MS = 10000;
|
|
31
|
+
/** Seams for the test, which cannot make a real rename fail on demand. */
|
|
32
|
+
export interface RenameOverOpenReadersOptions {
|
|
33
|
+
readonly rename?: (from: string, to: string) => Promise<void>;
|
|
34
|
+
readonly budgetMs?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `rename` the staged content over `destination`, retrying while Windows
|
|
38
|
+
* reports the destination as held open.
|
|
39
|
+
*
|
|
40
|
+
* The staging file exists so a reader never sees a half-written file, and on
|
|
41
|
+
* Windows the very presence of that reader is what makes the replacing rename
|
|
42
|
+
* fail — so the indivisible write breaks under exactly the contention it was
|
|
43
|
+
* built for, and it breaks intermittently, which is worse than never working.
|
|
44
|
+
* A reader's handle is released in milliseconds, so waiting turns a spurious
|
|
45
|
+
* failure into a slightly later success.
|
|
46
|
+
*
|
|
47
|
+
* Exhausting the budget rethrows the last failure, leaving the caller's cleanup
|
|
48
|
+
* and error contract unchanged. An errno OUTSIDE the contention set is rethrown
|
|
49
|
+
* without waiting at all: retrying a fault that will not clear only delays it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function renameOverOpenReaders(staging: string, destination: string, options?: RenameOverOpenReadersOptions): Promise<void>;
|
|
52
|
+
//# sourceMappingURL=rename-over-open-readers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-over-open-readers.d.ts","sourceRoot":"","sources":["../../src/node/rename-over-open-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,aAAwC,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,0EAA0E;AAC1E,MAAM,WAAW,4BAA4B;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACxC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,4BAAiC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import * as fsp from 'node:fs/promises';
|
|
10
|
+
/**
|
|
11
|
+
* Errnos Windows raises when a replacing `rename` meets a handle already on the
|
|
12
|
+
* destination open. POSIX renames are unaffected by open handles, so these
|
|
13
|
+
* cannot fire there and the retry below costs nothing.
|
|
14
|
+
*/
|
|
15
|
+
export const RENAME_CONTENTION_CODES = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
16
|
+
/**
|
|
17
|
+
* How long a replacing rename may keep retrying before it gives up.
|
|
18
|
+
*
|
|
19
|
+
* BOUNDED, not open-ended: a genuine permission fault raises the same errno as
|
|
20
|
+
* contention and is distinguishable from it only by never clearing, so an
|
|
21
|
+
* unbounded wait would convert a hard error into a hang.
|
|
22
|
+
*
|
|
23
|
+
* The figure is a judgement, not a measurement, and the honest bound on it is
|
|
24
|
+
* that the previous 2s was observed EXHAUSTED on a loaded Windows CI runner
|
|
25
|
+
* while no upper bound has been established. What would settle it is recording
|
|
26
|
+
* how long a real contended rename takes to clear. graceful-fs tolerates 60s
|
|
27
|
+
* for Windows rename contention, but that is weaker support than it looks: it
|
|
28
|
+
* retries only where the destination has GONE, which is the opposite of
|
|
29
|
+
* replacing one a reader holds open.
|
|
30
|
+
*/
|
|
31
|
+
export const RENAME_BUDGET_MS = 10_000;
|
|
32
|
+
/**
|
|
33
|
+
* `rename` the staged content over `destination`, retrying while Windows
|
|
34
|
+
* reports the destination as held open.
|
|
35
|
+
*
|
|
36
|
+
* The staging file exists so a reader never sees a half-written file, and on
|
|
37
|
+
* Windows the very presence of that reader is what makes the replacing rename
|
|
38
|
+
* fail — so the indivisible write breaks under exactly the contention it was
|
|
39
|
+
* built for, and it breaks intermittently, which is worse than never working.
|
|
40
|
+
* A reader's handle is released in milliseconds, so waiting turns a spurious
|
|
41
|
+
* failure into a slightly later success.
|
|
42
|
+
*
|
|
43
|
+
* Exhausting the budget rethrows the last failure, leaving the caller's cleanup
|
|
44
|
+
* and error contract unchanged. An errno OUTSIDE the contention set is rethrown
|
|
45
|
+
* without waiting at all: retrying a fault that will not clear only delays it.
|
|
46
|
+
*/
|
|
47
|
+
export async function renameOverOpenReaders(staging, destination, options = {}) {
|
|
48
|
+
const rename = options.rename ?? fsp.rename;
|
|
49
|
+
const deadline = Date.now() + (options.budgetMs ?? RENAME_BUDGET_MS);
|
|
50
|
+
for (let attempt = 0;; attempt++) {
|
|
51
|
+
try {
|
|
52
|
+
await rename(staging, destination);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const code = err instanceof Error && 'code' in err ? String(err.code) : undefined;
|
|
57
|
+
if (code === undefined || !RENAME_CONTENTION_CODES.has(code) || Date.now() >= deadline) {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
// Backs off to keep a long contention window from spinning, capped so
|
|
61
|
+
// a late attempt still lands promptly once the handle is released.
|
|
62
|
+
await new Promise(resolve => setTimeout(resolve, Math.min(2 ** attempt, 50)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=rename-over-open-readers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-over-open-readers.js","sourceRoot":"","sources":["../../src/node/rename-over-open-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAQvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACxC,OAAe,EACf,WAAmB,EACnB,UAAwC,EAAE;IAE1C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,gBAAgB,CAAC,CAAC;IACrE,KAAK,IAAI,OAAO,GAAG,CAAC,GAAI,OAAO,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC;YACF,MAAM,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACnC,OAAO;QACV,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACrB,MAAM,IAAI,GAAG,GAAG,YAAY,KAAK,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAE,GAA6B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7G,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;gBACtF,MAAM,GAAG,CAAC;YACb,CAAC;YACD,sEAAsE;YACtE,mEAAmE;YACnE,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACjF,CAAC;IACJ,CAAC;AACJ,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { DocumentState, type AstNode, type LangiumDocument, type URI } from '@hydranium/langium';
|
|
9
|
+
import { DocumentState, type AstNode, type AstReflection, type LangiumDocument, type URI } from '@hydranium/langium';
|
|
10
10
|
/**
|
|
11
11
|
* Build a typed AST-node fixture for unit tests.
|
|
12
12
|
*
|
|
@@ -21,13 +21,24 @@ import { DocumentState, type AstNode, type LangiumDocument, type URI } from '@hy
|
|
|
21
21
|
* framework synthetic node, and marking it would change scope/index behaviour.
|
|
22
22
|
* A test that wants a genuine synthetic node calls `markSynthetic` explicitly.
|
|
23
23
|
*
|
|
24
|
+
* **Without a `reflection`, the fixture carries only what the test spells out**,
|
|
25
|
+
* which is a shape production never produces: a parsed or built node always has
|
|
26
|
+
* its grammar-declared containment arrays, so a fixture that omits one lets a
|
|
27
|
+
* test pass against an impossible node, and lets code that walks a list crash
|
|
28
|
+
* only under test. Pass the grammar's reflection whenever the type is a real
|
|
29
|
+
* one and the code under test reads a collection off it. Fixtures typed against
|
|
30
|
+
* ad-hoc names have no reflection to pass and keep the plain form.
|
|
31
|
+
*
|
|
24
32
|
* @param node the node shape — `$type` is required; every other property is a
|
|
25
33
|
* value the test cares about (`$container`, cross-reference values, internal
|
|
26
|
-
* `_id` fields, …).
|
|
34
|
+
* `_id` fields, …).
|
|
35
|
+
* @param reflection when given, pre-fills the grammar's declared defaults the
|
|
36
|
+
* same way {@link buildAstNode} does, and the result is a fresh object rather
|
|
37
|
+
* than `node` itself. Omitted, `node` is returned by reference.
|
|
27
38
|
*/
|
|
28
39
|
export declare function makeFakeAstNode<TAst extends AstNode = AstNode>(node: {
|
|
29
40
|
$type: string;
|
|
30
|
-
} & Record<string, unknown
|
|
41
|
+
} & Record<string, unknown>, reflection?: AstReflection): TAst;
|
|
31
42
|
/**
|
|
32
43
|
* Options for {@link makeFakeDocument}.
|
|
33
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-document.d.ts","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"m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AAG,GAAG,EACjB,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAM,GACpD,eAAe,CAAC,IAAI,CAAC,CA2BvB"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DocumentState, UriUtils } from '@hydranium/langium';
|
|
10
|
+
import { buildAstNode } from '../langium/ast-extension/ast-node-builder.js';
|
|
10
11
|
/**
|
|
11
12
|
* Build a typed AST-node fixture for unit tests.
|
|
12
13
|
*
|
|
@@ -21,12 +22,26 @@ import { DocumentState, UriUtils } from '@hydranium/langium';
|
|
|
21
22
|
* framework synthetic node, and marking it would change scope/index behaviour.
|
|
22
23
|
* A test that wants a genuine synthetic node calls `markSynthetic` explicitly.
|
|
23
24
|
*
|
|
25
|
+
* **Without a `reflection`, the fixture carries only what the test spells out**,
|
|
26
|
+
* which is a shape production never produces: a parsed or built node always has
|
|
27
|
+
* its grammar-declared containment arrays, so a fixture that omits one lets a
|
|
28
|
+
* test pass against an impossible node, and lets code that walks a list crash
|
|
29
|
+
* only under test. Pass the grammar's reflection whenever the type is a real
|
|
30
|
+
* one and the code under test reads a collection off it. Fixtures typed against
|
|
31
|
+
* ad-hoc names have no reflection to pass and keep the plain form.
|
|
32
|
+
*
|
|
24
33
|
* @param node the node shape — `$type` is required; every other property is a
|
|
25
34
|
* value the test cares about (`$container`, cross-reference values, internal
|
|
26
|
-
* `_id` fields, …).
|
|
35
|
+
* `_id` fields, …).
|
|
36
|
+
* @param reflection when given, pre-fills the grammar's declared defaults the
|
|
37
|
+
* same way {@link buildAstNode} does, and the result is a fresh object rather
|
|
38
|
+
* than `node` itself. Omitted, `node` is returned by reference.
|
|
27
39
|
*/
|
|
28
|
-
export function makeFakeAstNode(node) {
|
|
29
|
-
|
|
40
|
+
export function makeFakeAstNode(node, reflection) {
|
|
41
|
+
if (!reflection) {
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
return buildAstNode(reflection, node.$type, node);
|
|
30
45
|
}
|
|
31
46
|
/**
|
|
32
47
|
* Serialise `root` for the fake document's default text. AST fixtures routinely
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-document.js","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"fake-document.js","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAA0D,QAAQ,EAAY,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,eAAe,CAC5B,IAAiD,EACjD,UAA0B;IAE1B,IAAI,CAAC,UAAU,EAAE,CAAC;QACf,OAAO,IAAuB,CAAC;IAClC,CAAC;IACD,OAAO,YAAY,CAAO,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AA+BD;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,IAAa;IACrC,IAAI,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAG,IAAwC,EAAE,KAAK,EAAE,CAAC,CAAC;IACtF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC7B,GAAiB,EACjB,IAAU,EACV,UAAkD,EAAE;IAEpD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG;QACd,GAAG,EAAE,MAAM;QACX,WAAW,EAAE;YACV,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,EAAE;YACf,GAAG,OAAO,CAAC,WAAW;SACxB;QACD,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI;YACnC,GAAG,EAAE,MAAM,CAAC,QAAQ,EAAE;YACtB,OAAO;YACP,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;SACrB;QACD,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAU;QACjD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC,SAAS;KACb,CAAC;IACtC,0EAA0E;IAC1E,qEAAqE;IACrE,sEAAsE;IACtE,iCAAiC;IAChC,IAA8C,CAAC,SAAS,GAAG,QAAQ,CAAC;IACrE,OAAO,QAAQ,CAAC;AACnB,CAAC"}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Clock, type Logger, type Tracer } from '@hydranium/protocol';
|
|
10
10
|
import type { ServerSharedServicesMinimal } from '../langium/shared-services.js';
|
|
11
|
+
import { type ServerLocale } from '../locale/server-locale.js';
|
|
12
|
+
import { type MessageRenderer } from '../messages/renderer.js';
|
|
11
13
|
/**
|
|
12
14
|
* Overrides for {@link makeNoopSharedServices}. The three observability slots
|
|
13
15
|
* are typed (they are the boilerplate this helper exists to default);
|
|
@@ -27,6 +29,18 @@ export interface NoopSharedServicesOverrides {
|
|
|
27
29
|
Logger?: Logger;
|
|
28
30
|
/** Bound on the top-level `Tracer` slot. Default: a `DefaultTracer` over `Logger` + `Clock`. */
|
|
29
31
|
Tracer?: Tracer;
|
|
32
|
+
/** Factory for the `ServerLocale` slot. Default: a real one, reporting no locale. */
|
|
33
|
+
ServerLocale?: (services: ServerSharedServicesMinimal) => ServerLocale;
|
|
34
|
+
/**
|
|
35
|
+
* Factory for the `MessageRenderer` slot. Default: the real
|
|
36
|
+
* {@link DefaultMessageRenderer}, whose no-catalogue behaviour is a
|
|
37
|
+
* pass-through — so the default is the framework's own behaviour, not a stub.
|
|
38
|
+
*
|
|
39
|
+
* A factory rather than an instance, because a renderer reads the tree it is
|
|
40
|
+
* bound into. Both slots are resolved lazily, so an override is honoured
|
|
41
|
+
* however late the caller reads them.
|
|
42
|
+
*/
|
|
43
|
+
MessageRenderer?: (services: ServerSharedServicesMinimal) => MessageRenderer;
|
|
30
44
|
/** Per-slot `workspace` overrides. Slots left out resolve to `undefined`. */
|
|
31
45
|
workspace?: Record<string, unknown>;
|
|
32
46
|
/** Any other minimal slot (`ServiceRegistry`, `AstReflection`, `additionalDocuments`, …). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-noop-shared-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,MAAM,EAA2B,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"make-noop-shared-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,MAAM,EAA2B,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEvF;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IACzC,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,YAAY,CAAC;IACvE;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,eAAe,CAAC;IAC7E,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,6FAA6F;IAC7F,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,2BAA2B,GAAG,2BAA2B,EACvG,SAAS,GAAE,2BAAgC,GAC3C,CAAC,CA8BH"}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DefaultTracer, NoopLogger, SystemClock } from '@hydranium/protocol';
|
|
10
|
+
import { DefaultServerLocale } from '../locale/server-locale.js';
|
|
11
|
+
import { DefaultMessageRenderer } from '../messages/renderer.js';
|
|
10
12
|
/**
|
|
11
13
|
* Build a {@link ServerSharedServicesMinimal} tree backed by no-op defaults for
|
|
12
14
|
* the observability slots every framework component reads (`Clock` / `Logger` /
|
|
@@ -33,11 +35,12 @@ import { DefaultTracer, NoopLogger, SystemClock } from '@hydranium/protocol';
|
|
|
33
35
|
* are still undefined and should be overridden if the code under test reads them.
|
|
34
36
|
*/
|
|
35
37
|
export function makeNoopSharedServices(overrides = {}) {
|
|
36
|
-
const { Clock: clock, Logger: logger, Tracer: tracer, workspace, additionalDocuments, ...restTop } = overrides;
|
|
38
|
+
const { Clock: clock, Logger: logger, Tracer: tracer, ServerLocale: serverLocale, MessageRenderer: messageRenderer, workspace, additionalDocuments, ...restTop } = overrides;
|
|
37
39
|
const resolvedClock = clock ?? new SystemClock();
|
|
38
40
|
const resolvedLogger = logger ?? new NoopLogger();
|
|
39
41
|
const resolvedTracer = tracer ?? new DefaultTracer(resolvedLogger, resolvedClock);
|
|
40
|
-
|
|
42
|
+
// Assembled in two steps, because both defaults read the tree they belong to.
|
|
43
|
+
const services = {
|
|
41
44
|
Clock: resolvedClock,
|
|
42
45
|
Logger: resolvedLogger,
|
|
43
46
|
Tracer: resolvedTracer,
|
|
@@ -45,5 +48,28 @@ export function makeNoopSharedServices(overrides = {}) {
|
|
|
45
48
|
...restTop,
|
|
46
49
|
workspace: { ...(workspace ?? {}) }
|
|
47
50
|
};
|
|
51
|
+
// Lazy, like Langium's own per-slot construction — and load-bearing here:
|
|
52
|
+
// both services emit an `instantiated` trace, so building them eagerly puts
|
|
53
|
+
// two lines into the capture of every test that passes a capturing logger
|
|
54
|
+
// and asserts on emptiness.
|
|
55
|
+
defineLazySlot(services, 'ServerLocale', () => serverLocale?.(services) ?? new DefaultServerLocale(services));
|
|
56
|
+
defineLazySlot(services, 'MessageRenderer', () => messageRenderer?.(services) ?? new DefaultMessageRenderer(services));
|
|
57
|
+
return services;
|
|
58
|
+
}
|
|
59
|
+
/** Install `name` as a memoized getter, so nothing is constructed until it is read. */
|
|
60
|
+
function defineLazySlot(target, name, create) {
|
|
61
|
+
let resolved;
|
|
62
|
+
let built = false;
|
|
63
|
+
Object.defineProperty(target, name, {
|
|
64
|
+
configurable: true,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: () => {
|
|
67
|
+
if (!built) {
|
|
68
|
+
resolved = create();
|
|
69
|
+
built = true;
|
|
70
|
+
}
|
|
71
|
+
return resolved;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
48
74
|
}
|
|
49
75
|
//# sourceMappingURL=make-noop-shared-services.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-noop-shared-services.js","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAc,aAAa,EAAe,UAAU,EAAE,WAAW,EAAe,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"make-noop-shared-services.js","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAc,aAAa,EAAe,UAAU,EAAE,WAAW,EAAe,MAAM,qBAAqB,CAAC;AAEnH,OAAO,EAAE,mBAAmB,EAAqB,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAwB,MAAM,yBAAyB,CAAC;AAuCvF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,sBAAsB,CACnC,YAAyC,EAAE;IAE3C,MAAM,EACH,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,SAAS,EACT,mBAAmB,EACnB,GAAG,OAAO,EACZ,GAAG,SAAS,CAAC;IACd,MAAM,aAAa,GAAG,KAAK,IAAI,IAAI,WAAW,EAAE,CAAC;IACjD,MAAM,cAAc,GAAG,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,MAAM,IAAI,IAAI,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAClF,8EAA8E;IAC9E,MAAM,QAAQ,GAAG;QACd,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,cAAc;QACtB,mBAAmB,EAAE,mBAAmB,IAAI,EAAE;QAC9C,GAAG,OAAO;QACV,SAAS,EAAE,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE;KACrB,CAAC;IAClB,0EAA0E;IAC1E,4EAA4E;IAC5E,0EAA0E;IAC1E,4BAA4B;IAC5B,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9G,cAAc,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,IAAI,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvH,OAAO,QAAQ,CAAC;AACnB,CAAC;AAED,uFAAuF;AACvF,SAAS,cAAc,CAAC,MAAc,EAAE,IAAY,EAAE,MAAqB;IACxE,IAAI,QAAiB,CAAC;IACtB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE;QACjC,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,GAAG,EAAE,GAAG,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;gBACV,QAAQ,GAAG,MAAM,EAAE,CAAC;gBACpB,KAAK,GAAG,IAAI,CAAC;YAChB,CAAC;YACD,OAAO,QAAQ,CAAC;QACnB,CAAC;KACH,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Clock, type Logger, type Project, type Tracer, type TransferDiagnostic, type TransferElement } from '@hydranium/protocol';
|
|
10
|
+
import { type ServerLocale } from '../locale/server-locale.js';
|
|
11
|
+
import { type MessageRenderer } from '../messages/renderer.js';
|
|
10
12
|
import type { Harness } from '@hydranium/protocol/testing';
|
|
11
13
|
import { type AstNode, type AstNodeDescription, type WorkspaceLock } from '@hydranium/langium';
|
|
12
14
|
import type { ModelService, ModelServiceOptions } from '../langium/model-service/model-service.js';
|
|
13
15
|
import type { ServerSharedServices } from '../langium/module.js';
|
|
14
|
-
import { TransferEncoder } from '../langium/transfer/transfer-encoder.js';
|
|
16
|
+
import { type TransferEncoder } from '../langium/transfer/transfer-encoder.js';
|
|
15
17
|
import { type DocumentUriPolicy } from '../langium/workspace/document-uri-policy.js';
|
|
16
18
|
import type { FakeDocumentOptions } from './fake-document.js';
|
|
17
19
|
import { type StubDocumentBuilder } from './stub-document-builder.js';
|
|
@@ -71,9 +73,18 @@ export interface TestSharedServices<TAst extends AstNode = AstNode, TDiagnostic
|
|
|
71
73
|
WorkspaceLock: WorkspaceLock;
|
|
72
74
|
};
|
|
73
75
|
readonly model: {
|
|
74
|
-
TransferEncoder: TransferEncoder<
|
|
76
|
+
TransferEncoder: TransferEncoder<TDiagnostic>;
|
|
75
77
|
ModelService: ModelService<TAst, TDiagnostic, TTransfer>;
|
|
76
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* The REAL services, not stubs — the framework renderer's no-catalogue
|
|
81
|
+
* behaviour is a pass-through, so the stub tree agrees with a production one
|
|
82
|
+
* unless a test installs a catalogue. Bound rather than omitted because
|
|
83
|
+
* `HydraniumDocumentBuilder` renders through the renderer on every
|
|
84
|
+
* `Validated` phase, where an omitted slot is a `TypeError`.
|
|
85
|
+
*/
|
|
86
|
+
readonly ServerLocale: ServerLocale;
|
|
87
|
+
readonly MessageRenderer: MessageRenderer;
|
|
77
88
|
}
|
|
78
89
|
/** Optional configuration for {@link makeTestServices}. */
|
|
79
90
|
export interface MakeTestServicesOptions<TAst extends AstNode = AstNode, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TTransfer extends TransferElement = TransferElement, TProject extends Project = Project> {
|
|
@@ -87,6 +98,14 @@ export interface MakeTestServicesOptions<TAst extends AstNode = AstNode, TDiagno
|
|
|
87
98
|
* for tests that don't assert on the produced text.
|
|
88
99
|
*/
|
|
89
100
|
serialize?: (uri: string, root: TTransfer) => string;
|
|
101
|
+
/**
|
|
102
|
+
* Renderer bound on `MessageRenderer`. Default: the framework's own, which
|
|
103
|
+
* passes every sentence through unchanged. Supply one to install a catalogue
|
|
104
|
+
* or to drive the throwing path.
|
|
105
|
+
*/
|
|
106
|
+
messageRenderer?: (services: ServerSharedServices<TProject>) => MessageRenderer;
|
|
107
|
+
/** Locale handed to the bundle's {@link ServerLocale}. Default: none, i.e. the framework's English. */
|
|
108
|
+
locale?: string;
|
|
90
109
|
/**
|
|
91
110
|
* Languages to register on a {@link StubServiceRegistry} bound on the
|
|
92
111
|
* `ServiceRegistry` slot. This is how a test gets multi-language routing:
|
|
@@ -162,7 +181,7 @@ export interface MakeTestServicesOptions<TAst extends AstNode = AstNode, TDiagno
|
|
|
162
181
|
* Override the {@link TransferEncoder} factory. Default: framework
|
|
163
182
|
* {@link TransferEncoder} with no overrides.
|
|
164
183
|
*/
|
|
165
|
-
transferEncoder?: (services: ServerSharedServices<TProject>) => TransferEncoder<
|
|
184
|
+
transferEncoder?: (services: ServerSharedServices<TProject>) => TransferEncoder<TDiagnostic>;
|
|
166
185
|
}
|
|
167
186
|
/**
|
|
168
187
|
* Bundle returned by {@link makeTestServices}. Exposes the assembled
|
|
@@ -198,10 +217,18 @@ export interface TestServicesBundle<TAst extends AstNode = AstNode, TDiagnostic
|
|
|
198
217
|
*/
|
|
199
218
|
readonly indexManager: StubIndexManager | undefined;
|
|
200
219
|
readonly modelService: ModelService<TAst, TDiagnostic, TTransfer>;
|
|
201
|
-
readonly transferEncoder: TransferEncoder<
|
|
220
|
+
readonly transferEncoder: TransferEncoder<TDiagnostic>;
|
|
202
221
|
readonly logger: Logger;
|
|
203
222
|
/** The clock bound on the `Clock` slot — a `makeFakeClock()` if one was passed. */
|
|
204
223
|
readonly clock: Clock;
|
|
224
|
+
/**
|
|
225
|
+
* The service bound on `ServerLocale`, so a test can hand over a locale
|
|
226
|
+
* mid-run — which is also how it verifies the renderer reads the locale per
|
|
227
|
+
* render rather than caching it at construction.
|
|
228
|
+
*/
|
|
229
|
+
readonly serverLocale: ServerLocale;
|
|
230
|
+
/** The renderer bound on `MessageRenderer` — the framework's own unless one was supplied. */
|
|
231
|
+
readonly messageRenderer: MessageRenderer;
|
|
205
232
|
}
|
|
206
233
|
/**
|
|
207
234
|
* Build a {@link ServerSharedServices} tree backed by the framework's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-test-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,KAAK,EAEV,KAAK,MAAM,EAEX,KAAK,OAAO,EAEZ,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACnG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"make-test-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,KAAK,EAEV,KAAK,MAAM,EAEX,KAAK,OAAO,EAEZ,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,OAAO,EA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B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,SAAS,SAAS,eAAe,GAAG,eAAe,EACnD,QAAQ,SAAS,OAAO,GAAG,OAAO,EAElC,OAAO,GAAE,uBAAuB,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAM,GAC7E,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CAoH5D"}
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DefaultTracer, NoopLogger, SystemClock } from '@hydranium/protocol';
|
|
10
|
-
import {
|
|
10
|
+
import { DefaultServerLocale } from '../locale/server-locale.js';
|
|
11
|
+
import { DefaultMessageRenderer } from '../messages/renderer.js';
|
|
12
|
+
import { DefaultTransferEncoder } from '../langium/transfer/transfer-encoder.js';
|
|
11
13
|
import { DefaultDocumentUriPolicy } from '../langium/workspace/document-uri-policy.js';
|
|
12
14
|
import { HydraniumWorkspaceLock } from '../langium/workspace/hydranium-workspace-lock.js';
|
|
13
15
|
import { makeStubDocumentBuilder } from './stub-document-builder.js';
|
|
@@ -88,13 +90,25 @@ export function makeTestServices(options = {}) {
|
|
|
88
90
|
...(indexManager ? { IndexManager: indexManager } : {}),
|
|
89
91
|
WorkspaceLock: new HydraniumWorkspaceLock()
|
|
90
92
|
},
|
|
91
|
-
model: {}
|
|
93
|
+
model: {},
|
|
94
|
+
ServerLocale: {},
|
|
95
|
+
MessageRenderer: {}
|
|
92
96
|
};
|
|
93
97
|
const sharedServices = services;
|
|
98
|
+
// Patched in after the literal, like `model` below: both read the tree they
|
|
99
|
+
// belong to, and the renderer reads the locale service.
|
|
100
|
+
const mutableMessages = services;
|
|
101
|
+
const serverLocale = new DefaultServerLocale(sharedServices);
|
|
102
|
+
if (options.locale) {
|
|
103
|
+
serverLocale.accept(options.locale);
|
|
104
|
+
}
|
|
105
|
+
mutableMessages.ServerLocale = serverLocale;
|
|
106
|
+
const messageRenderer = options.messageRenderer?.(sharedServices) ?? new DefaultMessageRenderer(sharedServices);
|
|
107
|
+
mutableMessages.MessageRenderer = messageRenderer;
|
|
94
108
|
const serialize = options.serialize ?? ((_uri, root) => JSON.stringify(root));
|
|
95
109
|
const transferEncoder = options.transferEncoder
|
|
96
110
|
? options.transferEncoder(sharedServices)
|
|
97
|
-
: new
|
|
111
|
+
: new DefaultTransferEncoder(sharedServices);
|
|
98
112
|
const modelService = options.modelService
|
|
99
113
|
? options.modelService(sharedServices)
|
|
100
114
|
: makeStubModelService(sharedServices, serialize, options.modelServiceOptions);
|
|
@@ -117,6 +131,8 @@ export function makeTestServices(options = {}) {
|
|
|
117
131
|
transferEncoder,
|
|
118
132
|
logger,
|
|
119
133
|
clock,
|
|
134
|
+
serverLocale,
|
|
135
|
+
messageRenderer,
|
|
120
136
|
dispose: () => {
|
|
121
137
|
// No-op: the bundled stubs hold only in-memory state (maps, arrays),
|
|
122
138
|
// released with the bundle when it goes out of scope. The hook exists
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-test-services.js","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,aAAa,EAEb,UAAU,EAEV,WAAW,EAIb,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"make-test-services.js","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,aAAa,EAEb,UAAU,EAEV,WAAW,EAIb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAqB,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAwB,MAAM,yBAAyB,CAAC;AAKvF,OAAO,EAAE,sBAAsB,EAAwB,MAAM,yCAAyC,CA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cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhH,MAAM,YAAY,GAAG,QAAQ,CAAC,KAG7B,CAAC;IACF,YAAY,CAAC,eAAe,GAAG,eAAe,CAAC;IAC/C,YAAY,CAAC,YAAY,GAAG,YAAY,CAAC;IAEzC,OAAO;QACJ,QAAQ,EAAE,cAAc;QACxB,SAAS;QACT,aAAa;QACb,kBAAkB;QAClB,eAAe;QACf,UAAU;QACV,gBAAgB;QAChB,cAAc;QACd,iBAAiB;QACjB,eAAe;QACf,YAAY;QACZ,YAAY;QACZ,eAAe;QACf,MAAM;QACN,KAAK;QACL,YAAY;QACZ,eAAe;QACf,OAAO,EAAE,GAAG,EAAE;YACX,qEAAqE;YACrE,sEAAsE;YACtE,gEAAgE;YAChE,mDAAmD;QACtD,CAAC;KACH,CAAC;AACL,CAAC"}
|
|
@@ -110,11 +110,21 @@ export declare function serverLogSpecName(file: string): string;
|
|
|
110
110
|
* Rename each `<token>.log` (backend) and `<token>.browser.log` (forwarded
|
|
111
111
|
* browser console) to the spec name recorded in its `<token>.spec` sidecar
|
|
112
112
|
* (written by {@link markServerLog}), then delete the sidecar. Colliding names —
|
|
113
|
-
* a spec that opened more than one workspace — get a `-2`, `-3`, … suffix.
|
|
114
|
-
*
|
|
115
|
-
*
|
|
113
|
+
* a spec that opened more than one workspace — get a `-2`, `-3`, … suffix. Run
|
|
114
|
+
* once, after all server processes have exited (e.g. a reporter's `onEnd`).
|
|
115
|
+
* Best-effort.
|
|
116
|
+
*
|
|
117
|
+
* Returns the workspace tokens left UNATTRIBUTED — a log the capture wrote that
|
|
118
|
+
* no test claimed, because that spec never reached
|
|
119
|
+
* {@link markServerLog} (no `serverLog` fixture, no `beforeEach` call).
|
|
120
|
+
*
|
|
121
|
+
* **Returned rather than ignored, because the unattributed state is the
|
|
122
|
+
* misleading one.** Such a log still exists, still has content, and is named by
|
|
123
|
+
* an opaque token with no test boundaries in it — so a capture run that covered
|
|
124
|
+
* nothing looks exactly like one that covered everything, and the logs are
|
|
125
|
+
* there to be read. A caller that can warn should warn.
|
|
116
126
|
*/
|
|
117
|
-
export declare function renameServerLogs(dir: string):
|
|
127
|
+
export declare function renameServerLogs(dir: string): string[];
|
|
118
128
|
/**
|
|
119
129
|
* Resolve the per-workspace server-log file the {@link captureServerLog} tee
|
|
120
130
|
* writes for `workspacePath` — the `<token>.log` under the capture dir — or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-log-capture.d.ts","sourceRoot":"","sources":["../../../src/testing/playwright/server-log-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAQlF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AACrE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,gCAAgC,CAAC;AAC3E;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,iCAAiC,CAAC;AAE7E,+GAA+G;AAC/G,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAAyB,CAAC;AAElF,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAqB/D,MAAM,WAAW,uBAAuB;IACrC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qEAAqE;AACrE,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;AAE9E,MAAM,WAAW,sBAAsB;IACpC,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,iHAAiH;IACjH,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACpC;AAED,MAAM,WAAW,8BAA8B;IAC5C,mFAAmF;IACnF,GAAG,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,sBAAsB,CAY9F;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,oGAAoG;IACpG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzF;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED
|
|
1
|
+
{"version":3,"file":"server-log-capture.d.ts","sourceRoot":"","sources":["../../../src/testing/playwright/server-log-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAQlF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AACrE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,gCAAgC,CAAC;AAC3E;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,iCAAiC,CAAC;AAE7E,+GAA+G;AAC/G,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAAyB,CAAC;AAElF,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAqB/D,MAAM,WAAW,uBAAuB;IACrC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qEAAqE;AACrE,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;AAE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SAAS,CAMtH;AAED,MAAM,WAAW,sBAAsB;IACpC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,IAAI,CAoB5H;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAWzG;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAChC,IAAI,IAAI,MAAM,CAAC;IACf,IAAI,IAAI,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC7B,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI,CAAC;CAC9E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAClC,IAAI,EAAE,eAAe,EACrB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GAC1D,IAAI,CAoBN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CAClC,QAAQ,EAAE,iBAAiB,EAC3B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,sBAA2B,GACpC,OAAO,CAAC,IAAI,CAAC,CAkCf"}
|
|
@@ -102,9 +102,19 @@ export function serverLogSpecName(file) {
|
|
|
102
102
|
* Rename each `<token>.log` (backend) and `<token>.browser.log` (forwarded
|
|
103
103
|
* browser console) to the spec name recorded in its `<token>.spec` sidecar
|
|
104
104
|
* (written by {@link markServerLog}), then delete the sidecar. Colliding names —
|
|
105
|
-
* a spec that opened more than one workspace — get a `-2`, `-3`, … suffix.
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* a spec that opened more than one workspace — get a `-2`, `-3`, … suffix. Run
|
|
106
|
+
* once, after all server processes have exited (e.g. a reporter's `onEnd`).
|
|
107
|
+
* Best-effort.
|
|
108
|
+
*
|
|
109
|
+
* Returns the workspace tokens left UNATTRIBUTED — a log the capture wrote that
|
|
110
|
+
* no test claimed, because that spec never reached
|
|
111
|
+
* {@link markServerLog} (no `serverLog` fixture, no `beforeEach` call).
|
|
112
|
+
*
|
|
113
|
+
* **Returned rather than ignored, because the unattributed state is the
|
|
114
|
+
* misleading one.** Such a log still exists, still has content, and is named by
|
|
115
|
+
* an opaque token with no test boundaries in it — so a capture run that covered
|
|
116
|
+
* nothing looks exactly like one that covered everything, and the logs are
|
|
117
|
+
* there to be read. A caller that can warn should warn.
|
|
108
118
|
*/
|
|
109
119
|
export function renameServerLogs(dir) {
|
|
110
120
|
let entries;
|
|
@@ -112,7 +122,9 @@ export function renameServerLogs(dir) {
|
|
|
112
122
|
entries = readdirSync(dir);
|
|
113
123
|
}
|
|
114
124
|
catch {
|
|
115
|
-
|
|
125
|
+
// An unreadable capture dir has nothing to report — including nothing
|
|
126
|
+
// unattributed, since no log was observed at all.
|
|
127
|
+
return [];
|
|
116
128
|
}
|
|
117
129
|
// Per suffix (`.log`, `.browser.log`) a `taken` set guards collisions, so the
|
|
118
130
|
// backend and browser logs for one spec share the same friendly base name.
|
|
@@ -134,6 +146,9 @@ export function renameServerLogs(dir) {
|
|
|
134
146
|
// ignore
|
|
135
147
|
}
|
|
136
148
|
};
|
|
149
|
+
// Every token the capture produced a backend log for, so the ones no sidecar
|
|
150
|
+
// claims can be reported rather than silently left behind.
|
|
151
|
+
const unattributed = new Set(entries.filter(entry => entry.endsWith('.log') && !entry.endsWith('.browser.log')).map(entry => entry.slice(0, -'.log'.length)));
|
|
137
152
|
for (const entry of entries) {
|
|
138
153
|
if (!entry.endsWith('.spec')) {
|
|
139
154
|
continue;
|
|
@@ -156,9 +171,11 @@ export function renameServerLogs(dir) {
|
|
|
156
171
|
if (!name) {
|
|
157
172
|
continue;
|
|
158
173
|
}
|
|
174
|
+
unattributed.delete(token);
|
|
159
175
|
rename(token, name, '.log');
|
|
160
176
|
rename(token, name, '.browser.log');
|
|
161
177
|
}
|
|
178
|
+
return [...unattributed];
|
|
162
179
|
}
|
|
163
180
|
/**
|
|
164
181
|
* Resolve the per-workspace server-log file the {@link captureServerLog} tee
|