@overkill-dev/engine 0.0.62 → 0.0.64
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/engine/async-leak-diagnostics.js +18 -5
- package/engine/async-leak-diagnostics.js.map +1 -1
- package/engine/benchmark-environment.d.ts +8 -0
- package/engine/benchmark-environment.d.ts.map +1 -0
- package/engine/benchmark-garbage-collection.d.ts +0 -4
- package/engine/benchmark-garbage-collection.d.ts.map +1 -1
- package/engine/benchmark-garbage-collection.js.map +1 -1
- package/engine/benchmark-node.d.ts +9 -2
- package/engine/benchmark-node.d.ts.map +1 -1
- package/engine/benchmark-node.js +11 -0
- package/engine/benchmark-node.js.map +1 -0
- package/engine/benchmark-result.d.ts +80 -1
- package/engine/benchmark-result.d.ts.map +1 -1
- package/engine/benchmark-result.js.map +1 -1
- package/engine/case-attempt-execution.js +25 -17
- package/engine/case-attempt-execution.js.map +1 -1
- package/engine/case-body-execution.js +1 -0
- package/engine/case-body-execution.js.map +1 -1
- package/engine/execution-async-leak-policy.js +38 -23
- package/engine/execution-async-leak-policy.js.map +1 -1
- package/engine/execution-error-ownership.d.ts +6 -0
- package/engine/execution-error-ownership.d.ts.map +1 -0
- package/engine/execution-error-ownership.js +83 -0
- package/engine/execution-error-ownership.js.map +1 -0
- package/engine/execution-global-error-observer.d.ts +1 -4
- package/engine/execution-global-error-observer.d.ts.map +1 -1
- package/engine/execution-global-error-observer.js +41 -81
- package/engine/execution-global-error-observer.js.map +1 -1
- package/engine/execution-observation.js +198 -0
- package/engine/execution-observation.js.map +1 -0
- package/engine/execution-preparation.js +34 -0
- package/engine/execution-preparation.js.map +1 -0
- package/engine/execution-supervision-state.js +8 -0
- package/engine/execution-supervision-state.js.map +1 -1
- package/engine/execution-supervision.d.ts +1 -1
- package/engine/execution-supervision.d.ts.map +1 -1
- package/engine/execution-supervision.js +3 -3
- package/engine/execution-supervision.js.map +1 -1
- package/engine/execution-test-plan-cases.js +11 -9
- package/engine/execution-test-plan-cases.js.map +1 -1
- package/engine/execution.d.ts +1 -1
- package/engine/execution.d.ts.map +1 -1
- package/engine/execution.js +3 -27
- package/engine/execution.js.map +1 -1
- package/engine/infrastructure-resource-observation.js +55 -0
- package/engine/infrastructure-resource-observation.js.map +1 -0
- package/engine/reporter-dispatcher.d.ts.map +1 -1
- package/engine/reporter-dispatcher.js +6 -3
- package/engine/reporter-dispatcher.js.map +1 -1
- package/engine/reporter-output-scope.js +7 -2
- package/engine/reporter-output-scope.js.map +1 -1
- package/engine/resource-owner-observation.d.ts.map +1 -1
- package/engine/resource-owner-observation.js +97 -7
- package/engine/resource-owner-observation.js.map +1 -1
- package/package.json +5 -1
- package/packages/engine/engine.entry-point.d.ts +5 -2
- package/packages/engine/engine.entry-point.d.ts.map +1 -1
- package/packages/engine/engine.entry-point.js +1 -0
- package/packages/engine/engine.entry-point.js.map +1 -1
- package/readme.md +11 -0
- package/software-bill-of-materials.cyclonedx.json +4 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
function createActiveScopes() {
|
|
3
|
+
const scopes = [];
|
|
4
|
+
return {
|
|
5
|
+
add(scope) {
|
|
6
|
+
scopes.push(scope);
|
|
7
|
+
},
|
|
8
|
+
all() {
|
|
9
|
+
return Array.from(scopes);
|
|
10
|
+
},
|
|
11
|
+
includes(scope) {
|
|
12
|
+
return scopes.includes(scope);
|
|
13
|
+
},
|
|
14
|
+
remove(scope) {
|
|
15
|
+
const index = scopes.lastIndexOf(scope);
|
|
16
|
+
if (index !== -1) {
|
|
17
|
+
scopes.splice(index, 1);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
size() {
|
|
21
|
+
return scopes.length;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const ownershipKey = Symbol.for('@overkill-dev/engine/executionErrorOwnership');
|
|
26
|
+
function hasMethods(value, names) {
|
|
27
|
+
return typeof value === 'object' && value !== null && names.every(function callable(name) {
|
|
28
|
+
return typeof Reflect.get(value, name) === 'function';
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function isErrorOwnership(value) {
|
|
32
|
+
if (typeof value !== 'object' || value === null) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return Reflect.get(value, 'runScopeStorage') instanceof AsyncLocalStorage &&
|
|
36
|
+
Reflect.get(value, 'activeCaseStorage') instanceof AsyncLocalStorage &&
|
|
37
|
+
hasMethods(Reflect.get(value, 'activeScopes'), ['add', 'all', 'includes', 'remove', 'size']) &&
|
|
38
|
+
hasMethods(Reflect.get(value, 'processHookListeners'), ['install', 'removeWhenIdle']);
|
|
39
|
+
}
|
|
40
|
+
function createProcessHookListeners(activeScopes) {
|
|
41
|
+
let stop = null;
|
|
42
|
+
return {
|
|
43
|
+
install(receive) {
|
|
44
|
+
if (stop !== null) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
function receiveUnhandledRejection(reason) {
|
|
48
|
+
receive('unhandledRejection', reason);
|
|
49
|
+
}
|
|
50
|
+
function receiveUncaughtException(error) {
|
|
51
|
+
receive('uncaughtException', error);
|
|
52
|
+
}
|
|
53
|
+
process.prependListener('unhandledRejection', receiveUnhandledRejection);
|
|
54
|
+
process.prependListener('uncaughtException', receiveUncaughtException);
|
|
55
|
+
stop = function removeProcessListeners() {
|
|
56
|
+
process.removeListener('unhandledRejection', receiveUnhandledRejection);
|
|
57
|
+
process.removeListener('uncaughtException', receiveUncaughtException);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
removeWhenIdle() {
|
|
61
|
+
if (activeScopes.size() === 0) {
|
|
62
|
+
stop?.();
|
|
63
|
+
stop = null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function executionErrorOwnership() {
|
|
69
|
+
const existing = Reflect.get(globalThis, ownershipKey);
|
|
70
|
+
if (isErrorOwnership(existing)) {
|
|
71
|
+
return existing;
|
|
72
|
+
}
|
|
73
|
+
const activeScopes = createActiveScopes();
|
|
74
|
+
const created = {
|
|
75
|
+
runScopeStorage: new AsyncLocalStorage(),
|
|
76
|
+
activeCaseStorage: new AsyncLocalStorage(),
|
|
77
|
+
activeScopes,
|
|
78
|
+
processHookListeners: createProcessHookListeners(activeScopes)
|
|
79
|
+
};
|
|
80
|
+
Reflect.set(globalThis, ownershipKey, created);
|
|
81
|
+
return created;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=execution-error-ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-error-ownership.js","sourceRoot":"","sources":["../../../../source/engine/execution-error-ownership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA+CrD,SAAS,kBAAkB;IACvB,MAAM,MAAM,GAAoB,EAAE,CAAC;IAEnC,OAAO;QACH,GAAG,CAAC,KAAK;YACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,GAAG;YACC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;QACD,QAAQ,CAAC,KAAK;YACV,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,MAAM,CAAC,KAAK;YACR,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAExC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QACD,IAAI;YACA,OAAO,MAAM,CAAC,MAAM,CAAC;QACzB,CAAC;KACJ,CAAC;AACN,CAAC;AASD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAEhF,SAAS,UAAU,CAA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,yBAAyB,CAAC,CAAC;YACzE,OAAO,CAAC,eAAe,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;YACvE,IAAI,GAAG,SAAS,sBAAsB;gBAClC,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,CAAC;gBACxE,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;YAC1E,CAAC,CAAC;QACN,CAAC;QACD,cAAc;YACV,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;gBAC5B,IAAI,EAAE,EAAE,CAAC;gBACT,IAAI,GAAG,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AAED,MAAM,UAAU,uBAAuB;IACnC,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAChE,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG;QACZ,eAAe,EAAE,IAAI,iBAAiB,EAAiB;QACvD,iBAAiB,EAAE,IAAI,iBAAiB,EAAqB;QAC7D,YAAY;QACZ,oBAAoB,EAAE,0BAA0B,CAAC,YAAY,CAAC;KACjE,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { type ExecutionPhase, type FatalErrorHandler, type FatalErrorHandlerDisposer } from './execution-error-ownership.ts';
|
|
1
2
|
import type { AttemptId } from './identity.ts';
|
|
2
3
|
import { type RunnerError } from './run-result.ts';
|
|
3
4
|
import type { TestPlanCase } from './test-plan.ts';
|
|
4
|
-
type ExecutionPhase = 'body' | 'collection' | 'run';
|
|
5
|
-
type FatalErrorHandler = (error: RunnerError) => unknown;
|
|
6
|
-
type FatalErrorHandlerDisposer = () => unknown;
|
|
7
5
|
export type ExecutionGlobalErrorObserver = {
|
|
8
6
|
readonly fatalSignal: () => Promise<void>;
|
|
9
7
|
readonly hasFatalError: () => boolean;
|
|
@@ -14,5 +12,4 @@ export type ExecutionGlobalErrorObserver = {
|
|
|
14
12
|
readonly stop: () => unknown;
|
|
15
13
|
readonly takeErrors: () => readonly RunnerError[];
|
|
16
14
|
};
|
|
17
|
-
export {};
|
|
18
15
|
//# sourceMappingURL=execution-global-error-observer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-global-error-observer.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-global-error-observer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-global-error-observer.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-global-error-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,cACc,EACnB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAGjC,MAAM,gCAAgC,CAAC;AAKxC,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAmCnD,MAAM,MAAM,4BAA4B,GAAG;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,yBAAyB,CAAC;IACjF,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3E,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACnH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/F,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,SAAS,WAAW,EAAE,CAAC;CACrD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { executionErrorOwnership } from "./execution-error-ownership.js";
|
|
2
|
+
import { createExecutionObservation, observingInfrastructure } from "./execution-observation.js";
|
|
2
3
|
import { permissionDeniedRunnerErrorFromThrown } from "./run-result.js";
|
|
3
|
-
const runScopeStorage =
|
|
4
|
-
const activeCaseStorage = new AsyncLocalStorage();
|
|
4
|
+
const { runScopeStorage, activeCaseStorage, activeScopes, processHookListeners } = executionErrorOwnership();
|
|
5
5
|
function createStoredValue(initialValue) {
|
|
6
6
|
let currentValue = initialValue;
|
|
7
7
|
return {
|
|
@@ -14,6 +14,7 @@ function createStoredValue(initialValue) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function createRunErrorScope(boundary) {
|
|
17
|
+
const observation = createExecutionObservation();
|
|
17
18
|
const activeCaseKeys = new Set();
|
|
18
19
|
const errors = [];
|
|
19
20
|
const fatal = createStoredValue(false);
|
|
@@ -31,6 +32,7 @@ function createRunErrorScope(boundary) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
return {
|
|
35
|
+
observation,
|
|
34
36
|
activeCaseStarted(key) {
|
|
35
37
|
activeCaseKeys.add(key);
|
|
36
38
|
},
|
|
@@ -81,6 +83,8 @@ function createRunErrorScope(boundary) {
|
|
|
81
83
|
stop() {
|
|
82
84
|
stopped.write(true);
|
|
83
85
|
fatalHandlers.clear();
|
|
86
|
+
activeCaseKeys.clear();
|
|
87
|
+
observation.stop();
|
|
84
88
|
},
|
|
85
89
|
takeErrors() {
|
|
86
90
|
const currentErrors = Array.from(errors);
|
|
@@ -89,29 +93,6 @@ function createRunErrorScope(boundary) {
|
|
|
89
93
|
}
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
|
-
function createActiveScopes() {
|
|
93
|
-
const scopes = [];
|
|
94
|
-
return {
|
|
95
|
-
add(scope) {
|
|
96
|
-
scopes.push(scope);
|
|
97
|
-
},
|
|
98
|
-
all() {
|
|
99
|
-
return Array.from(scopes);
|
|
100
|
-
},
|
|
101
|
-
includes(scope) {
|
|
102
|
-
return scopes.includes(scope);
|
|
103
|
-
},
|
|
104
|
-
remove(scope) {
|
|
105
|
-
const index = scopes.lastIndexOf(scope);
|
|
106
|
-
if (index !== -1) {
|
|
107
|
-
scopes.splice(index, 1);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
size() {
|
|
111
|
-
return scopes.length;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
96
|
|
|
116
97
|
function serializedReason(reason) {
|
|
117
98
|
if (reason instanceof Error) {
|
|
@@ -187,41 +168,37 @@ function attributionDriftError(scope, hook, reason, activeCase) {
|
|
|
187
168
|
function scopeIncludesCase(scope, activeCase) {
|
|
188
169
|
return activeCase !== null && activeCase.scope === scope;
|
|
189
170
|
}
|
|
190
|
-
function activePermissionCase(input) {
|
|
191
|
-
if (!scopeIncludesCase(input.scope, input.activeCase)) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
return input.scope.hasActiveCase(input.activeCase) ? input.activeCase : null;
|
|
195
|
-
}
|
|
196
171
|
function permissionErrorForScope(input) {
|
|
197
|
-
const activeCase =
|
|
198
|
-
|
|
199
|
-
attributedTo:
|
|
200
|
-
attributedToWork: activeCase
|
|
172
|
+
const activeCase = scopeIncludesCase(input.scope, input.activeCase) ? input.activeCase : null;
|
|
173
|
+
const attribution = activeCase === null
|
|
174
|
+
? { attributedTo: null, attributedToWork: null, phase: input.scope.phase() }
|
|
175
|
+
: { attributedTo: activeCase.id, attributedToWork: activeCase.workId, phase: 'body' };
|
|
176
|
+
const error = permissionDeniedRunnerErrorFromThrown(input.reason, {
|
|
177
|
+
...attribution,
|
|
201
178
|
boundary: input.scope.boundary,
|
|
202
179
|
diagnosticChannel: null,
|
|
203
|
-
hook: input.hook
|
|
204
|
-
phase: activeCase === null ? input.scope.phase() : 'body'
|
|
180
|
+
hook: input.hook
|
|
205
181
|
});
|
|
182
|
+
return error === null ? null : input.scope.observation.attribute(error);
|
|
183
|
+
}
|
|
184
|
+
function ownedHookError(input) {
|
|
185
|
+
if (scopeIncludesCase(input.scope, input.activeCase)) {
|
|
186
|
+
return attributedError(input.scope, input.hook, input.reason, input.activeCase);
|
|
187
|
+
}
|
|
188
|
+
const error = runLevelHookError(input.scope, input.hook, input.reason);
|
|
189
|
+
return input.scope.observation.attribute(error).subtype === 'attribution-drift'
|
|
190
|
+
? attributionDriftError(input.scope, input.hook, input.reason, input.activeCase)
|
|
191
|
+
: error;
|
|
206
192
|
}
|
|
207
193
|
function errorForScope(input) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return permissionError;
|
|
194
|
+
if (scopeIncludesCase(input.scope, input.activeCase) && !input.scope.hasActiveCase(input.activeCase)) {
|
|
195
|
+
return attributionDriftError(input.scope, input.hook, input.reason, input.activeCase);
|
|
211
196
|
}
|
|
212
197
|
if (input.ambiguousScope) {
|
|
213
|
-
return attributionDriftError(input.scope, input.hook, input.reason,
|
|
198
|
+
return attributionDriftError(input.scope, input.hook, input.reason, null);
|
|
214
199
|
}
|
|
215
|
-
|
|
216
|
-
return runLevelHookError(input.scope, input.hook, input.reason);
|
|
217
|
-
}
|
|
218
|
-
if (input.scope.hasActiveCase(input.activeCase)) {
|
|
219
|
-
return attributedError(input.scope, input.hook, input.reason, input.activeCase);
|
|
220
|
-
}
|
|
221
|
-
return attributionDriftError(input.scope, input.hook, input.reason, input.activeCase);
|
|
200
|
+
return permissionErrorForScope(input) ?? ownedHookError(input);
|
|
222
201
|
}
|
|
223
|
-
const activeScopes = createActiveScopes();
|
|
224
|
-
const listenersInstalled = createStoredValue(false);
|
|
225
202
|
function currentTargetScopes() {
|
|
226
203
|
const currentScope = runScopeStorage.getStore();
|
|
227
204
|
if (currentScope !== undefined && activeScopes.includes(currentScope)) {
|
|
@@ -230,40 +207,19 @@ function currentTargetScopes() {
|
|
|
230
207
|
return activeScopes.all();
|
|
231
208
|
}
|
|
232
209
|
function receiveHookFailure(hook, reason) {
|
|
233
|
-
const activeCase = activeCaseStorage.getStore() ?? null;
|
|
210
|
+
const activeCase = observingInfrastructure() ? null : activeCaseStorage.getStore() ?? null;
|
|
234
211
|
const ambiguousScope = runScopeStorage.getStore() === undefined && activeScopes.size() > 1;
|
|
235
212
|
for (const scope of currentTargetScopes()) {
|
|
236
213
|
scope.recordError(errorForScope({ activeCase, ambiguousScope, hook, reason, scope }));
|
|
237
214
|
}
|
|
238
215
|
}
|
|
239
|
-
function receiveUnhandledRejection(reason) {
|
|
240
|
-
receiveHookFailure('unhandledRejection', reason);
|
|
241
|
-
}
|
|
242
|
-
function receiveUncaughtException(error) {
|
|
243
|
-
receiveHookFailure('uncaughtException', error);
|
|
244
|
-
}
|
|
245
|
-
function createProcessHookListeners() {
|
|
246
|
-
return {
|
|
247
|
-
install() {
|
|
248
|
-
if (listenersInstalled.read()) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
process.prependListener('unhandledRejection', receiveUnhandledRejection);
|
|
252
|
-
process.prependListener('uncaughtException', receiveUncaughtException);
|
|
253
|
-
listenersInstalled.write(true);
|
|
254
|
-
},
|
|
255
|
-
removeWhenIdle() {
|
|
256
|
-
if (listenersInstalled.read() && activeScopes.size() === 0) {
|
|
257
|
-
process.removeListener('unhandledRejection', receiveUnhandledRejection);
|
|
258
|
-
process.removeListener('uncaughtException', receiveUncaughtException);
|
|
259
|
-
listenersInstalled.write(false);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
const processHookListeners = createProcessHookListeners();
|
|
265
216
|
export function createExecutionGlobalErrorObserver(boundary) {
|
|
266
217
|
const scope = createRunErrorScope(boundary);
|
|
218
|
+
scope.observation.register(function stopOwnedGlobalObserver() {
|
|
219
|
+
scope.stop();
|
|
220
|
+
activeScopes.remove(scope);
|
|
221
|
+
processHookListeners.removeWhenIdle();
|
|
222
|
+
});
|
|
267
223
|
return {
|
|
268
224
|
async fatalSignal() {
|
|
269
225
|
await scope.fatalSignal();
|
|
@@ -275,10 +231,12 @@ export function createExecutionGlobalErrorObserver(boundary) {
|
|
|
275
231
|
return scope.onFatalError(handler);
|
|
276
232
|
},
|
|
277
233
|
async runBoundary(run) {
|
|
278
|
-
processHookListeners.install();
|
|
234
|
+
processHookListeners.install(receiveHookFailure);
|
|
279
235
|
activeScopes.add(scope);
|
|
280
236
|
try {
|
|
281
|
-
return await
|
|
237
|
+
return await scope.observation.run(async function observeRunOwnership() {
|
|
238
|
+
return await runScopeStorage.run(scope, run);
|
|
239
|
+
});
|
|
282
240
|
}
|
|
283
241
|
finally {
|
|
284
242
|
activeScopes.remove(scope);
|
|
@@ -294,7 +252,9 @@ export function createExecutionGlobalErrorObserver(boundary) {
|
|
|
294
252
|
};
|
|
295
253
|
scope.activeCaseStarted(activeCase);
|
|
296
254
|
try {
|
|
297
|
-
return await
|
|
255
|
+
return await scope.observation.runAttempt(testCase, attempt, async function observeAttemptOwnership() {
|
|
256
|
+
return await activeCaseStorage.run(activeCase, run);
|
|
257
|
+
});
|
|
298
258
|
}
|
|
299
259
|
finally {
|
|
300
260
|
scope.activeCaseStopped(activeCase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-global-error-observer.js","sourceRoot":"","sources":["../../../../source/engine/execution-global-error-observer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"execution-global-error-observer.js","sourceRoot":"","sources":["../../../../source/engine/execution-global-error-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EAQ1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,0BAA0B,EAC1B,uBAAuB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qCAAqC,EAAoB,MAAM,iBAAiB,CAAC;AA+C1F,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,uBAAuB,EAAE,CAAC;AAE7G,SAAS,iBAAiB,CAAQ,YAAmB;IACjD,IAAI,YAAY,GAAG,YAAY,CAAC;IAEhC,OAAO;QACH,IAAI;YACA,OAAO,YAAY,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,KAAK;YACP,YAAY,GAAG,KAAK,CAAC;QACzB,CAAC;KACJ,CAAC;AACN,CAAC;AAED,SAAS,mBAAmB,CAAC,QAA2B;IACpD,MAAM,WAAW,GAAG,0BAA0B,EAAE,CAAC;IACjD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;IACpD,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAqB,CAAC;IACnD,MAAM,WAAW,GAAG,iBAAiB,CAAyC,IAAI,CAAC,CAAC;IACpF,MAAM,KAAK,GAAG,iBAAiB,CAAiB,KAAK,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEzC,SAAS,WAAW,CAAC,KAAkB;QACnC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC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GAAG;gBACf,OAAO;gBACP,EAAE,EAAE,QAAQ,CAAC,EAAE;gBACf,KAAK;gBACL,MAAM,EAAE,QAAQ,CAAC,MAAM;aAC1B,CAAC;YAEF,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YAEpC,IAAI,CAAC;gBACD,OAAO,MAAM,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,UAAU,uBAAuB;oBAC/F,OAAO,MAAM,iBAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBACxD,CAAC,CAAC,CAAC;YACP,CAAC;oBAAS,CAAC;gBACP,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACxC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG;YACrB,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI;YACA,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3B,oBAAoB,CAAC,cAAc,EAAE,CAAC;QAC1C,CAAC;QACD,UAAU;YACN,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
const observationKey = Symbol.for('@overkill-dev/engine/executionObservation');
|
|
3
|
+
function isObservationStorage(value) {
|
|
4
|
+
return value instanceof AsyncLocalStorage;
|
|
5
|
+
}
|
|
6
|
+
function sharedObservationStorage() {
|
|
7
|
+
const existing = Reflect.get(globalThis, observationKey);
|
|
8
|
+
if (isObservationStorage(existing)) {
|
|
9
|
+
return existing;
|
|
10
|
+
}
|
|
11
|
+
const created = new AsyncLocalStorage();
|
|
12
|
+
Reflect.set(globalThis, observationKey, created);
|
|
13
|
+
return created;
|
|
14
|
+
}
|
|
15
|
+
const ownership = sharedObservationStorage();
|
|
16
|
+
function disposeObservations(disposers) {
|
|
17
|
+
const errors = [];
|
|
18
|
+
for (const dispose of disposers) {
|
|
19
|
+
try {
|
|
20
|
+
dispose();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
errors.push(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (errors.length > 0) {
|
|
27
|
+
throw new AggregateError(errors, 'Execution observation shutdown failed.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function createLifetime() {
|
|
31
|
+
const disposers = new Set();
|
|
32
|
+
let open = true;
|
|
33
|
+
return {
|
|
34
|
+
open() {
|
|
35
|
+
return open;
|
|
36
|
+
},
|
|
37
|
+
close() {
|
|
38
|
+
if (!open) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
open = false;
|
|
42
|
+
const pending = Array.from(disposers);
|
|
43
|
+
disposers.clear();
|
|
44
|
+
disposeObservations(pending);
|
|
45
|
+
},
|
|
46
|
+
register(dispose) {
|
|
47
|
+
if (open) {
|
|
48
|
+
disposers.add(dispose);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
dispose();
|
|
52
|
+
}
|
|
53
|
+
return function unregister() {
|
|
54
|
+
disposers.delete(dispose);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function createRunOwner() {
|
|
60
|
+
return { ...createLifetime(), identity: Symbol('execution run') };
|
|
61
|
+
}
|
|
62
|
+
export function observingInfrastructure() {
|
|
63
|
+
return ownership.getStore()?.kind === 'infrastructure';
|
|
64
|
+
}
|
|
65
|
+
export function registerExecutionDisposal(dispose) {
|
|
66
|
+
const run = ownership.getStore()?.run;
|
|
67
|
+
if (run === null || run === undefined) {
|
|
68
|
+
return function unregisterUnownedDisposal() {
|
|
69
|
+
return undefined;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return run.register(dispose);
|
|
73
|
+
}
|
|
74
|
+
export function withRunnerInfrastructure(operation) {
|
|
75
|
+
return ownership.run({ kind: 'infrastructure', run: ownership.getStore()?.run ?? null }, operation);
|
|
76
|
+
}
|
|
77
|
+
function closeFailedObservation(run, error) {
|
|
78
|
+
try {
|
|
79
|
+
run.close();
|
|
80
|
+
}
|
|
81
|
+
catch (cleanupError) {
|
|
82
|
+
throw new AggregateError([error, cleanupError], 'Execution and observation shutdown failed.', {
|
|
83
|
+
cause: cleanupError
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
export async function withExecutionObservation(operation) {
|
|
89
|
+
const current = ownership.getStore();
|
|
90
|
+
if (current?.kind === 'run' && current.run.open()) {
|
|
91
|
+
return await operation();
|
|
92
|
+
}
|
|
93
|
+
const run = createRunOwner();
|
|
94
|
+
try {
|
|
95
|
+
const result = await ownership.run({ kind: 'run', run }, operation);
|
|
96
|
+
run.close();
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return closeFailedObservation(run, error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function lateObservation(error, owner) {
|
|
104
|
+
return {
|
|
105
|
+
...error,
|
|
106
|
+
attributedTo: null,
|
|
107
|
+
attributedToWork: null,
|
|
108
|
+
attributedToAttempt: null,
|
|
109
|
+
subtype: 'attribution-drift',
|
|
110
|
+
cause: {
|
|
111
|
+
kind: 'late-observation',
|
|
112
|
+
origin: { case: owner.attempt.caseId, work: owner.attempt.workId, attempt: owner.attempt.attempt },
|
|
113
|
+
observation: error
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function attributeObservation(error, run) {
|
|
118
|
+
const owner = ownership.getStore();
|
|
119
|
+
if (owner?.kind === 'attempt') {
|
|
120
|
+
if (!owner.run.open() || !owner.attempt.open()) {
|
|
121
|
+
return lateObservation(error, owner);
|
|
122
|
+
}
|
|
123
|
+
if (owner.run === run) {
|
|
124
|
+
return {
|
|
125
|
+
...error,
|
|
126
|
+
attributedTo: owner.attempt.caseId,
|
|
127
|
+
attributedToWork: owner.attempt.workId,
|
|
128
|
+
attributedToAttempt: owner.attempt.attempt
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { ...error, attributedTo: null, attributedToWork: null, attributedToAttempt: null };
|
|
133
|
+
}
|
|
134
|
+
function matchesAttempt(owner, testCase, attempt) {
|
|
135
|
+
return owner.caseId === testCase.id && owner.workId === testCase.workId && owner.attempt.index === attempt.index;
|
|
136
|
+
}
|
|
137
|
+
function ownsObservation(run, owner) {
|
|
138
|
+
if (owner === undefined) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (owner.kind === 'infrastructure') {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return owner.run === run || !owner.run.open();
|
|
145
|
+
}
|
|
146
|
+
async function runOwnedAttempt(run, testCase, attempt, operation) {
|
|
147
|
+
const current = ownership.getStore();
|
|
148
|
+
if (current?.kind === 'attempt' && current.run === run && current.attempt.open() &&
|
|
149
|
+
matchesAttempt(current.attempt, testCase, attempt)) {
|
|
150
|
+
return await operation();
|
|
151
|
+
}
|
|
152
|
+
const owner = { ...createLifetime(), caseId: testCase.id, workId: testCase.workId, attempt };
|
|
153
|
+
try {
|
|
154
|
+
return await ownership.run({ kind: 'attempt', run, attempt: owner }, operation);
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
owner.close();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export function createExecutionObservation() {
|
|
161
|
+
const current = ownership.getStore();
|
|
162
|
+
const inherited = current?.kind === 'run' && current.run.open();
|
|
163
|
+
const run = inherited ? current.run : createRunOwner();
|
|
164
|
+
const lifetime = createLifetime();
|
|
165
|
+
const unregister = run.register(lifetime.close);
|
|
166
|
+
return {
|
|
167
|
+
open: lifetime.open,
|
|
168
|
+
accepts() {
|
|
169
|
+
return lifetime.open() && ownsObservation(run, ownership.getStore());
|
|
170
|
+
},
|
|
171
|
+
hasActiveAttempt() {
|
|
172
|
+
const owner = ownership.getStore();
|
|
173
|
+
return owner?.kind === 'attempt' && owner.run === run && owner.run.open() && owner.attempt.open();
|
|
174
|
+
},
|
|
175
|
+
attribute(error) {
|
|
176
|
+
return attributeObservation(error, run);
|
|
177
|
+
},
|
|
178
|
+
register: lifetime.register,
|
|
179
|
+
async run(operation) {
|
|
180
|
+
return await ownership.run({ kind: 'run', run }, operation);
|
|
181
|
+
},
|
|
182
|
+
async runAttempt(testCase, attempt, operation) {
|
|
183
|
+
return await runOwnedAttempt(run, testCase, attempt, operation);
|
|
184
|
+
},
|
|
185
|
+
stop() {
|
|
186
|
+
unregister();
|
|
187
|
+
try {
|
|
188
|
+
lifetime.close();
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
if (!inherited) {
|
|
192
|
+
run.close();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=execution-observation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-observation.js","sourceRoot":"","sources":["../../../../source/engine/execution-observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA6CrD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;AAE/E,SAAS,oBAAoB,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,iBAAiB,CAAC;AAC9C,CAAC;AAED,SAAS,wBAAwB;IAC7B,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAClE,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,QAAQ,C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AAC;YACnC,OAAO,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACtG,CAAC;QACD,SAAS,CAAC,KAAK;YACX,OAAO,oBAAoB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,KAAK,CAAC,GAAG,CAAC,SAAS;YACf,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS;YACzC,OAAO,MAAM,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACpE,CAAC;QACD,IAAI;YACA,UAAU,EAAE,CAAC;YACb,IAAI,CAAC;gBACD,QAAQ,CAAC,KAAK,EAAE,CAAC;YACrB,CAAC;oBAAS,CAAC;gBACP,IAAI,CAAC,SAAS,EAAE,CAAC;oBACb,GAAG,CAAC,KAAK,EAAE,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createExecutionAsyncLeakMonitor } from "./execution-async-leak-policy.js";
|
|
2
|
+
import { createExecutionGlobalErrorObserver } from "./execution-global-error-observer.js";
|
|
3
|
+
import { withExecutionObservation } from "./execution-observation.js";
|
|
4
|
+
import { executeOptionsWithDefaults } from "./execution-options.js";
|
|
5
|
+
function prepareExecution(dependencies, options, testPlan) {
|
|
6
|
+
const executeOptions = executeOptionsWithDefaults(options, testPlan, dependencies.benchmarkEnvironment);
|
|
7
|
+
const asyncLeakMonitor = createExecutionAsyncLeakMonitor(dependencies.asyncLeakDiagnostics);
|
|
8
|
+
const globalErrorObserver = createExecutionGlobalErrorObserver('in-process');
|
|
9
|
+
return {
|
|
10
|
+
asyncLeakMonitor,
|
|
11
|
+
dependencies: {
|
|
12
|
+
asyncLeakMonitor,
|
|
13
|
+
globalErrorObserver,
|
|
14
|
+
...dependencies,
|
|
15
|
+
benchmarkEnvironment: executeOptions.benchmarkEnvironment,
|
|
16
|
+
runtimePolicy: executeOptions.runtimePolicy
|
|
17
|
+
},
|
|
18
|
+
globalErrorObserver,
|
|
19
|
+
options: executeOptions
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export async function withPreparedExecution(dependencies, options, testPlan, execute) {
|
|
23
|
+
return await withExecutionObservation(async function observeEngineExecution() {
|
|
24
|
+
const prepared = prepareExecution(dependencies, options, testPlan);
|
|
25
|
+
try {
|
|
26
|
+
return await execute(prepared);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
prepared.asyncLeakMonitor.stop();
|
|
30
|
+
prepared.globalErrorObserver.stop();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=execution-preparation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-preparation.js","sourceRoot":"","sources":["../../../../source/engine/execution-preparation.ts"],"names":[],"mappings":"AACA,OAAO,EACH,+BAA+B,EAGlC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,kCAAkC,EAErC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACH,0BAA0B,EAG7B,MAAM,wBAAwB,CAAC;AA2BhC,SAAS,gBAAgB,CACrB,YAAiC,EACjC,OAA6C,EAC7C,QAAkB;IAElB,MAAM,cAAc,GAAG,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACxG,MAAM,gBAAgB,GAAG,+BAA+B,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC5F,MAAM,mBAAmB,GAAG,kCAAkC,CAAC,YAAY,CAAC,CAAC;IAE7E,OAAO;QACH,gBAAgB;QAChB,YAAY,EAAE;YACV,gBAAgB;YAChB,mBAAmB;YACnB,GAAG,YAAY;YACf,oBAAoB,EAAE,cAAc,CAAC,oBAAoB;YACzD,aAAa,EAAE,cAAc,CAAC,aAAa;SAC9C;QACD,mBAAmB;QACnB,OAAO,EAAE,cAAc;KAC1B,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACvC,YAAiC,EACjC,OAA6C,EAC7C,QAAkB,EAClB,OAAwD;IAExD,OAAO,MAAM,wBAAwB,CAAC,KAAK,UAAU,sBAAsB;QACvE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC;YACD,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;gBAAS,CAAC;YACP,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;YACjC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
1
2
|
import { createStoredValue } from "../stored-value.js";
|
|
3
|
+
import { withRunnerInfrastructure } from "./execution-observation.js";
|
|
2
4
|
import { currentCaseExecutionLifecycle } from "./case-execution-lifecycle.js";
|
|
5
|
+
export function scheduleSupervisionTimeout(wallClock, callback, milliseconds) {
|
|
6
|
+
const ownedCallback = AsyncLocalStorage.bind(callback);
|
|
7
|
+
return withRunnerInfrastructure(function scheduleWatchdog() {
|
|
8
|
+
return wallClock.setTimeout(ownedCallback, milliseconds);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
3
11
|
export function createBenchmarkState() {
|
|
4
12
|
return createStoredValue(null);
|
|
5
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-supervision-state.js","sourceRoot":"","sources":["../../../../source/engine/execution-supervision-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-supervision-state.js","sourceRoot":"","sources":["../../../../source/engine/execution-supervision-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAA+B,MAAM,+BAA+B,CAAC;AAM3G,MAAM,UAAU,0BAA0B,CACtC,SAAgB,EAChB,QAAoB,EACpB,YAAoB;IAEpB,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,wBAAwB,CAAC,SAAS,gBAAgB;QACrD,OAAO,SAAS,CAAC,UAAU,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACP,CAAC;AAGD,MAAM,UAAU,oBAAoB;IAChC,OAAO,iBAAiB,CAAkC,IAAI,CAAC,CAAC;AACpE,CAAC;AAaD,MAAM,UAAU,oBAAoB;IAChC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAA2B,CAAC;IAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC;AAwBD,MAAM,UAAU,0BAA0B;IACtC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,YAAY,GAAmD,EAAE,CAAC;IACxE,IAAI,eAAe,GAAG,IAAI,CAAC;IAE3B,OAAO;QACH,SAAS,EAAE,6BAA6B,EAAE;QAC1C,eAAe;YACX,OAAO,eAAe,CAAC;QAC3B,CAAC;QACD,qBAAqB;YACjB,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAAC,KAAK;gBAC/D,OAAO,KAAK,CAAC,OAAO,KAAK,oBAAoB,CAAC;YAClD,CAAC,CAAC,CAAC;YACH,OAAO,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;QACvD,CAAC;QACD,WAAW;QACX,aAAa,CAAC,GAAG,EAAE,UAAU;YACzB,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,iBAAiB,CAAC,KAAK;YACnB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,gBAAgB,CAAC,GAAG;YAChB,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,YAAY;QACZ,kBAAkB;YACd,eAAe,GAAG,KAAK,CAAC;QAC5B,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Clock } from '@enormora/clock';
|
|
2
|
-
import type { BenchmarkExecutionEnvironment } from './benchmark-
|
|
2
|
+
import type { BenchmarkExecutionEnvironment } from './benchmark-environment.ts';
|
|
3
3
|
import { type TestRuntimePolicy } from './case-execution.ts';
|
|
4
4
|
import type { ExecutionGlobalErrorObserver } from './execution-global-error-observer.ts';
|
|
5
5
|
export type ExecuteTimeoutPolicy = {
|