@flemist/test-variants 5.0.12 → 5.0.14
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/README.md +5 -0
- package/build/browser/index.cjs +1 -1
- package/build/browser/index.mjs +3 -2
- package/build/common/index.cjs +1 -1
- package/build/common/index.mjs +3 -2
- package/build/common/test-variants/-test/helpers/CallController.d.ts +1 -1
- package/build/common/test-variants/NowObservable.d.ts +13 -0
- package/build/common/test-variants/run/errorHandlers.d.ts +1 -2
- package/build/common/test-variants/run/runIterationLoop.d.ts +1 -2
- package/build/common/test-variants/run/types.d.ts +3 -2
- package/build/common/test-variants/types.d.ts +5 -2
- package/build/createTestVariants-DGrAba6p.mjs +1102 -0
- package/build/createTestVariants-DHZ0gEE2.js +4 -0
- package/build/node/index.cjs +1 -1
- package/build/node/index.mjs +7 -8
- package/package.json +3 -4
- package/build/createTestVariants-DlP_jc3m.js +0 -4
- package/build/createTestVariants-DxolnPmm.mjs +0 -1042
|
@@ -0,0 +1,1102 @@
|
|
|
1
|
+
import { timeControllerDefault as F } from "@flemist/time-controller";
|
|
2
|
+
import { formatAny as ge, Subject as Je, combineAbortSignals as X, isPromiseLike as O, abortSignalToPromise as Xe, deepCloneJsonLike as Ze, waitMicrotasks as Ke } from "@flemist/simple-utils";
|
|
3
|
+
import { AbortError as Qe, AbortControllerFast as Z } from "@flemist/abort-controller-fast";
|
|
4
|
+
import { poolWait as ae, Pool as Ye } from "@flemist/time-limits";
|
|
5
|
+
class et extends Error {
|
|
6
|
+
}
|
|
7
|
+
function re() {
|
|
8
|
+
if (typeof process < "u" && process.memoryUsage)
|
|
9
|
+
try {
|
|
10
|
+
return process.memoryUsage.rss();
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
if (typeof performance < "u") {
|
|
14
|
+
const e = performance.memory;
|
|
15
|
+
if (e)
|
|
16
|
+
try {
|
|
17
|
+
return e.usedJSHeapSize;
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const tt = 1e3, B = [];
|
|
24
|
+
function rt(e) {
|
|
25
|
+
return ge(e, { pretty: !0, maxDepth: 5, maxItems: 50 });
|
|
26
|
+
}
|
|
27
|
+
function nt(...e) {
|
|
28
|
+
const r = e.map((t) => typeof t == "string" ? t : rt(t)).join(" ");
|
|
29
|
+
B.push(r), B.length > tt && B.shift(), console.log(r);
|
|
30
|
+
}
|
|
31
|
+
function ot() {
|
|
32
|
+
return B.join(`
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
globalThis.__getStressTestLogLast = ot;
|
|
36
|
+
const pe = (e, r) => {
|
|
37
|
+
nt(r);
|
|
38
|
+
}, he = (e) => ge(e, {
|
|
39
|
+
pretty: !0,
|
|
40
|
+
maxDepth: 20,
|
|
41
|
+
maxItems: 100,
|
|
42
|
+
maxStringLength: 5e3,
|
|
43
|
+
dontExpandClassInstances: !0,
|
|
44
|
+
dontExpandFunctions: !0
|
|
45
|
+
}), T = {
|
|
46
|
+
start: !0,
|
|
47
|
+
progress: 5e3,
|
|
48
|
+
completed: !0,
|
|
49
|
+
error: !0,
|
|
50
|
+
modeChange: !0,
|
|
51
|
+
debug: !1,
|
|
52
|
+
func: pe,
|
|
53
|
+
format: he
|
|
54
|
+
}, it = {
|
|
55
|
+
start: !1,
|
|
56
|
+
progress: !1,
|
|
57
|
+
completed: !1,
|
|
58
|
+
error: !1,
|
|
59
|
+
modeChange: !1,
|
|
60
|
+
debug: !1,
|
|
61
|
+
func: pe,
|
|
62
|
+
format: he
|
|
63
|
+
};
|
|
64
|
+
function be(e) {
|
|
65
|
+
return e === !1 ? it : e === !0 || !e ? T : {
|
|
66
|
+
start: e.start ?? T.start,
|
|
67
|
+
progress: e.progress ?? T.progress,
|
|
68
|
+
completed: e.completed ?? T.completed,
|
|
69
|
+
error: e.error ?? T.error,
|
|
70
|
+
modeChange: e.modeChange ?? T.modeChange,
|
|
71
|
+
debug: e.debug ?? T.debug,
|
|
72
|
+
func: e.func ?? T.func,
|
|
73
|
+
format: e.format ?? T.format
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function st(e, r) {
|
|
77
|
+
const t = e.now();
|
|
78
|
+
return {
|
|
79
|
+
startTime: t,
|
|
80
|
+
startMemory: r,
|
|
81
|
+
debugMode: !1,
|
|
82
|
+
tests: 0,
|
|
83
|
+
iterations: 0,
|
|
84
|
+
iterationsAsync: 0,
|
|
85
|
+
prevLogTime: t,
|
|
86
|
+
prevLogMemory: r,
|
|
87
|
+
pendingModeChange: null,
|
|
88
|
+
prevGcTime: t,
|
|
89
|
+
prevGcIterations: 0,
|
|
90
|
+
prevGcIterationsAsync: 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
class V extends Qe {
|
|
94
|
+
}
|
|
95
|
+
class lt {
|
|
96
|
+
_timeController;
|
|
97
|
+
_subject;
|
|
98
|
+
_interval;
|
|
99
|
+
_timer;
|
|
100
|
+
constructor(r, t) {
|
|
101
|
+
this._interval = r, this._timeController = t ?? F, this._subject = new Je({
|
|
102
|
+
startStopNotifier: () => (this.update(), () => {
|
|
103
|
+
this._timeController.clearTimeout(this._timer);
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
update() {
|
|
108
|
+
this._subject.emit(this._timeController.now()), this._timer = this._timeController.setTimeout(
|
|
109
|
+
() => this.update(),
|
|
110
|
+
this._interval
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
get interval() {
|
|
114
|
+
return this._interval;
|
|
115
|
+
}
|
|
116
|
+
set interval(r) {
|
|
117
|
+
this._interval = r, this._timer && (this._timeController.clearTimeout(this._timer), this.update());
|
|
118
|
+
}
|
|
119
|
+
subscribe(r) {
|
|
120
|
+
return this._subject.subscribe(r);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const at = 50, ut = 5;
|
|
124
|
+
function ct(e, r) {
|
|
125
|
+
return e == null ? null : typeof e == "number" ? e : e(r) ?? null;
|
|
126
|
+
}
|
|
127
|
+
function ue(e, r) {
|
|
128
|
+
return typeof e == "number" ? { iterationsAsync: 0, iterationsSync: e } : e != null && typeof e == "object" ? e : r ? { iterationsAsync: 1, iterationsSync: 0 } : { iterationsAsync: 0, iterationsSync: 1 };
|
|
129
|
+
}
|
|
130
|
+
function ft(e, r) {
|
|
131
|
+
const t = r.log, i = r.pauseDebuggerOnError ?? !0, o = r.onStart, s = r.onEnd;
|
|
132
|
+
let n = null, a = 0;
|
|
133
|
+
function c(m, h, y) {
|
|
134
|
+
n == null && (n = { error: m, args: h, tests: y }, t.error && t.func(
|
|
135
|
+
"error",
|
|
136
|
+
`[test-variants] error variant: ${t.format(h)}
|
|
137
|
+
tests: ${y}
|
|
138
|
+
${t.format(m)}`
|
|
139
|
+
));
|
|
140
|
+
const d = Date.now();
|
|
141
|
+
if (i)
|
|
142
|
+
debugger;
|
|
143
|
+
if (Date.now() - d > at && a < ut) {
|
|
144
|
+
t.func(
|
|
145
|
+
"debug",
|
|
146
|
+
`[test-variants] debug iteration: ${a}`
|
|
147
|
+
), a++;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const v = n;
|
|
151
|
+
throw n = null, r.onError && r.onError(v), v.error;
|
|
152
|
+
}
|
|
153
|
+
const g = new lt(100);
|
|
154
|
+
return function(h, y, d) {
|
|
155
|
+
o && o({ args: h, tests: y });
|
|
156
|
+
const b = ct(r.timeout, h);
|
|
157
|
+
let v = null, M = d, f = null;
|
|
158
|
+
b && (v = Date.now(), f = new Z(), M = {
|
|
159
|
+
abortSignal: X(
|
|
160
|
+
d.abortSignal,
|
|
161
|
+
f.signal
|
|
162
|
+
),
|
|
163
|
+
timeController: d.timeController
|
|
164
|
+
});
|
|
165
|
+
function E() {
|
|
166
|
+
f.abort(
|
|
167
|
+
new et(
|
|
168
|
+
`[test-variants] test timeout ${b}ms exceeded`
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
let S = e(h, M);
|
|
174
|
+
if (O(S)) {
|
|
175
|
+
let x = null;
|
|
176
|
+
return f && (x = g.subscribe(() => {
|
|
177
|
+
Date.now() - v > b && (E(), x());
|
|
178
|
+
}), S = Promise.race([
|
|
179
|
+
S,
|
|
180
|
+
Xe(f.signal)
|
|
181
|
+
])), S.then(
|
|
182
|
+
(A) => {
|
|
183
|
+
x?.();
|
|
184
|
+
const G = ue(A, !0);
|
|
185
|
+
return s && s({ args: h, tests: y, result: G }), G;
|
|
186
|
+
},
|
|
187
|
+
(A) => (x?.(), s && !(A instanceof V) && s({ args: h, tests: y, error: A }), c(A, h, y))
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
v != null && Date.now() - v > b && (E(), f.signal.throwIfAborted());
|
|
191
|
+
const C = ue(S, !1);
|
|
192
|
+
return s && s({ args: h, tests: y, result: C }), C;
|
|
193
|
+
} catch (S) {
|
|
194
|
+
return S instanceof V ? void 0 : (s && s({ args: h, tests: y, error: S }), c(S, h, y));
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function k(e, r, t) {
|
|
199
|
+
for (let i = 0, o = e.length; i < o; i++)
|
|
200
|
+
if (t ? t(e[i], r) : e[i] === r)
|
|
201
|
+
return i;
|
|
202
|
+
return -1;
|
|
203
|
+
}
|
|
204
|
+
function ce(e, r, t, i) {
|
|
205
|
+
const o = Object.keys(e.templates), s = {}, n = [], a = [], c = [], g = o.length;
|
|
206
|
+
for (let m = 0; m < g; m++) {
|
|
207
|
+
const h = o[m];
|
|
208
|
+
s[h] = void 0, n.push(-1), a.push(void 0), c.push(null);
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
args: s,
|
|
212
|
+
argsNames: o,
|
|
213
|
+
indexes: n,
|
|
214
|
+
argValues: a,
|
|
215
|
+
argLimits: c,
|
|
216
|
+
attempts: 0,
|
|
217
|
+
templates: e,
|
|
218
|
+
limitArgOnError: t,
|
|
219
|
+
equals: r,
|
|
220
|
+
includeErrorVariant: i ?? !1
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function P(e, r) {
|
|
224
|
+
const t = e.templates.templates[r], i = e.templates.extra[r];
|
|
225
|
+
let o;
|
|
226
|
+
if (typeof t == "function" ? o = t(e.args) : o = t, i == null)
|
|
227
|
+
return o;
|
|
228
|
+
let s = null;
|
|
229
|
+
const n = i.length;
|
|
230
|
+
for (let a = 0; a < n; a++) {
|
|
231
|
+
const c = i[a];
|
|
232
|
+
k(o, c, e.equals) < 0 && (s == null ? s = [...o, c] : s.push(c));
|
|
233
|
+
}
|
|
234
|
+
return s ?? o;
|
|
235
|
+
}
|
|
236
|
+
function I(e, r, t) {
|
|
237
|
+
const i = e.argValues[r].length;
|
|
238
|
+
if (i === 0)
|
|
239
|
+
return -1;
|
|
240
|
+
const o = e.argLimits[r];
|
|
241
|
+
if (o == null)
|
|
242
|
+
return i - 1;
|
|
243
|
+
let s = e.limitArgOnError;
|
|
244
|
+
if (typeof s == "function") {
|
|
245
|
+
const n = e.argsNames[r];
|
|
246
|
+
s = s({
|
|
247
|
+
name: n,
|
|
248
|
+
values: e.argValues[r],
|
|
249
|
+
maxValueIndex: o
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return !t || s ? Math.min(o, i - 1) : i - 1;
|
|
253
|
+
}
|
|
254
|
+
function L(e) {
|
|
255
|
+
const r = e.indexes.length;
|
|
256
|
+
for (let t = 0; t < r; t++) {
|
|
257
|
+
const i = e.argLimits[t];
|
|
258
|
+
if (i == null)
|
|
259
|
+
return !1;
|
|
260
|
+
const o = e.indexes[t];
|
|
261
|
+
if (o > i)
|
|
262
|
+
return !0;
|
|
263
|
+
if (o < i)
|
|
264
|
+
return !1;
|
|
265
|
+
}
|
|
266
|
+
return !e.includeErrorVariant;
|
|
267
|
+
}
|
|
268
|
+
function N(e) {
|
|
269
|
+
const r = e.indexes.length;
|
|
270
|
+
for (let t = 0; t < r; t++)
|
|
271
|
+
e.indexes[t] = -1, e.argValues[t] = void 0, e.args[e.argsNames[t]] = void 0;
|
|
272
|
+
}
|
|
273
|
+
function ye(e) {
|
|
274
|
+
let r = !1, t = !0;
|
|
275
|
+
const i = e.indexes.length;
|
|
276
|
+
let o = i, s = !1, n = 0;
|
|
277
|
+
for (; n < i; n++) {
|
|
278
|
+
const a = e.argValues[n] == null;
|
|
279
|
+
(a || s) && (a && (r = !0), e.argValues[n] = P(
|
|
280
|
+
e,
|
|
281
|
+
e.argsNames[n]
|
|
282
|
+
));
|
|
283
|
+
const c = I(
|
|
284
|
+
e,
|
|
285
|
+
n,
|
|
286
|
+
n > o
|
|
287
|
+
);
|
|
288
|
+
if (c < 0) {
|
|
289
|
+
t = !1, e.indexes[n] = -1;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
a && (e.indexes[n] = 0, e.args[e.argsNames[n]] = e.argValues[n][0]), (s || e.indexes[n] > c) && (e.indexes[n] = c, e.args[e.argsNames[n]] = e.argValues[n][c], s = !0), o === i && e.indexes[n] < c && (o = n);
|
|
293
|
+
}
|
|
294
|
+
if (L(e))
|
|
295
|
+
return N(e), !1;
|
|
296
|
+
if (r && t)
|
|
297
|
+
return !0;
|
|
298
|
+
for (n--; n >= 0; n--) {
|
|
299
|
+
if (e.argValues[n] == null)
|
|
300
|
+
continue;
|
|
301
|
+
let a = n > o;
|
|
302
|
+
const c = I(e, n, a), g = e.indexes[n] + 1;
|
|
303
|
+
if (g <= c) {
|
|
304
|
+
e.indexes[n] = g, e.args[e.argsNames[n]] = e.argValues[n][g], g < c && (a = !0);
|
|
305
|
+
for (let m = n + 1; m < i; m++)
|
|
306
|
+
e.args[e.argsNames[m]] = void 0;
|
|
307
|
+
for (n++; n < i; n++) {
|
|
308
|
+
e.argValues[n] = P(
|
|
309
|
+
e,
|
|
310
|
+
e.argsNames[n]
|
|
311
|
+
);
|
|
312
|
+
const m = I(e, n, a);
|
|
313
|
+
if (m < 0)
|
|
314
|
+
break;
|
|
315
|
+
e.indexes[n] = 0, e.args[e.argsNames[n]] = e.argValues[n][0], m > 0 && (a = !0);
|
|
316
|
+
}
|
|
317
|
+
if (n >= i)
|
|
318
|
+
return L(e) ? (N(e), !1) : !0;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return N(e), !1;
|
|
322
|
+
}
|
|
323
|
+
function K(e) {
|
|
324
|
+
L(e) && N(e);
|
|
325
|
+
let r = !1, t = !0;
|
|
326
|
+
const i = e.indexes.length;
|
|
327
|
+
let o = i, s = !1, n = 0;
|
|
328
|
+
for (; n < i; n++) {
|
|
329
|
+
const a = e.argValues[n] == null;
|
|
330
|
+
(a || s) && (a && (r = !0), e.argValues[n] = P(
|
|
331
|
+
e,
|
|
332
|
+
e.argsNames[n]
|
|
333
|
+
));
|
|
334
|
+
const c = I(
|
|
335
|
+
e,
|
|
336
|
+
n,
|
|
337
|
+
n > o
|
|
338
|
+
);
|
|
339
|
+
if (c < 0) {
|
|
340
|
+
t = !1, e.indexes[n] = -1;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
a && (e.indexes[n] = c, e.args[e.argsNames[n]] = e.argValues[n][c]), (s || e.indexes[n] > c) && (e.indexes[n] = c, e.args[e.argsNames[n]] = e.argValues[n][c], s = !0), o === i && e.indexes[n] < c && (o = n);
|
|
344
|
+
}
|
|
345
|
+
if ((r || s) && t && !L(e))
|
|
346
|
+
return !0;
|
|
347
|
+
for (n--; n >= 0; n--) {
|
|
348
|
+
if (e.argValues[n] == null)
|
|
349
|
+
continue;
|
|
350
|
+
let a = n > o;
|
|
351
|
+
const c = I(e, n, a);
|
|
352
|
+
let g = e.indexes[n] - 1;
|
|
353
|
+
if (g > c && (g = c), g >= 0) {
|
|
354
|
+
e.indexes[n] = g, e.args[e.argsNames[n]] = e.argValues[n][g], g < c && (a = !0);
|
|
355
|
+
for (let m = n + 1; m < i; m++)
|
|
356
|
+
e.args[e.argsNames[m]] = void 0;
|
|
357
|
+
for (n++; n < i; n++) {
|
|
358
|
+
e.argValues[n] = P(
|
|
359
|
+
e,
|
|
360
|
+
e.argsNames[n]
|
|
361
|
+
);
|
|
362
|
+
const m = I(e, n, a);
|
|
363
|
+
if (m < 0)
|
|
364
|
+
break;
|
|
365
|
+
e.indexes[n] = m, e.args[e.argsNames[n]] = e.argValues[n][m], m > 0 && (a = !0);
|
|
366
|
+
}
|
|
367
|
+
if (n >= i)
|
|
368
|
+
return !0;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return N(e), !1;
|
|
372
|
+
}
|
|
373
|
+
function mt(e, r) {
|
|
374
|
+
N(e);
|
|
375
|
+
const t = e.argsNames, i = t.length;
|
|
376
|
+
let o = !1;
|
|
377
|
+
for (let s = 0; s < i; s++) {
|
|
378
|
+
const n = t[s], a = r[n];
|
|
379
|
+
if (a === void 0)
|
|
380
|
+
return null;
|
|
381
|
+
e.argValues[s] = P(e, n);
|
|
382
|
+
const c = I(e, s, o);
|
|
383
|
+
if (c < 0)
|
|
384
|
+
return null;
|
|
385
|
+
const g = k(
|
|
386
|
+
e.argValues[s],
|
|
387
|
+
a,
|
|
388
|
+
e.equals
|
|
389
|
+
);
|
|
390
|
+
if (g < 0 || g > c)
|
|
391
|
+
return null;
|
|
392
|
+
e.indexes[s] = g, e.args[e.argsNames[s]] = e.argValues[s][g], e.indexes[s] < c && (o = !0);
|
|
393
|
+
}
|
|
394
|
+
return L(e) ? null : e.indexes.slice();
|
|
395
|
+
}
|
|
396
|
+
function dt(e) {
|
|
397
|
+
const r = e.indexes.length;
|
|
398
|
+
if (r === 0)
|
|
399
|
+
return !1;
|
|
400
|
+
let t = !1;
|
|
401
|
+
for (let i = 0; i < r; i++) {
|
|
402
|
+
e.argValues[i] = P(e, e.argsNames[i]);
|
|
403
|
+
const o = I(e, i, t);
|
|
404
|
+
if (o < 0)
|
|
405
|
+
return Math.random() < 0.5 ? ye(e) : K(e);
|
|
406
|
+
e.indexes[i] = Math.floor(Math.random() * (o + 1)), e.args[e.argsNames[i]] = e.argValues[i][e.indexes[i]], e.indexes[i] < o && (t = !0);
|
|
407
|
+
}
|
|
408
|
+
return L(e) ? K(e) : !0;
|
|
409
|
+
}
|
|
410
|
+
function U(e) {
|
|
411
|
+
return e.mode === "forward" || e.mode === "backward";
|
|
412
|
+
}
|
|
413
|
+
function gt(e, r, t, i) {
|
|
414
|
+
const o = r[t], s = e.templates[t];
|
|
415
|
+
if (typeof s != "function") {
|
|
416
|
+
if (k(s, o, i) >= 0)
|
|
417
|
+
return;
|
|
418
|
+
s.push(o);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const n = e.extra[t];
|
|
422
|
+
if (n == null) {
|
|
423
|
+
e.extra[t] = [o];
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
k(n, o, i) >= 0 || n.push(o);
|
|
427
|
+
}
|
|
428
|
+
function pt(e, r, t) {
|
|
429
|
+
for (const i in r)
|
|
430
|
+
if (Object.prototype.hasOwnProperty.call(r, i)) {
|
|
431
|
+
if (i === "seed")
|
|
432
|
+
continue;
|
|
433
|
+
gt(e, r, i, t);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function fe(e, r) {
|
|
437
|
+
for (const t in r)
|
|
438
|
+
if (Object.prototype.hasOwnProperty.call(r, t)) {
|
|
439
|
+
if (t === "seed")
|
|
440
|
+
continue;
|
|
441
|
+
if (!e[t])
|
|
442
|
+
return !1;
|
|
443
|
+
}
|
|
444
|
+
return !0;
|
|
445
|
+
}
|
|
446
|
+
const ht = [{ mode: "forward" }];
|
|
447
|
+
function bt(e) {
|
|
448
|
+
const {
|
|
449
|
+
argsTemplates: r,
|
|
450
|
+
equals: t,
|
|
451
|
+
limitArgOnError: i,
|
|
452
|
+
includeErrorVariant: o,
|
|
453
|
+
getSeed: s,
|
|
454
|
+
iterationModes: n,
|
|
455
|
+
onModeChange: a,
|
|
456
|
+
limitCompletionCount: c,
|
|
457
|
+
limitTests: g,
|
|
458
|
+
limitTime: m
|
|
459
|
+
} = e, h = e.timeController ?? F, y = {
|
|
460
|
+
templates: Ze(r),
|
|
461
|
+
extra: {}
|
|
462
|
+
}, d = n == null || n.length === 0 ? ht : n, b = [];
|
|
463
|
+
let v = null, M = null, f = 0, E = 0, S = !1, C = 0;
|
|
464
|
+
function x() {
|
|
465
|
+
S || (S = !0, C = h.now(), A(), f = 0, ie(), xe());
|
|
466
|
+
}
|
|
467
|
+
function A() {
|
|
468
|
+
for (let l = 0, u = d.length; l < u; l++)
|
|
469
|
+
b.push(G());
|
|
470
|
+
}
|
|
471
|
+
function G() {
|
|
472
|
+
return {
|
|
473
|
+
navigationState: ce(
|
|
474
|
+
y,
|
|
475
|
+
t ?? null,
|
|
476
|
+
i ?? null,
|
|
477
|
+
o ?? null
|
|
478
|
+
),
|
|
479
|
+
cycleCount: 0,
|
|
480
|
+
completedCount: 0,
|
|
481
|
+
testsInLastTurn: 0,
|
|
482
|
+
tryNextVariantAttempts: 0,
|
|
483
|
+
startTime: null
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function xe() {
|
|
487
|
+
v = ce(
|
|
488
|
+
y,
|
|
489
|
+
t ?? null,
|
|
490
|
+
// Initial values; overwritten in calcIndexes before each use
|
|
491
|
+
!1,
|
|
492
|
+
!1
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
function ie() {
|
|
496
|
+
a?.({
|
|
497
|
+
mode: d[f],
|
|
498
|
+
modeIndex: f,
|
|
499
|
+
tests: E
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
function Te(l) {
|
|
503
|
+
x(), fe(y.templates, l) && pt(y, l, t);
|
|
504
|
+
}
|
|
505
|
+
function se(l, u) {
|
|
506
|
+
return x(), fe(y.templates, l) ? (v.limitArgOnError = u?.limitArg ?? i ?? null, v.includeErrorVariant = u?.includeLimit ?? o ?? !1, mt(v, l)) : null;
|
|
507
|
+
}
|
|
508
|
+
function Me(l) {
|
|
509
|
+
const u = l?.args;
|
|
510
|
+
if (u == null)
|
|
511
|
+
return;
|
|
512
|
+
x();
|
|
513
|
+
const p = se(u);
|
|
514
|
+
if (p != null) {
|
|
515
|
+
M = {
|
|
516
|
+
args: u,
|
|
517
|
+
error: l?.error,
|
|
518
|
+
tests: l?.tests ?? E
|
|
519
|
+
}, v.argLimits = p;
|
|
520
|
+
for (let w = 0, q = b.length; w < q; w++) {
|
|
521
|
+
const H = b[w].navigationState;
|
|
522
|
+
H.argLimits = p;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function Ie() {
|
|
527
|
+
return x(), Ve();
|
|
528
|
+
}
|
|
529
|
+
function Ve() {
|
|
530
|
+
for (; ; ) {
|
|
531
|
+
if (!Ce())
|
|
532
|
+
return null;
|
|
533
|
+
for (; ; ) {
|
|
534
|
+
const l = qe();
|
|
535
|
+
if (l != null)
|
|
536
|
+
return b[f].testsInLastTurn++, E++, l;
|
|
537
|
+
if (Pe()) {
|
|
538
|
+
if (!$e())
|
|
539
|
+
return null;
|
|
540
|
+
De();
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function Ce() {
|
|
547
|
+
return !(Ae() || Oe() || D() && (Le() || !_e()) || !Ne());
|
|
548
|
+
}
|
|
549
|
+
function Ae() {
|
|
550
|
+
return g != null && E >= g;
|
|
551
|
+
}
|
|
552
|
+
function Oe() {
|
|
553
|
+
return m != null && h.now() - C >= m;
|
|
554
|
+
}
|
|
555
|
+
function Le() {
|
|
556
|
+
if (!D())
|
|
557
|
+
throw new Error("Unexpected behavior");
|
|
558
|
+
return c != null && c <= 0;
|
|
559
|
+
}
|
|
560
|
+
function _e() {
|
|
561
|
+
if (!D())
|
|
562
|
+
throw new Error("Unexpected behavior");
|
|
563
|
+
for (let l = 0, u = d.length; l < u; l++)
|
|
564
|
+
if (_(d[l]) && W(l))
|
|
565
|
+
return !0;
|
|
566
|
+
return !1;
|
|
567
|
+
}
|
|
568
|
+
function Ne() {
|
|
569
|
+
for (let l = 0, u = d.length; l < u; l++)
|
|
570
|
+
if (W(l))
|
|
571
|
+
return !0;
|
|
572
|
+
return !1;
|
|
573
|
+
}
|
|
574
|
+
function Pe() {
|
|
575
|
+
f++;
|
|
576
|
+
const l = f >= d.length;
|
|
577
|
+
return l && (f = 0), ie(), l;
|
|
578
|
+
}
|
|
579
|
+
function $e() {
|
|
580
|
+
if (D()) {
|
|
581
|
+
const l = Ge();
|
|
582
|
+
if (c != null && l >= c)
|
|
583
|
+
return !1;
|
|
584
|
+
}
|
|
585
|
+
return !0;
|
|
586
|
+
}
|
|
587
|
+
function D() {
|
|
588
|
+
for (let l = 0, u = d.length; l < u; l++)
|
|
589
|
+
if (U(d[l]))
|
|
590
|
+
return !0;
|
|
591
|
+
return !1;
|
|
592
|
+
}
|
|
593
|
+
function Ge() {
|
|
594
|
+
let l = !1, u = 1 / 0;
|
|
595
|
+
for (let p = 0, w = b.length; p < w; p++) {
|
|
596
|
+
const q = b[p], H = d[p];
|
|
597
|
+
U(H) && (l = !0, W(p) && q.completedCount < u && (u = q.completedCount));
|
|
598
|
+
}
|
|
599
|
+
if (!l)
|
|
600
|
+
throw new Error("Unexpected behavior");
|
|
601
|
+
return u;
|
|
602
|
+
}
|
|
603
|
+
function W(l) {
|
|
604
|
+
const u = d[l], p = b[l];
|
|
605
|
+
return u.limitTests != null && u.limitTests <= 0 || _(u) && (u.cycles != null && u.cycles <= 0 || u.attemptsPerVariant != null && u.attemptsPerVariant <= 0) ? !1 : p.tryNextVariantAttempts < 2;
|
|
606
|
+
}
|
|
607
|
+
function De() {
|
|
608
|
+
f = 0;
|
|
609
|
+
for (let l = 0, u = b.length; l < u; l++) {
|
|
610
|
+
const p = b[l];
|
|
611
|
+
p.testsInLastTurn = 0, p.startTime = null;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function qe() {
|
|
615
|
+
let l = 0;
|
|
616
|
+
for (; l < 2; ) {
|
|
617
|
+
if (!Ue())
|
|
618
|
+
return null;
|
|
619
|
+
const u = Fe();
|
|
620
|
+
if (u != null)
|
|
621
|
+
return u;
|
|
622
|
+
if (_(d[f]) && je())
|
|
623
|
+
return null;
|
|
624
|
+
l++;
|
|
625
|
+
}
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
function Ue() {
|
|
629
|
+
const l = d[f];
|
|
630
|
+
return !(Be() || ke() || _(l) && !Re(f));
|
|
631
|
+
}
|
|
632
|
+
function Be() {
|
|
633
|
+
const l = d[f], u = b[f];
|
|
634
|
+
return l.limitTests != null && u.testsInLastTurn >= l.limitTests;
|
|
635
|
+
}
|
|
636
|
+
function ke() {
|
|
637
|
+
const l = d[f], u = b[f];
|
|
638
|
+
return l.limitTime != null && u.startTime != null && h.now() - u.startTime >= l.limitTime;
|
|
639
|
+
}
|
|
640
|
+
function _(l) {
|
|
641
|
+
return U(l);
|
|
642
|
+
}
|
|
643
|
+
function Re(l) {
|
|
644
|
+
const u = d[l], p = b[l];
|
|
645
|
+
if (!_(u))
|
|
646
|
+
throw new Error("Unexpected behavior");
|
|
647
|
+
return p.cycleCount < (u.cycles ?? 1);
|
|
648
|
+
}
|
|
649
|
+
function je() {
|
|
650
|
+
const l = d[f], u = b[f];
|
|
651
|
+
if (!_(l))
|
|
652
|
+
throw new Error("Unexpected behavior");
|
|
653
|
+
return u.cycleCount++, u.cycleCount >= (l.cycles ?? 1) ? (u.cycleCount = 0, u.completedCount++, !0) : !1;
|
|
654
|
+
}
|
|
655
|
+
function Fe() {
|
|
656
|
+
const l = d[f], u = b[f], p = u.navigationState;
|
|
657
|
+
if ($(l)) {
|
|
658
|
+
if (z())
|
|
659
|
+
return null;
|
|
660
|
+
const w = We();
|
|
661
|
+
if (w != null)
|
|
662
|
+
return u.startTime == null && (u.startTime = h.now()), w;
|
|
663
|
+
}
|
|
664
|
+
return He() ? (u.tryNextVariantAttempts = 0, $(l) && ze(), u.startTime == null && (u.startTime = h.now()), le(p.args)) : (u.tryNextVariantAttempts++, null);
|
|
665
|
+
}
|
|
666
|
+
function We() {
|
|
667
|
+
const l = d[f], p = b[f].navigationState;
|
|
668
|
+
if (!$(l))
|
|
669
|
+
throw new Error("Unexpected behavior");
|
|
670
|
+
if (z())
|
|
671
|
+
throw new Error("Unexpected behavior");
|
|
672
|
+
const w = l.attemptsPerVariant ?? 1;
|
|
673
|
+
return p.attempts > 0 && p.attempts < w ? L(p) ? null : (p.attempts++, le(p.args)) : null;
|
|
674
|
+
}
|
|
675
|
+
function ze() {
|
|
676
|
+
const l = d[f], p = b[f].navigationState;
|
|
677
|
+
if (!$(l))
|
|
678
|
+
throw new Error("Unexpected behavior");
|
|
679
|
+
if (z())
|
|
680
|
+
throw new Error("Unexpected behavior");
|
|
681
|
+
p.attempts = 1;
|
|
682
|
+
}
|
|
683
|
+
function $(l) {
|
|
684
|
+
return U(l);
|
|
685
|
+
}
|
|
686
|
+
function z() {
|
|
687
|
+
const l = d[f];
|
|
688
|
+
if (!$(l))
|
|
689
|
+
throw new Error("Unexpected behavior");
|
|
690
|
+
return (l.attemptsPerVariant ?? 1) <= 0;
|
|
691
|
+
}
|
|
692
|
+
function He() {
|
|
693
|
+
const l = d[f], p = b[f].navigationState;
|
|
694
|
+
switch (l.mode) {
|
|
695
|
+
case "forward":
|
|
696
|
+
return ye(p);
|
|
697
|
+
case "backward":
|
|
698
|
+
return K(p);
|
|
699
|
+
case "random":
|
|
700
|
+
return dt(p);
|
|
701
|
+
default:
|
|
702
|
+
throw new Error(`Unknown mode: ${l.mode}`);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function le(l) {
|
|
706
|
+
const u = { ...l };
|
|
707
|
+
return s != null && (u.seed = s({ tests: E })), u;
|
|
708
|
+
}
|
|
709
|
+
return {
|
|
710
|
+
get limit() {
|
|
711
|
+
return M;
|
|
712
|
+
},
|
|
713
|
+
get modeIndex() {
|
|
714
|
+
return f;
|
|
715
|
+
},
|
|
716
|
+
get modeConfigs() {
|
|
717
|
+
return d;
|
|
718
|
+
},
|
|
719
|
+
get modeStates() {
|
|
720
|
+
return b;
|
|
721
|
+
},
|
|
722
|
+
get tests() {
|
|
723
|
+
return E;
|
|
724
|
+
},
|
|
725
|
+
calcIndexes: se,
|
|
726
|
+
extendTemplates: Te,
|
|
727
|
+
addLimit: Me,
|
|
728
|
+
next: Ie
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
function ne(e) {
|
|
732
|
+
if (e == null || e <= 0)
|
|
733
|
+
throw new Error(`Iterations = ${e}`);
|
|
734
|
+
e--;
|
|
735
|
+
const r = Ke().then(() => e);
|
|
736
|
+
return e <= 0 ? r : r.then(ne);
|
|
737
|
+
}
|
|
738
|
+
function yt(e, r, t) {
|
|
739
|
+
const i = r.limit ? {
|
|
740
|
+
error: r.limit.error,
|
|
741
|
+
args: r.limit.args,
|
|
742
|
+
tests: r.limit.tests
|
|
743
|
+
} : null;
|
|
744
|
+
if (i && !t)
|
|
745
|
+
throw i.error;
|
|
746
|
+
return {
|
|
747
|
+
iterations: e.iterations,
|
|
748
|
+
bestError: i
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
const me = 2 ** 31;
|
|
752
|
+
function vt(e) {
|
|
753
|
+
if (e == null)
|
|
754
|
+
return { parallel: 1, sequentialOnError: !1 };
|
|
755
|
+
if (typeof e == "boolean")
|
|
756
|
+
return {
|
|
757
|
+
parallel: e ? me : 1,
|
|
758
|
+
sequentialOnError: !1
|
|
759
|
+
};
|
|
760
|
+
if (typeof e == "number")
|
|
761
|
+
return { parallel: e > 0 ? e : 1, sequentialOnError: !1 };
|
|
762
|
+
const r = e.count;
|
|
763
|
+
let t = 1;
|
|
764
|
+
return r === !0 ? t = me : typeof r == "number" && r > 0 && (t = r), {
|
|
765
|
+
parallel: t,
|
|
766
|
+
sequentialOnError: e.sequentialOnError ?? !1
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function St(e) {
|
|
770
|
+
const r = e?.saveErrorVariants, t = r && e.createSaveErrorVariantsStore ? e.createSaveErrorVariantsStore(r) : null, i = e?.findBestError, { parallel: o, sequentialOnError: s } = vt(
|
|
771
|
+
e?.parallel
|
|
772
|
+
);
|
|
773
|
+
return {
|
|
774
|
+
store: t,
|
|
775
|
+
GC_Iterations: e?.GC_Iterations ?? 1e6,
|
|
776
|
+
GC_IterationsAsync: e?.GC_IterationsAsync ?? 1e4,
|
|
777
|
+
GC_Interval: e?.GC_Interval ?? 1e3,
|
|
778
|
+
logOptions: be(e?.log),
|
|
779
|
+
abortSignalExternal: e?.abortSignal,
|
|
780
|
+
findBestError: i,
|
|
781
|
+
dontThrowIfError: i?.dontThrowIfError,
|
|
782
|
+
timeController: e?.timeController ?? F,
|
|
783
|
+
parallel: o,
|
|
784
|
+
sequentialOnError: s
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
function R(e, r, t) {
|
|
788
|
+
const { options: i, variantsIterator: o } = e, s = o.limit?.args ?? r;
|
|
789
|
+
if (!i.store)
|
|
790
|
+
return;
|
|
791
|
+
const n = i.store.save(s);
|
|
792
|
+
if (t)
|
|
793
|
+
return n;
|
|
794
|
+
}
|
|
795
|
+
function Et(e, r, t, i) {
|
|
796
|
+
const { abortControllerParallel: o, state: s, options: n } = e, { logOptions: a } = n;
|
|
797
|
+
if (e.options.findBestError)
|
|
798
|
+
e.variantsIterator.addLimit({ args: r, error: t, tests: i }), s.debugMode = !1, R(e, r, !1), n.sequentialOnError && !o.signal.aborted ? (a.debug && a.func(
|
|
799
|
+
"debug",
|
|
800
|
+
"[test-variants] sequentialOnError: aborting parallel, switching to sequential"
|
|
801
|
+
), o.abort(new V())) : a.debug && a.func(
|
|
802
|
+
"debug",
|
|
803
|
+
"[test-variants] parallel error in findBestError mode, continuing with new limits"
|
|
804
|
+
);
|
|
805
|
+
else {
|
|
806
|
+
if (o.signal.aborted)
|
|
807
|
+
return;
|
|
808
|
+
R(e, r, !1), o.abort(t);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function de(e, r, t, i) {
|
|
812
|
+
const { state: o } = e;
|
|
813
|
+
if (e.options.findBestError) {
|
|
814
|
+
e.variantsIterator.addLimit({ args: r, error: t, tests: i });
|
|
815
|
+
const n = R(e, r, !0);
|
|
816
|
+
if (n)
|
|
817
|
+
return n.then(() => {
|
|
818
|
+
o.debugMode = !1;
|
|
819
|
+
});
|
|
820
|
+
o.debugMode = !1;
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
const s = R(e, r, !0);
|
|
824
|
+
if (s)
|
|
825
|
+
return s.then(() => {
|
|
826
|
+
throw t;
|
|
827
|
+
});
|
|
828
|
+
throw t;
|
|
829
|
+
}
|
|
830
|
+
function wt(e, r) {
|
|
831
|
+
const { GC_Iterations: t, GC_IterationsAsync: i, GC_Interval: o } = e.options;
|
|
832
|
+
return t > 0 && e.state.iterations - e.state.prevGcIterations >= t || i > 0 && e.state.iterationsAsync - e.state.prevGcIterationsAsync >= i || o > 0 && r - e.state.prevGcTime >= o;
|
|
833
|
+
}
|
|
834
|
+
async function xt(e, r) {
|
|
835
|
+
e.prevGcIterations = e.iterations, e.prevGcIterationsAsync = e.iterationsAsync, e.prevGcTime = r, await ne(1);
|
|
836
|
+
}
|
|
837
|
+
function oe(e) {
|
|
838
|
+
const r = e / 1e3;
|
|
839
|
+
if (r < 60)
|
|
840
|
+
return `${r.toFixed(1)}s`;
|
|
841
|
+
const t = r / 60;
|
|
842
|
+
return t < 60 ? `${t.toFixed(1)}m` : `${(t / 60).toFixed(1)}h`;
|
|
843
|
+
}
|
|
844
|
+
function Q(e) {
|
|
845
|
+
const r = e / 1073741824;
|
|
846
|
+
if (r >= 1)
|
|
847
|
+
return r >= 10 ? `${Math.round(r)}GB` : `${r.toFixed(1)}GB`;
|
|
848
|
+
const t = e / (1024 * 1024);
|
|
849
|
+
return t >= 10 ? `${Math.round(t)}MB` : `${t.toFixed(1)}MB`;
|
|
850
|
+
}
|
|
851
|
+
function Tt(e, r) {
|
|
852
|
+
if (!e)
|
|
853
|
+
return `mode[${r}]: null`;
|
|
854
|
+
let t = `mode[${r}]: ${e.mode}`;
|
|
855
|
+
return (e.mode === "forward" || e.mode === "backward") && (e.cycles != null && (t += `, cycles=${e.cycles}`), e.attemptsPerVariant != null && (t += `, attempts=${e.attemptsPerVariant}`)), e.limitTime != null && (t += `, limitTime=${oe(e.limitTime)}`), e.limitTests != null && (t += `, limitTests=${e.limitTests}`), t;
|
|
856
|
+
}
|
|
857
|
+
function ve(e, r) {
|
|
858
|
+
const t = e - r, i = t >= 0 ? "+" : "";
|
|
859
|
+
return `${Q(e)} (${i}${Q(t)})`;
|
|
860
|
+
}
|
|
861
|
+
function Mt(e, r) {
|
|
862
|
+
if (!e.start)
|
|
863
|
+
return;
|
|
864
|
+
let t = "[test-variants] start";
|
|
865
|
+
r != null && (t += `, memory: ${Q(r)}`), e.func("start", t);
|
|
866
|
+
}
|
|
867
|
+
function It(e) {
|
|
868
|
+
const { options: r, state: t } = e, { logOptions: i, timeController: o } = r;
|
|
869
|
+
if (!i.completed)
|
|
870
|
+
return;
|
|
871
|
+
const s = o.now() - t.startTime;
|
|
872
|
+
let n = `[test-variants] end, tests: ${t.tests} (${oe(s)}), async: ${t.iterationsAsync}`;
|
|
873
|
+
if (t.startMemory != null) {
|
|
874
|
+
const a = re();
|
|
875
|
+
a != null && (n += `, memory: ${ve(a, t.startMemory)}`);
|
|
876
|
+
}
|
|
877
|
+
i.func("completed", n);
|
|
878
|
+
}
|
|
879
|
+
function Se(e) {
|
|
880
|
+
const { options: r, state: t } = e, { logOptions: i } = r, o = t.pendingModeChange;
|
|
881
|
+
!i.modeChange || o == null || (i.func(
|
|
882
|
+
"modeChange",
|
|
883
|
+
`[test-variants] ${Tt(o.mode, o.modeIndex)}`
|
|
884
|
+
), t.pendingModeChange = null);
|
|
885
|
+
}
|
|
886
|
+
function Vt(e) {
|
|
887
|
+
const { options: r, state: t } = e, { logOptions: i, timeController: o } = r, s = o.now();
|
|
888
|
+
if (!i.progress || s - t.prevLogTime < i.progress)
|
|
889
|
+
return !1;
|
|
890
|
+
Se(e);
|
|
891
|
+
const n = s - t.startTime;
|
|
892
|
+
let a = `[test-variants] tests: ${t.tests} (${oe(n)}), async: ${t.iterationsAsync}`;
|
|
893
|
+
if (t.prevLogMemory != null) {
|
|
894
|
+
const c = re();
|
|
895
|
+
c != null && (a += `, memory: ${ve(c, t.prevLogMemory)}`, t.prevLogMemory = c);
|
|
896
|
+
}
|
|
897
|
+
return i.func("progress", a), t.prevLogTime = s, !0;
|
|
898
|
+
}
|
|
899
|
+
function Y(e, r) {
|
|
900
|
+
e.debugMode = !1, r && (e.iterationsAsync += r.iterationsAsync, e.iterations += r.iterationsSync + r.iterationsAsync);
|
|
901
|
+
}
|
|
902
|
+
function ee(e) {
|
|
903
|
+
e.state.debugMode = !0, e.abortControllerParallel.abort(new V());
|
|
904
|
+
}
|
|
905
|
+
function Ee(e, r) {
|
|
906
|
+
const { testRun: t, testOptions: i, state: o } = e, s = o.tests;
|
|
907
|
+
o.tests++;
|
|
908
|
+
try {
|
|
909
|
+
const n = t(r, s, i);
|
|
910
|
+
if (O(n))
|
|
911
|
+
return n.then(
|
|
912
|
+
(a) => {
|
|
913
|
+
if (!a) {
|
|
914
|
+
ee(e);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
Y(o, a);
|
|
918
|
+
},
|
|
919
|
+
(a) => de(e, r, a, s)
|
|
920
|
+
);
|
|
921
|
+
if (!n) {
|
|
922
|
+
ee(e);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
Y(o, n);
|
|
926
|
+
} catch (n) {
|
|
927
|
+
return n instanceof V ? void 0 : de(e, r, n, s);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function Ct(e, r) {
|
|
931
|
+
const { pool: t, abortSignal: i, testRun: o, testOptionsParallel: s, state: n } = e;
|
|
932
|
+
if (!t)
|
|
933
|
+
return;
|
|
934
|
+
const a = n.tests;
|
|
935
|
+
n.tests++, (async () => {
|
|
936
|
+
try {
|
|
937
|
+
if (i.aborted)
|
|
938
|
+
return;
|
|
939
|
+
let c = o(r, a, s);
|
|
940
|
+
if (O(c) && (c = await c), !c) {
|
|
941
|
+
ee(e);
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
Y(n, c);
|
|
945
|
+
} catch (c) {
|
|
946
|
+
if (c instanceof V)
|
|
947
|
+
return;
|
|
948
|
+
Et(e, r, c, a);
|
|
949
|
+
} finally {
|
|
950
|
+
t.release(1);
|
|
951
|
+
}
|
|
952
|
+
})();
|
|
953
|
+
}
|
|
954
|
+
function we(e) {
|
|
955
|
+
const { options: r, state: t } = e, { logOptions: i, timeController: o, GC_Interval: s } = r;
|
|
956
|
+
if (!i.progress && !s)
|
|
957
|
+
return;
|
|
958
|
+
Vt(e);
|
|
959
|
+
const n = o.now();
|
|
960
|
+
if (wt(e, n))
|
|
961
|
+
return xt(t, n);
|
|
962
|
+
}
|
|
963
|
+
function j(e) {
|
|
964
|
+
return e.options.abortSignalExternal?.aborted ?? !1;
|
|
965
|
+
}
|
|
966
|
+
function te(e) {
|
|
967
|
+
return e.abortSignal.aborted;
|
|
968
|
+
}
|
|
969
|
+
async function J(e, r) {
|
|
970
|
+
const { pool: t, state: i, options: o } = e, { parallel: s, logOptions: n } = o;
|
|
971
|
+
let a = null;
|
|
972
|
+
for (; !j(e); ) {
|
|
973
|
+
const c = t && !te(e);
|
|
974
|
+
let g = !1;
|
|
975
|
+
c && (t.hold(1) || await ae({ pool: t, count: 1, hold: !0 }), g = !0);
|
|
976
|
+
try {
|
|
977
|
+
if (r != null ? (a = r, r = null) : e.state.debugMode || (a = e.variantsIterator.next()), a == null)
|
|
978
|
+
break;
|
|
979
|
+
const m = we(e);
|
|
980
|
+
if (O(m) && await m, j(e))
|
|
981
|
+
continue;
|
|
982
|
+
if (c)
|
|
983
|
+
Ct(e, a), g = !1;
|
|
984
|
+
else {
|
|
985
|
+
n.debug && t && te(e) && n.func(
|
|
986
|
+
"debug",
|
|
987
|
+
`[test-variants] parallel aborted, running sequential: tests=${i.tests}`
|
|
988
|
+
);
|
|
989
|
+
const h = Ee(e, a);
|
|
990
|
+
O(h) && await h;
|
|
991
|
+
}
|
|
992
|
+
} finally {
|
|
993
|
+
g && t.release(1);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
t && (await ae({ pool: t, count: s, hold: !0 }), t.release(s));
|
|
997
|
+
}
|
|
998
|
+
function At(e) {
|
|
999
|
+
const { pool: r, state: t, options: i } = e, { logOptions: o } = i;
|
|
1000
|
+
if (r)
|
|
1001
|
+
return J(e);
|
|
1002
|
+
let s = null;
|
|
1003
|
+
for (; !j(e) && (e.state.debugMode || (s = e.variantsIterator.next()), s != null); ) {
|
|
1004
|
+
const n = we(e);
|
|
1005
|
+
if (O(n))
|
|
1006
|
+
return n.then(() => J(e, s));
|
|
1007
|
+
if (j(e))
|
|
1008
|
+
continue;
|
|
1009
|
+
o.debug && te(e) && o.func(
|
|
1010
|
+
"debug",
|
|
1011
|
+
`[test-variants] parallel aborted, running sequential: tests=${t.tests}`
|
|
1012
|
+
);
|
|
1013
|
+
const a = Ee(e, s);
|
|
1014
|
+
if (O(a))
|
|
1015
|
+
return a.then(() => J(e));
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
async function Ot(e, r, t, i) {
|
|
1019
|
+
const o = St(i), {
|
|
1020
|
+
store: s,
|
|
1021
|
+
logOptions: n,
|
|
1022
|
+
abortSignalExternal: a,
|
|
1023
|
+
findBestError: c,
|
|
1024
|
+
dontThrowIfError: g,
|
|
1025
|
+
timeController: m,
|
|
1026
|
+
parallel: h
|
|
1027
|
+
} = o, y = new Z(), d = new Z(), b = X(
|
|
1028
|
+
a,
|
|
1029
|
+
y.signal
|
|
1030
|
+
), v = X(
|
|
1031
|
+
b,
|
|
1032
|
+
d.signal
|
|
1033
|
+
), M = {
|
|
1034
|
+
abortSignal: b,
|
|
1035
|
+
timeController: m
|
|
1036
|
+
}, f = {
|
|
1037
|
+
abortSignal: v,
|
|
1038
|
+
timeController: m
|
|
1039
|
+
};
|
|
1040
|
+
s && await s.replay({
|
|
1041
|
+
testRun: e,
|
|
1042
|
+
variantsIterator: r,
|
|
1043
|
+
testOptions: M,
|
|
1044
|
+
findBestErrorEnabled: !!c
|
|
1045
|
+
});
|
|
1046
|
+
const E = h <= 1 ? null : new Ye(h);
|
|
1047
|
+
Mt(n, t.startMemory);
|
|
1048
|
+
const S = {
|
|
1049
|
+
options: o,
|
|
1050
|
+
testRun: e,
|
|
1051
|
+
variantsIterator: r,
|
|
1052
|
+
testOptions: M,
|
|
1053
|
+
testOptionsParallel: f,
|
|
1054
|
+
abortControllerGlobal: y,
|
|
1055
|
+
abortControllerParallel: d,
|
|
1056
|
+
abortSignal: v,
|
|
1057
|
+
pool: E,
|
|
1058
|
+
state: t
|
|
1059
|
+
};
|
|
1060
|
+
Se(S);
|
|
1061
|
+
try {
|
|
1062
|
+
await At(S), v.throwIfAborted();
|
|
1063
|
+
} catch (C) {
|
|
1064
|
+
throw y.abort(new V()), C;
|
|
1065
|
+
}
|
|
1066
|
+
return b.throwIfAborted(), y.abort(new V()), It(S), await ne(1), yt(t, r, g);
|
|
1067
|
+
}
|
|
1068
|
+
function Gt(e) {
|
|
1069
|
+
return function(t) {
|
|
1070
|
+
return async function(o) {
|
|
1071
|
+
const s = be(o?.log), n = ft(e, {
|
|
1072
|
+
onStart: o?.onStart,
|
|
1073
|
+
onEnd: o?.onEnd,
|
|
1074
|
+
onError: o?.onError,
|
|
1075
|
+
log: s,
|
|
1076
|
+
pauseDebuggerOnError: o?.pauseDebuggerOnError,
|
|
1077
|
+
timeout: o?.timeout
|
|
1078
|
+
}), a = o?.timeController ?? F, c = re(), g = st(a, c), m = o?.onModeChange;
|
|
1079
|
+
function h(d) {
|
|
1080
|
+
g.pendingModeChange = d, m?.(d);
|
|
1081
|
+
}
|
|
1082
|
+
const y = bt({
|
|
1083
|
+
argsTemplates: t,
|
|
1084
|
+
getSeed: o?.getSeed,
|
|
1085
|
+
iterationModes: o?.iterationModes,
|
|
1086
|
+
equals: o?.findBestError?.equals,
|
|
1087
|
+
limitArgOnError: o?.findBestError?.limitArgOnError,
|
|
1088
|
+
includeErrorVariant: o?.findBestError?.includeErrorVariant,
|
|
1089
|
+
timeController: a,
|
|
1090
|
+
onModeChange: h,
|
|
1091
|
+
limitCompletionCount: o?.cycles ?? 1,
|
|
1092
|
+
limitTests: o?.limitTests,
|
|
1093
|
+
limitTime: o?.limitTime
|
|
1094
|
+
});
|
|
1095
|
+
return Ot(n, y, g, o);
|
|
1096
|
+
};
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
export {
|
|
1100
|
+
et as T,
|
|
1101
|
+
Gt as c
|
|
1102
|
+
};
|