@flemist/test-variants 5.0.4 → 5.0.5
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/build/browser/index.cjs +1 -1
- package/build/browser/index.mjs +1 -1
- package/build/common/index.cjs +1 -1
- package/build/common/index.mjs +1 -1
- package/build/{createTestVariants-D3rpiTL9.mjs → createTestVariants-BXmWQaT8.mjs} +129 -137
- package/build/{createTestVariants-cAlu7ujN.js → createTestVariants-BYmqvvhv.js} +3 -3
- package/build/node/index.cjs +1 -1
- package/build/node/index.mjs +1 -1
- package/package.json +35 -32
package/build/browser/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-BYmqvvhv.js");exports.createTestVariants=e.createTestVariants;
|
package/build/browser/index.mjs
CHANGED
package/build/common/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createTestVariants-BYmqvvhv.js");exports.createTestVariants=e.createTestVariants;
|
package/build/common/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { timeControllerDefault as Q } from "@flemist/time-controller";
|
|
2
|
-
import { formatAny as z, deepCloneJsonLike as
|
|
3
|
-
import { isPromiseLike as M, waitMicrotasks as
|
|
4
|
-
import { AbortError as
|
|
5
|
-
import { poolWait as ae, Pool as
|
|
2
|
+
import { formatAny as z, deepCloneJsonLike as He } from "@flemist/simple-utils";
|
|
3
|
+
import { isPromiseLike as M, waitMicrotasks as Je, combineAbortSignals as ie } from "@flemist/async-utils";
|
|
4
|
+
import { AbortError as Xe, AbortControllerFast as se } from "@flemist/abort-controller-fast";
|
|
5
|
+
import { poolWait as ae, Pool as Ze } from "@flemist/time-limits";
|
|
6
6
|
function Y() {
|
|
7
7
|
if (typeof process < "u" && process.memoryUsage)
|
|
8
8
|
try {
|
|
@@ -19,22 +19,22 @@ function Y() {
|
|
|
19
19
|
}
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
function
|
|
22
|
+
const Ke = 1e3, q = [];
|
|
23
|
+
function Qe(e) {
|
|
24
24
|
return z(e, { pretty: !0, maxDepth: 5, maxItems: 50 });
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const n = e.map((t) => typeof t == "string" ? t :
|
|
28
|
-
q.push(n), q.length >
|
|
26
|
+
function Ye(...e) {
|
|
27
|
+
const n = e.map((t) => typeof t == "string" ? t : Qe(t)).join(" ");
|
|
28
|
+
q.push(n), q.length > Ke && q.shift(), console.log(n);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function et() {
|
|
31
31
|
return q.join(`
|
|
32
32
|
`);
|
|
33
33
|
}
|
|
34
|
-
globalThis.__getStressTestLogLast =
|
|
34
|
+
globalThis.__getStressTestLogLast = et;
|
|
35
35
|
const me = (e, n) => {
|
|
36
|
-
|
|
37
|
-
},
|
|
36
|
+
Ye(n);
|
|
37
|
+
}, w = {
|
|
38
38
|
start: !0,
|
|
39
39
|
progress: 5e3,
|
|
40
40
|
completed: !0,
|
|
@@ -42,7 +42,7 @@ const me = (e, n) => {
|
|
|
42
42
|
modeChange: !0,
|
|
43
43
|
debug: !1,
|
|
44
44
|
func: me
|
|
45
|
-
},
|
|
45
|
+
}, tt = {
|
|
46
46
|
start: !1,
|
|
47
47
|
progress: !1,
|
|
48
48
|
completed: !1,
|
|
@@ -52,17 +52,17 @@ const me = (e, n) => {
|
|
|
52
52
|
func: me
|
|
53
53
|
};
|
|
54
54
|
function ge(e) {
|
|
55
|
-
return e === !1 ?
|
|
56
|
-
start: e.start ??
|
|
57
|
-
progress: e.progress ??
|
|
58
|
-
completed: e.completed ??
|
|
59
|
-
error: e.error ??
|
|
60
|
-
modeChange: e.modeChange ??
|
|
61
|
-
debug: e.debug ??
|
|
62
|
-
func: e.func ??
|
|
55
|
+
return e === !1 ? tt : e === !0 || !e ? w : {
|
|
56
|
+
start: e.start ?? w.start,
|
|
57
|
+
progress: e.progress ?? w.progress,
|
|
58
|
+
completed: e.completed ?? w.completed,
|
|
59
|
+
error: e.error ?? w.error,
|
|
60
|
+
modeChange: e.modeChange ?? w.modeChange,
|
|
61
|
+
debug: e.debug ?? w.debug,
|
|
62
|
+
func: e.func ?? w.func
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function rt(e, n) {
|
|
66
66
|
const t = e.now();
|
|
67
67
|
return {
|
|
68
68
|
startTime: t,
|
|
@@ -79,13 +79,13 @@ function nt(e, n) {
|
|
|
79
79
|
prevGcIterationsAsync: 0
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
class T extends
|
|
82
|
+
class T extends Xe {
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const nt = 50, ot = 5;
|
|
85
85
|
function le(e, n) {
|
|
86
86
|
return typeof e == "number" ? { iterationsAsync: 0, iterationsSync: e } : e != null && typeof e == "object" ? e : n ? { iterationsAsync: 1, iterationsSync: 0 } : { iterationsAsync: 0, iterationsSync: 1 };
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function it(e, n) {
|
|
89
89
|
const t = n.log, i = n.pauseDebuggerOnError ?? !0;
|
|
90
90
|
let o = null, a = 0;
|
|
91
91
|
function r(l, u, f) {
|
|
@@ -96,7 +96,7 @@ tests: ${f}
|
|
|
96
96
|
${z(l)}`
|
|
97
97
|
));
|
|
98
98
|
const d = Date.now();
|
|
99
|
-
if (i && Function("debugger")(), Date.now() - d >
|
|
99
|
+
if (i && Function("debugger")(), Date.now() - d > nt && a < ot) {
|
|
100
100
|
t.func(
|
|
101
101
|
"debug",
|
|
102
102
|
`[test-variants] debug iteration: ${a}`
|
|
@@ -156,7 +156,7 @@ function O(e, n) {
|
|
|
156
156
|
}
|
|
157
157
|
return a ?? o;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function x(e, n, t) {
|
|
160
160
|
const i = e.argValues[n].length;
|
|
161
161
|
if (i === 0)
|
|
162
162
|
return -1;
|
|
@@ -203,7 +203,7 @@ function pe(e) {
|
|
|
203
203
|
e,
|
|
204
204
|
e.argsNames[r]
|
|
205
205
|
));
|
|
206
|
-
const u =
|
|
206
|
+
const u = x(
|
|
207
207
|
e,
|
|
208
208
|
r,
|
|
209
209
|
r > o
|
|
@@ -222,7 +222,7 @@ function pe(e) {
|
|
|
222
222
|
if (e.argValues[r] == null)
|
|
223
223
|
continue;
|
|
224
224
|
let l = r > o;
|
|
225
|
-
const u =
|
|
225
|
+
const u = x(e, r, l), f = e.indexes[r] + 1;
|
|
226
226
|
if (f <= u) {
|
|
227
227
|
e.indexes[r] = f, e.args[e.argsNames[r]] = e.argValues[r][f], f < u && (l = !0);
|
|
228
228
|
for (let d = r + 1; d < i; d++)
|
|
@@ -232,7 +232,7 @@ function pe(e) {
|
|
|
232
232
|
e,
|
|
233
233
|
e.argsNames[r]
|
|
234
234
|
);
|
|
235
|
-
const d =
|
|
235
|
+
const d = x(e, r, l);
|
|
236
236
|
if (d < 0)
|
|
237
237
|
break;
|
|
238
238
|
e.indexes[r] = 0, e.args[e.argsNames[r]] = e.argValues[r][0], d > 0 && (l = !0);
|
|
@@ -254,7 +254,7 @@ function H(e) {
|
|
|
254
254
|
e,
|
|
255
255
|
e.argsNames[r]
|
|
256
256
|
));
|
|
257
|
-
const u =
|
|
257
|
+
const u = x(
|
|
258
258
|
e,
|
|
259
259
|
r,
|
|
260
260
|
r > o
|
|
@@ -271,7 +271,7 @@ function H(e) {
|
|
|
271
271
|
if (e.argValues[r] == null)
|
|
272
272
|
continue;
|
|
273
273
|
let l = r > o;
|
|
274
|
-
const u =
|
|
274
|
+
const u = x(e, r, l);
|
|
275
275
|
let f = e.indexes[r] - 1;
|
|
276
276
|
if (f > u && (f = u), f >= 0) {
|
|
277
277
|
e.indexes[r] = f, e.args[e.argsNames[r]] = e.argValues[r][f], f < u && (l = !0);
|
|
@@ -282,7 +282,7 @@ function H(e) {
|
|
|
282
282
|
e,
|
|
283
283
|
e.argsNames[r]
|
|
284
284
|
);
|
|
285
|
-
const d =
|
|
285
|
+
const d = x(e, r, l);
|
|
286
286
|
if (d < 0)
|
|
287
287
|
break;
|
|
288
288
|
e.indexes[r] = d, e.args[e.argsNames[r]] = e.argValues[r][d], d > 0 && (l = !0);
|
|
@@ -293,7 +293,7 @@ function H(e) {
|
|
|
293
293
|
}
|
|
294
294
|
return C(e), !1;
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function st(e, n) {
|
|
297
297
|
C(e);
|
|
298
298
|
const t = e.argsNames, i = t.length;
|
|
299
299
|
let o = !1;
|
|
@@ -302,7 +302,7 @@ function at(e, n) {
|
|
|
302
302
|
if (l === void 0)
|
|
303
303
|
return null;
|
|
304
304
|
e.argValues[a] = O(e, r);
|
|
305
|
-
const u =
|
|
305
|
+
const u = x(e, a, o);
|
|
306
306
|
if (u < 0)
|
|
307
307
|
return null;
|
|
308
308
|
const f = U(
|
|
@@ -316,14 +316,14 @@ function at(e, n) {
|
|
|
316
316
|
}
|
|
317
317
|
return V(e) ? null : e.indexes.slice();
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function at(e) {
|
|
320
320
|
const n = e.indexes.length;
|
|
321
321
|
if (n === 0)
|
|
322
322
|
return !1;
|
|
323
323
|
let t = !1;
|
|
324
324
|
for (let i = 0; i < n; i++) {
|
|
325
325
|
e.argValues[i] = O(e, e.argsNames[i]);
|
|
326
|
-
const o =
|
|
326
|
+
const o = x(e, i, t);
|
|
327
327
|
if (o < 0)
|
|
328
328
|
return Math.random() < 0.5 ? pe(e) : H(e);
|
|
329
329
|
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);
|
|
@@ -333,7 +333,7 @@ function lt(e) {
|
|
|
333
333
|
function _(e) {
|
|
334
334
|
return e.mode === "forward" || e.mode === "backward";
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function lt(e, n, t, i) {
|
|
337
337
|
const o = n[t], a = e.templates[t];
|
|
338
338
|
if (typeof a != "function") {
|
|
339
339
|
if (U(a, o, i) >= 0)
|
|
@@ -348,12 +348,12 @@ function ut(e, n, t, i) {
|
|
|
348
348
|
}
|
|
349
349
|
U(r, o, i) >= 0 || r.push(o);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function ut(e, n, t) {
|
|
352
352
|
for (const i in n)
|
|
353
353
|
if (Object.prototype.hasOwnProperty.call(n, i)) {
|
|
354
354
|
if (i === "seed")
|
|
355
355
|
continue;
|
|
356
|
-
|
|
356
|
+
lt(e, n, i, t);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
function ce(e, n) {
|
|
@@ -366,8 +366,8 @@ function ce(e, n) {
|
|
|
366
366
|
}
|
|
367
367
|
return !0;
|
|
368
368
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
369
|
+
const ct = [{ mode: "forward" }];
|
|
370
|
+
function ft(e) {
|
|
371
371
|
const {
|
|
372
372
|
argsTemplates: n,
|
|
373
373
|
equals: t,
|
|
@@ -380,18 +380,18 @@ function dt(e) {
|
|
|
380
380
|
limitTests: f,
|
|
381
381
|
limitTime: d
|
|
382
382
|
} = e, h = e.timeController ?? Q, y = {
|
|
383
|
-
templates:
|
|
383
|
+
templates: He(n),
|
|
384
384
|
extra: {}
|
|
385
|
-
}, p = r == null || r.length === 0 ?
|
|
385
|
+
}, p = r == null || r.length === 0 ? ct : r, b = [];
|
|
386
386
|
let E = null, L = null, g = 0, S = 0, I = !1, P = 0;
|
|
387
387
|
function $() {
|
|
388
|
-
I || (I = !0, P = h.now(),
|
|
388
|
+
I || (I = !0, P = h.now(), Ee(), g = 0, re(), we());
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Ee() {
|
|
391
391
|
for (let s = 0, c = p.length; s < c; s++)
|
|
392
|
-
b.push(
|
|
392
|
+
b.push(Se());
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function Se() {
|
|
395
395
|
return {
|
|
396
396
|
navigationState: ue(
|
|
397
397
|
y,
|
|
@@ -422,13 +422,13 @@ function dt(e) {
|
|
|
422
422
|
tests: S
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
|
-
function
|
|
426
|
-
$(), ce(y.templates, s) &&
|
|
425
|
+
function xe(s) {
|
|
426
|
+
$(), ce(y.templates, s) && ut(y, s, t);
|
|
427
427
|
}
|
|
428
428
|
function ne(s, c) {
|
|
429
|
-
return $(), ce(y.templates, s) ? (E.limitArgOnError = c?.limitArg ?? i ?? null, E.includeErrorVariant = c?.includeLimit ?? o ?? !1,
|
|
429
|
+
return $(), ce(y.templates, s) ? (E.limitArgOnError = c?.limitArg ?? i ?? null, E.includeErrorVariant = c?.includeLimit ?? o ?? !1, st(E, s)) : null;
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function Me(s) {
|
|
432
432
|
const c = s?.args;
|
|
433
433
|
if (c == null)
|
|
434
434
|
return;
|
|
@@ -446,41 +446,41 @@ function dt(e) {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return $(),
|
|
449
|
+
function Te() {
|
|
450
|
+
return $(), Ve();
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function Ve() {
|
|
453
453
|
for (; ; ) {
|
|
454
|
-
if (!
|
|
454
|
+
if (!Ie())
|
|
455
455
|
return null;
|
|
456
456
|
for (; ; ) {
|
|
457
|
-
const s =
|
|
457
|
+
const s = _e();
|
|
458
458
|
if (s != null)
|
|
459
459
|
return b[g].testsInLastTurn++, S++, s;
|
|
460
|
-
if (
|
|
461
|
-
if (
|
|
460
|
+
if (Pe()) {
|
|
461
|
+
if (!$e())
|
|
462
462
|
return null;
|
|
463
|
-
|
|
463
|
+
De();
|
|
464
464
|
break;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
function
|
|
470
|
-
return !(
|
|
469
|
+
function Ie() {
|
|
470
|
+
return !(Ae() || Ce() || G() && (Oe() || !Le()) || !Ne());
|
|
471
471
|
}
|
|
472
|
-
function
|
|
472
|
+
function Ae() {
|
|
473
473
|
return f != null && S >= f;
|
|
474
474
|
}
|
|
475
|
-
function
|
|
475
|
+
function Ce() {
|
|
476
476
|
return d != null && h.now() - P >= d;
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function Oe() {
|
|
479
479
|
if (!G())
|
|
480
480
|
throw new Error("Unexpected behavior");
|
|
481
481
|
return u != null && u <= 0;
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function Le() {
|
|
484
484
|
if (!G())
|
|
485
485
|
throw new Error("Unexpected behavior");
|
|
486
486
|
for (let s = 0, c = p.length; s < c; s++)
|
|
@@ -488,20 +488,20 @@ function dt(e) {
|
|
|
488
488
|
return !0;
|
|
489
489
|
return !1;
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function Ne() {
|
|
492
492
|
for (let s = 0, c = p.length; s < c; s++)
|
|
493
493
|
if (k(s))
|
|
494
494
|
return !0;
|
|
495
495
|
return !1;
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function Pe() {
|
|
498
498
|
g++;
|
|
499
499
|
const s = g >= p.length;
|
|
500
500
|
return s && (g = 0), re(), s;
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function $e() {
|
|
503
503
|
if (G()) {
|
|
504
|
-
const s =
|
|
504
|
+
const s = Ge();
|
|
505
505
|
if (u != null && s >= u)
|
|
506
506
|
return !1;
|
|
507
507
|
}
|
|
@@ -513,7 +513,7 @@ function dt(e) {
|
|
|
513
513
|
return !0;
|
|
514
514
|
return !1;
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function Ge() {
|
|
517
517
|
let s = !1, c = 1 / 0;
|
|
518
518
|
for (let m = 0, v = b.length; m < v; m++) {
|
|
519
519
|
const D = b[m], j = p[m];
|
|
@@ -527,66 +527,66 @@ function dt(e) {
|
|
|
527
527
|
const c = p[s], m = b[s];
|
|
528
528
|
return c.limitTests != null && c.limitTests <= 0 || A(c) && (c.cycles != null && c.cycles <= 0 || c.attemptsPerVariant != null && c.attemptsPerVariant <= 0) ? !1 : m.tryNextVariantAttempts < 2;
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function De() {
|
|
531
531
|
g = 0;
|
|
532
532
|
for (let s = 0, c = b.length; s < c; s++) {
|
|
533
533
|
const m = b[s];
|
|
534
534
|
m.testsInLastTurn = 0, m.startTime = null;
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function _e() {
|
|
538
538
|
let s = 0;
|
|
539
539
|
for (; s < 2; ) {
|
|
540
|
-
if (!
|
|
540
|
+
if (!qe())
|
|
541
541
|
return null;
|
|
542
|
-
const c =
|
|
542
|
+
const c = Fe();
|
|
543
543
|
if (c != null)
|
|
544
544
|
return c;
|
|
545
|
-
if (A(p[g]) &&
|
|
545
|
+
if (A(p[g]) && ke())
|
|
546
546
|
return null;
|
|
547
547
|
s++;
|
|
548
548
|
}
|
|
549
549
|
return null;
|
|
550
550
|
}
|
|
551
|
-
function
|
|
551
|
+
function qe() {
|
|
552
552
|
const s = p[g];
|
|
553
|
-
return !(
|
|
553
|
+
return !(Ue() || Be() || A(s) && !Re(g));
|
|
554
554
|
}
|
|
555
|
-
function
|
|
555
|
+
function Ue() {
|
|
556
556
|
const s = p[g], c = b[g];
|
|
557
557
|
return s.limitTests != null && c.testsInLastTurn >= s.limitTests;
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function Be() {
|
|
560
560
|
const s = p[g], c = b[g];
|
|
561
561
|
return s.limitTime != null && c.startTime != null && h.now() - c.startTime >= s.limitTime;
|
|
562
562
|
}
|
|
563
563
|
function A(s) {
|
|
564
564
|
return _(s);
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function Re(s) {
|
|
567
567
|
const c = p[s], m = b[s];
|
|
568
568
|
if (!A(c))
|
|
569
569
|
throw new Error("Unexpected behavior");
|
|
570
570
|
return m.cycleCount < (c.cycles ?? 1);
|
|
571
571
|
}
|
|
572
|
-
function
|
|
572
|
+
function ke() {
|
|
573
573
|
const s = p[g], c = b[g];
|
|
574
574
|
if (!A(s))
|
|
575
575
|
throw new Error("Unexpected behavior");
|
|
576
576
|
return c.cycleCount++, c.cycleCount >= (s.cycles ?? 1) ? (c.cycleCount = 0, c.completedCount++, !0) : !1;
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function Fe() {
|
|
579
579
|
const s = p[g], c = b[g], m = c.navigationState;
|
|
580
580
|
if (N(s)) {
|
|
581
581
|
if (F())
|
|
582
582
|
return null;
|
|
583
|
-
const v =
|
|
583
|
+
const v = je();
|
|
584
584
|
if (v != null)
|
|
585
585
|
return c.startTime == null && (c.startTime = h.now()), v;
|
|
586
586
|
}
|
|
587
|
-
return
|
|
587
|
+
return ze() ? (c.tryNextVariantAttempts = 0, N(s) && We(), c.startTime == null && (c.startTime = h.now()), oe(m.args)) : (c.tryNextVariantAttempts++, null);
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function je() {
|
|
590
590
|
const s = p[g], m = b[g].navigationState;
|
|
591
591
|
if (!N(s))
|
|
592
592
|
throw new Error("Unexpected behavior");
|
|
@@ -595,7 +595,7 @@ function dt(e) {
|
|
|
595
595
|
const v = s.attemptsPerVariant ?? 1;
|
|
596
596
|
return m.attempts > 0 && m.attempts < v ? V(m) ? null : (m.attempts++, oe(m.args)) : null;
|
|
597
597
|
}
|
|
598
|
-
function
|
|
598
|
+
function We() {
|
|
599
599
|
const s = p[g], m = b[g].navigationState;
|
|
600
600
|
if (!N(s))
|
|
601
601
|
throw new Error("Unexpected behavior");
|
|
@@ -612,7 +612,7 @@ function dt(e) {
|
|
|
612
612
|
throw new Error("Unexpected behavior");
|
|
613
613
|
return (s.attemptsPerVariant ?? 1) <= 0;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
615
|
+
function ze() {
|
|
616
616
|
const s = p[g], m = b[g].navigationState;
|
|
617
617
|
switch (s.mode) {
|
|
618
618
|
case "forward":
|
|
@@ -620,7 +620,7 @@ function dt(e) {
|
|
|
620
620
|
case "backward":
|
|
621
621
|
return H(m);
|
|
622
622
|
case "random":
|
|
623
|
-
return
|
|
623
|
+
return at(m);
|
|
624
624
|
default:
|
|
625
625
|
throw new Error(`Unknown mode: ${s.mode}`);
|
|
626
626
|
}
|
|
@@ -646,19 +646,19 @@ function dt(e) {
|
|
|
646
646
|
return S;
|
|
647
647
|
},
|
|
648
648
|
calcIndexes: ne,
|
|
649
|
-
extendTemplates:
|
|
650
|
-
addLimit:
|
|
651
|
-
next:
|
|
649
|
+
extendTemplates: xe,
|
|
650
|
+
addLimit: Me,
|
|
651
|
+
next: Te
|
|
652
652
|
};
|
|
653
653
|
}
|
|
654
654
|
function ee(e) {
|
|
655
655
|
if (e == null || e <= 0)
|
|
656
656
|
throw new Error(`Iterations = ${e}`);
|
|
657
657
|
e--;
|
|
658
|
-
const n =
|
|
658
|
+
const n = Je().then(() => e);
|
|
659
659
|
return e <= 0 ? n : n.then(ee);
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function dt(e, n, t) {
|
|
662
662
|
const i = n.limit ? {
|
|
663
663
|
error: n.limit.error,
|
|
664
664
|
args: n.limit.args,
|
|
@@ -672,7 +672,7 @@ function mt(e, n, t) {
|
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
674
|
const fe = 2 ** 31;
|
|
675
|
-
function
|
|
675
|
+
function mt(e) {
|
|
676
676
|
if (e == null)
|
|
677
677
|
return { parallel: 1, sequentialOnError: !1 };
|
|
678
678
|
if (typeof e == "boolean")
|
|
@@ -689,8 +689,8 @@ function gt(e) {
|
|
|
689
689
|
sequentialOnError: e.sequentialOnError ?? !1
|
|
690
690
|
};
|
|
691
691
|
}
|
|
692
|
-
function
|
|
693
|
-
const n = e?.saveErrorVariants, t = n && e.createSaveErrorVariantsStore ? e.createSaveErrorVariantsStore(n) : null, i = e?.findBestError, { parallel: o, sequentialOnError: a } =
|
|
692
|
+
function gt(e) {
|
|
693
|
+
const n = e?.saveErrorVariants, t = n && e.createSaveErrorVariantsStore ? e.createSaveErrorVariantsStore(n) : null, i = e?.findBestError, { parallel: o, sequentialOnError: a } = mt(
|
|
694
694
|
e?.parallel
|
|
695
695
|
);
|
|
696
696
|
return {
|
|
@@ -715,7 +715,7 @@ function B(e, n, t) {
|
|
|
715
715
|
if (t)
|
|
716
716
|
return r;
|
|
717
717
|
}
|
|
718
|
-
function
|
|
718
|
+
function pt(e, n, t, i) {
|
|
719
719
|
const { abortControllerParallel: o, state: a, options: r } = e, { logOptions: l } = r;
|
|
720
720
|
if (e.options.findBestError)
|
|
721
721
|
e.variantsIterator.addLimit({ args: n, error: t, tests: i }), a.debugMode = !1, B(e, n, !1), r.sequentialOnError && !o.signal.aborted ? (l.debug && l.func(
|
|
@@ -750,11 +750,11 @@ function de(e, n, t, i) {
|
|
|
750
750
|
});
|
|
751
751
|
throw t;
|
|
752
752
|
}
|
|
753
|
-
function
|
|
753
|
+
function ht(e, n) {
|
|
754
754
|
const { GC_Iterations: t, GC_IterationsAsync: i, GC_Interval: o } = e.options;
|
|
755
755
|
return t > 0 && e.state.iterations - e.state.prevGcIterations >= t || i > 0 && e.state.iterationsAsync - e.state.prevGcIterationsAsync >= i || o > 0 && n - e.state.prevGcTime >= o;
|
|
756
756
|
}
|
|
757
|
-
async function
|
|
757
|
+
async function bt(e, n) {
|
|
758
758
|
e.prevGcIterations = e.iterations, e.prevGcIterationsAsync = e.iterationsAsync, e.prevGcTime = n, await ee(1);
|
|
759
759
|
}
|
|
760
760
|
function te(e) {
|
|
@@ -771,7 +771,7 @@ function J(e) {
|
|
|
771
771
|
const t = e / (1024 * 1024);
|
|
772
772
|
return t >= 10 ? `${Math.round(t)}MB` : `${t.toFixed(1)}MB`;
|
|
773
773
|
}
|
|
774
|
-
function
|
|
774
|
+
function yt(e, n) {
|
|
775
775
|
if (!e)
|
|
776
776
|
return `mode[${n}]: null`;
|
|
777
777
|
let t = `mode[${n}]: ${e.mode}`;
|
|
@@ -781,13 +781,13 @@ function he(e, n) {
|
|
|
781
781
|
const t = e - n, i = t >= 0 ? "+" : "";
|
|
782
782
|
return `${J(e)} (${i}${J(t)})`;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function vt(e, n) {
|
|
785
785
|
if (!e.start)
|
|
786
786
|
return;
|
|
787
787
|
let t = "[test-variants] start";
|
|
788
788
|
n != null && (t += `, memory: ${J(n)}`), e.func("start", t);
|
|
789
789
|
}
|
|
790
|
-
function
|
|
790
|
+
function Et(e) {
|
|
791
791
|
const { options: n, state: t } = e, { logOptions: i, timeController: o } = n;
|
|
792
792
|
if (!i.completed)
|
|
793
793
|
return;
|
|
@@ -803,10 +803,10 @@ function be(e) {
|
|
|
803
803
|
const { options: n, state: t } = e, { logOptions: i } = n, o = t.pendingModeChange;
|
|
804
804
|
!i.modeChange || o == null || (i.func(
|
|
805
805
|
"modeChange",
|
|
806
|
-
`[test-variants] ${
|
|
806
|
+
`[test-variants] ${yt(o.mode, o.modeIndex)}`
|
|
807
807
|
), t.pendingModeChange = null);
|
|
808
808
|
}
|
|
809
|
-
function
|
|
809
|
+
function St(e) {
|
|
810
810
|
const { options: n, state: t } = e, { logOptions: i, timeController: o } = n, a = o.now();
|
|
811
811
|
if (!i.progress || a - t.prevLogTime < i.progress)
|
|
812
812
|
return !1;
|
|
@@ -868,7 +868,7 @@ function wt(e, n) {
|
|
|
868
868
|
} catch (u) {
|
|
869
869
|
if (u instanceof T)
|
|
870
870
|
return;
|
|
871
|
-
|
|
871
|
+
pt(e, n, u, l);
|
|
872
872
|
} finally {
|
|
873
873
|
t.release(1);
|
|
874
874
|
}
|
|
@@ -878,10 +878,10 @@ function ve(e) {
|
|
|
878
878
|
const { options: n, state: t } = e, { logOptions: i, timeController: o, GC_Interval: a } = n;
|
|
879
879
|
if (!i.progress && !a)
|
|
880
880
|
return;
|
|
881
|
-
|
|
881
|
+
St(e);
|
|
882
882
|
const r = o.now();
|
|
883
|
-
if (
|
|
884
|
-
return
|
|
883
|
+
if (ht(e, r))
|
|
884
|
+
return bt(t, r);
|
|
885
885
|
}
|
|
886
886
|
function R(e) {
|
|
887
887
|
return e.options.abortSignalExternal?.aborted ?? !1;
|
|
@@ -889,24 +889,19 @@ function R(e) {
|
|
|
889
889
|
function K(e) {
|
|
890
890
|
return e.abortSignal.aborted;
|
|
891
891
|
}
|
|
892
|
-
function Ee(e, n) {
|
|
893
|
-
return e.state.debugMode ? n : e.variantsIterator.next();
|
|
894
|
-
}
|
|
895
892
|
async function W(e, n) {
|
|
896
893
|
const { pool: t, state: i, options: o } = e, { parallel: a, logOptions: r } = o;
|
|
897
|
-
let l =
|
|
894
|
+
let l = null;
|
|
898
895
|
for (; !R(e); ) {
|
|
899
896
|
const u = t && !K(e);
|
|
900
897
|
let f = !1;
|
|
901
898
|
u && (t.hold(1) || await ae({ pool: t, count: 1, hold: !0 }), f = !0);
|
|
902
899
|
try {
|
|
903
|
-
if (
|
|
900
|
+
if (n != null ? (l = n, n = null) : e.state.debugMode || (l = e.variantsIterator.next()), l == null)
|
|
904
901
|
break;
|
|
905
902
|
const d = ve(e);
|
|
906
|
-
if (M(d) && await d, R(e))
|
|
907
|
-
l = null;
|
|
903
|
+
if (M(d) && await d, R(e))
|
|
908
904
|
continue;
|
|
909
|
-
}
|
|
910
905
|
if (u)
|
|
911
906
|
wt(e, l), f = !1;
|
|
912
907
|
else {
|
|
@@ -917,24 +912,21 @@ async function W(e, n) {
|
|
|
917
912
|
const h = ye(e, l);
|
|
918
913
|
M(h) && await h;
|
|
919
914
|
}
|
|
920
|
-
l = null;
|
|
921
915
|
} finally {
|
|
922
916
|
f && t.release(1);
|
|
923
917
|
}
|
|
924
918
|
}
|
|
925
919
|
t && (await ae({ pool: t, count: a, hold: !0 }), t.release(a));
|
|
926
920
|
}
|
|
927
|
-
function
|
|
921
|
+
function xt(e) {
|
|
928
922
|
const { pool: n, state: t, options: i } = e, { logOptions: o } = i;
|
|
929
923
|
if (n)
|
|
930
924
|
return W(e);
|
|
931
925
|
let a = null;
|
|
932
|
-
for (; !R(e) && (a =
|
|
926
|
+
for (; !R(e) && (e.state.debugMode || (a = e.variantsIterator.next()), a != null); ) {
|
|
933
927
|
const r = ve(e);
|
|
934
|
-
if (M(r))
|
|
935
|
-
|
|
936
|
-
return r.then(() => W(e, u));
|
|
937
|
-
}
|
|
928
|
+
if (M(r))
|
|
929
|
+
return r.then(() => W(e, a));
|
|
938
930
|
if (R(e))
|
|
939
931
|
continue;
|
|
940
932
|
o.debug && K(e) && o.func(
|
|
@@ -946,8 +938,8 @@ function Mt(e) {
|
|
|
946
938
|
return l.then(() => W(e));
|
|
947
939
|
}
|
|
948
940
|
}
|
|
949
|
-
async function
|
|
950
|
-
const o =
|
|
941
|
+
async function Mt(e, n, t, i) {
|
|
942
|
+
const o = gt(i), {
|
|
951
943
|
store: a,
|
|
952
944
|
logOptions: r,
|
|
953
945
|
abortSignalExternal: l,
|
|
@@ -974,8 +966,8 @@ async function Tt(e, n, t, i) {
|
|
|
974
966
|
testOptions: L,
|
|
975
967
|
findBestErrorEnabled: !!u
|
|
976
968
|
});
|
|
977
|
-
const S = h <= 1 ? null : new
|
|
978
|
-
|
|
969
|
+
const S = h <= 1 ? null : new Ze(h);
|
|
970
|
+
vt(r, t.startMemory);
|
|
979
971
|
const I = {
|
|
980
972
|
options: o,
|
|
981
973
|
testRun: e,
|
|
@@ -990,24 +982,24 @@ async function Tt(e, n, t, i) {
|
|
|
990
982
|
};
|
|
991
983
|
be(I);
|
|
992
984
|
try {
|
|
993
|
-
await
|
|
985
|
+
await xt(I), E.throwIfAborted();
|
|
994
986
|
} catch (P) {
|
|
995
987
|
throw y.abort(new T()), P;
|
|
996
988
|
}
|
|
997
|
-
return b.throwIfAborted(), y.abort(new T()),
|
|
989
|
+
return b.throwIfAborted(), y.abort(new T()), Et(I), await ee(1), dt(t, n, f);
|
|
998
990
|
}
|
|
999
|
-
function
|
|
991
|
+
function Lt(e) {
|
|
1000
992
|
return function(t) {
|
|
1001
993
|
return async function(o) {
|
|
1002
|
-
const a = ge(o?.log), r =
|
|
994
|
+
const a = ge(o?.log), r = it(e, {
|
|
1003
995
|
onError: o?.onError,
|
|
1004
996
|
log: a,
|
|
1005
997
|
pauseDebuggerOnError: o?.pauseDebuggerOnError
|
|
1006
|
-
}), l = o?.timeController ?? Q, u = Y(), f =
|
|
998
|
+
}), l = o?.timeController ?? Q, u = Y(), f = rt(l, u), d = o?.onModeChange;
|
|
1007
999
|
function h(p) {
|
|
1008
1000
|
f.pendingModeChange = p, d?.(p);
|
|
1009
1001
|
}
|
|
1010
|
-
const y =
|
|
1002
|
+
const y = ft({
|
|
1011
1003
|
argsTemplates: t,
|
|
1012
1004
|
getSeed: o?.getSeed,
|
|
1013
1005
|
iterationModes: o?.iterationModes,
|
|
@@ -1020,10 +1012,10 @@ function Nt(e) {
|
|
|
1020
1012
|
limitTests: o?.limitTests,
|
|
1021
1013
|
limitTime: o?.limitTime
|
|
1022
1014
|
});
|
|
1023
|
-
return
|
|
1015
|
+
return Mt(r, y, f, o);
|
|
1024
1016
|
};
|
|
1025
1017
|
};
|
|
1026
1018
|
}
|
|
1027
1019
|
export {
|
|
1028
|
-
|
|
1020
|
+
Lt as c
|
|
1029
1021
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const ee=require("@flemist/time-controller"),k=require("@flemist/simple-utils"),E=require("@flemist/async-utils"),H=require("@flemist/abort-controller-fast"),J=require("@flemist/time-limits");function te(){if(typeof process<"u"&&process.memoryUsage)try{return process.memoryUsage().heapUsed}catch{}if(typeof performance<"u"){const e=performance.memory;if(e)try{return e.usedJSHeapSize}catch{}}return null}const
|
|
2
|
-
`)}globalThis.__getStressTestLogLast=
|
|
1
|
+
"use strict";const ee=require("@flemist/time-controller"),k=require("@flemist/simple-utils"),E=require("@flemist/async-utils"),H=require("@flemist/abort-controller-fast"),J=require("@flemist/time-limits");function te(){if(typeof process<"u"&&process.memoryUsage)try{return process.memoryUsage().heapUsed}catch{}if(typeof performance<"u"){const e=performance.memory;if(e)try{return e.usedJSHeapSize}catch{}}return null}const ze=1e3,_=[];function He(e){return k.formatAny(e,{pretty:!0,maxDepth:5,maxItems:50})}function Je(...e){const n=e.map(t=>typeof t=="string"?t:He(t)).join(" ");_.push(n),_.length>ze&&_.shift(),console.log(n)}function Xe(){return _.join(`
|
|
2
|
+
`)}globalThis.__getStressTestLogLast=Xe;const de=(e,n)=>{Je(n)},x={start:!0,progress:5e3,completed:!0,error:!0,modeChange:!0,debug:!1,func:de},Ze={start:!1,progress:!1,completed:!1,error:!1,modeChange:!1,debug:!1,func:de};function me(e){return e===!1?Ze:e===!0||!e?x:{start:e.start??x.start,progress:e.progress??x.progress,completed:e.completed??x.completed,error:e.error??x.error,modeChange:e.modeChange??x.modeChange,debug:e.debug??x.debug,func:e.func??x.func}}function Ke(e,n){const t=e.now();return{startTime:t,startMemory:n,debugMode:!1,tests:0,iterations:0,iterationsAsync:0,prevLogTime:t,prevLogMemory:n,pendingModeChange:null,prevGcTime:t,prevGcIterations:0,prevGcIterationsAsync:0}}class T extends H.AbortError{}const Qe=50,Ye=5;function le(e,n){return typeof e=="number"?{iterationsAsync:0,iterationsSync:e}:e!=null&&typeof e=="object"?e:n?{iterationsAsync:1,iterationsSync:0}:{iterationsAsync:0,iterationsSync:1}}function et(e,n){const t=n.log,o=n.pauseDebuggerOnError??!0;let i=null,l=0;function r(a,u,f){i==null&&(i={error:a,args:u,tests:f},t.error&&t.func("error",`[test-variants] error variant: ${k.formatAny(u,{pretty:!0})}
|
|
3
3
|
tests: ${f}
|
|
4
|
-
${k.formatAny(a)}`));const d=Date.now();if(o&&Function("debugger")(),Date.now()-d>Ye&&l<et){t.func("debug",`[test-variants] debug iteration: ${l}`),l++;return}const y=i;throw i=null,n.onError&&n.onError(y),y.error}return function(u,f,d){try{const h=e(u,d);return E.isPromiseLike(h)?h.then(y=>le(y,!0),y=>r(y,u,f)):le(h,!1)}catch(h){return h instanceof T?void 0:r(h,u,f)}}}function U(e,n,t){for(let o=0,i=e.length;o<i;o++)if(t?t(e[o],n):e[o]===n)return o;return-1}function ae(e,n,t,o){const i=Object.keys(e.templates),l={},r=[],a=[],u=[],f=i.length;for(let d=0;d<f;d++){const h=i[d];l[h]=void 0,r.push(-1),a.push(void 0),u.push(null)}return{args:l,argsNames:i,indexes:r,argValues:a,argLimits:u,attempts:0,templates:e,limitArgOnError:t,equals:n,includeErrorVariant:o??!1}}function O(e,n){const t=e.templates.templates[n],o=e.templates.extra[n];let i;if(typeof t=="function"?i=t(e.args):i=t,o==null)return i;let l=null;const r=o.length;for(let a=0;a<r;a++){const u=o[a];U(i,u,e.equals)<0&&(l==null?l=[...i,u]:l.push(u))}return l??i}function M(e,n,t){const o=e.argValues[n].length;if(o===0)return-1;const i=e.argLimits[n];if(i==null)return o-1;let l=e.limitArgOnError;if(typeof l=="function"){const r=e.argsNames[n];l=l({name:r,values:e.argValues[n],maxValueIndex:i})}return!t||l?Math.min(i,o-1):o-1}function V(e){const n=e.indexes.length;for(let t=0;t<n;t++){const o=e.argLimits[t];if(o==null)return!1;const i=e.indexes[t];if(i>o)return!0;if(i<o)return!1}return!e.includeErrorVariant}function C(e){const n=e.indexes.length;for(let t=0;t<n;t++)e.indexes[t]=-1,e.argValues[t]=void 0,e.args[e.argsNames[t]]=void 0}function ge(e){let n=!1,t=!0;const o=e.indexes.length;let i=o,l=!1,r=0;for(;r<o;r++){const a=e.argValues[r]==null;(a||l)&&(a&&(n=!0),e.argValues[r]=O(e,e.argsNames[r]));const u=M(e,r,r>i);if(u<0){t=!1,e.indexes[r]=-1;break}a&&(e.indexes[r]=0,e.args[e.argsNames[r]]=e.argValues[r][0]),(l||e.indexes[r]>u)&&(e.indexes[r]=u,e.args[e.argsNames[r]]=e.argValues[r][u],l=!0),i===o&&e.indexes[r]<u&&(i=r)}if(V(e))return C(e),!1;if(n&&t)return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let a=r>i;const u=M(e,r,a),f=e.indexes[r]+1;if(f<=u){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(a=!0);for(let d=r+1;d<o;d++)e.args[e.argsNames[d]]=void 0;for(r++;r<o;r++){e.argValues[r]=O(e,e.argsNames[r]);const d=M(e,r,a);if(d<0)break;e.indexes[r]=0,e.args[e.argsNames[r]]=e.argValues[r][0],d>0&&(a=!0)}if(r>=o)return V(e)?(C(e),!1):!0}}return C(e),!1}function X(e){V(e)&&C(e);let n=!1,t=!0;const o=e.indexes.length;let i=o,l=!1,r=0;for(;r<o;r++){const a=e.argValues[r]==null;(a||l)&&(a&&(n=!0),e.argValues[r]=O(e,e.argsNames[r]));const u=M(e,r,r>i);if(u<0){t=!1,e.indexes[r]=-1;break}a&&(e.indexes[r]=u,e.args[e.argsNames[r]]=e.argValues[r][u]),(l||e.indexes[r]>u)&&(e.indexes[r]=u,e.args[e.argsNames[r]]=e.argValues[r][u],l=!0),i===o&&e.indexes[r]<u&&(i=r)}if((n||l)&&t&&!V(e))return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let a=r>i;const u=M(e,r,a);let f=e.indexes[r]-1;if(f>u&&(f=u),f>=0){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(a=!0);for(let d=r+1;d<o;d++)e.args[e.argsNames[d]]=void 0;for(r++;r<o;r++){e.argValues[r]=O(e,e.argsNames[r]);const d=M(e,r,a);if(d<0)break;e.indexes[r]=d,e.args[e.argsNames[r]]=e.argValues[r][d],d>0&&(a=!0)}if(r>=o)return!0}}return C(e),!1}function rt(e,n){C(e);const t=e.argsNames,o=t.length;let i=!1;for(let l=0;l<o;l++){const r=t[l],a=n[r];if(a===void 0)return null;e.argValues[l]=O(e,r);const u=M(e,l,i);if(u<0)return null;const f=U(e.argValues[l],a,e.equals);if(f<0||f>u)return null;e.indexes[l]=f,e.args[e.argsNames[l]]=e.argValues[l][f],e.indexes[l]<u&&(i=!0)}return V(e)?null:e.indexes.slice()}function nt(e){const n=e.indexes.length;if(n===0)return!1;let t=!1;for(let o=0;o<n;o++){e.argValues[o]=O(e,e.argsNames[o]);const i=M(e,o,t);if(i<0)return Math.random()<.5?ge(e):X(e);e.indexes[o]=Math.floor(Math.random()*(i+1)),e.args[e.argsNames[o]]=e.argValues[o][e.indexes[o]],e.indexes[o]<i&&(t=!0)}return V(e)?X(e):!0}function D(e){return e.mode==="forward"||e.mode==="backward"}function it(e,n,t,o){const i=n[t],l=e.templates[t];if(typeof l!="function"){if(U(l,i,o)>=0)return;l.push(i);return}const r=e.extra[t];if(r==null){e.extra[t]=[i];return}U(r,i,o)>=0||r.push(i)}function ot(e,n,t){for(const o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(o==="seed")continue;it(e,n,o,t)}}function ue(e,n){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(t==="seed")continue;if(!e[t])return!1}return!0}const st=[{mode:"forward"}];function lt(e){const{argsTemplates:n,equals:t,limitArgOnError:o,includeErrorVariant:i,getSeed:l,iterationModes:r,onModeChange:a,limitCompletionCount:u,limitTests:f,limitTime:d}=e,h=e.timeController??ee.timeControllerDefault,y={templates:k.deepCloneJsonLike(n),extra:{}},p=r==null||r.length===0?st:r,b=[];let S=null,L=null,g=0,w=0,A=!1,N=0;function $(){A||(A=!0,N=h.now(),Ee(),g=0,ie(),we())}function Ee(){for(let s=0,c=p.length;s<c;s++)b.push(Se())}function Se(){return{navigationState:ae(y,t??null,o??null,i??null),cycleCount:0,completedCount:0,testsInLastTurn:0,tryNextVariantAttempts:0,startTime:null}}function we(){S=ae(y,t??null,!1,!1)}function ie(){a?.({mode:p[g],modeIndex:g,tests:w})}function xe(s){$(),ue(y.templates,s)&&ot(y,s,t)}function oe(s,c){return $(),ue(y.templates,s)?(S.limitArgOnError=c?.limitArg??o??null,S.includeErrorVariant=c?.includeLimit??i??!1,rt(S,s)):null}function Me(s){const c=s?.args;if(c==null)return;$();const m=oe(c);if(m!=null){L={args:c,error:s?.error,tests:s?.tests??w},S.argLimits=m;for(let v=0,q=b.length;v<q;v++){const W=b[v].navigationState;W.argLimits=m}}}function Te(){return $(),Ve()}function Ve(){for(;;){if(!Ae())return null;for(;;){const s=De();if(s!=null)return b[g].testsInLastTurn++,w++,s;if(Ne()){if(!$e())return null;qe();break}}}}function Ae(){return!(Ie()||Ce()||G()&&(Oe()||!Le())||!Pe())}function Ie(){return f!=null&&w>=f}function Ce(){return d!=null&&h.now()-N>=d}function Oe(){if(!G())throw new Error("Unexpected behavior");return u!=null&&u<=0}function Le(){if(!G())throw new Error("Unexpected behavior");for(let s=0,c=p.length;s<c;s++)if(I(p[s])&&F(s))return!0;return!1}function Pe(){for(let s=0,c=p.length;s<c;s++)if(F(s))return!0;return!1}function Ne(){g++;const s=g>=p.length;return s&&(g=0),ie(),s}function $e(){if(G()){const s=Ge();if(u!=null&&s>=u)return!1}return!0}function G(){for(let s=0,c=p.length;s<c;s++)if(D(p[s]))return!0;return!1}function Ge(){let s=!1,c=1/0;for(let m=0,v=b.length;m<v;m++){const q=b[m],W=p[m];D(W)&&(s=!0,F(m)&&q.completedCount<c&&(c=q.completedCount))}if(!s)throw new Error("Unexpected behavior");return c}function F(s){const c=p[s],m=b[s];return c.limitTests!=null&&c.limitTests<=0||I(c)&&(c.cycles!=null&&c.cycles<=0||c.attemptsPerVariant!=null&&c.attemptsPerVariant<=0)?!1:m.tryNextVariantAttempts<2}function qe(){g=0;for(let s=0,c=b.length;s<c;s++){const m=b[s];m.testsInLastTurn=0,m.startTime=null}}function De(){let s=0;for(;s<2;){if(!_e())return null;const c=Fe();if(c!=null)return c;if(I(p[g])&&Re())return null;s++}return null}function _e(){const s=p[g];return!(ke()||Ue()||I(s)&&!Be(g))}function ke(){const s=p[g],c=b[g];return s.limitTests!=null&&c.testsInLastTurn>=s.limitTests}function Ue(){const s=p[g],c=b[g];return s.limitTime!=null&&c.startTime!=null&&h.now()-c.startTime>=s.limitTime}function I(s){return D(s)}function Be(s){const c=p[s],m=b[s];if(!I(c))throw new Error("Unexpected behavior");return m.cycleCount<(c.cycles??1)}function Re(){const s=p[g],c=b[g];if(!I(s))throw new Error("Unexpected behavior");return c.cycleCount++,c.cycleCount>=(s.cycles??1)?(c.cycleCount=0,c.completedCount++,!0):!1}function Fe(){const s=p[g],c=b[g],m=c.navigationState;if(P(s)){if(j())return null;const v=je();if(v!=null)return c.startTime==null&&(c.startTime=h.now()),v}return ze()?(c.tryNextVariantAttempts=0,P(s)&&We(),c.startTime==null&&(c.startTime=h.now()),se(m.args)):(c.tryNextVariantAttempts++,null)}function je(){const s=p[g],m=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(j())throw new Error("Unexpected behavior");const v=s.attemptsPerVariant??1;return m.attempts>0&&m.attempts<v?V(m)?null:(m.attempts++,se(m.args)):null}function We(){const s=p[g],m=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(j())throw new Error("Unexpected behavior");m.attempts=1}function P(s){return D(s)}function j(){const s=p[g];if(!P(s))throw new Error("Unexpected behavior");return(s.attemptsPerVariant??1)<=0}function ze(){const s=p[g],m=b[g].navigationState;switch(s.mode){case"forward":return ge(m);case"backward":return X(m);case"random":return nt(m);default:throw new Error(`Unknown mode: ${s.mode}`)}}function se(s){const c={...s};return l!=null&&(c.seed=l({tests:w})),c}return{get limit(){return L},get modeIndex(){return g},get modeConfigs(){return p},get modeStates(){return b},get tests(){return w},calcIndexes:oe,extendTemplates:xe,addLimit:Me,next:Te}}function re(e){if(e==null||e<=0)throw new Error(`Iterations = ${e}`);e--;const n=E.waitMicrotasks().then(()=>e);return e<=0?n:n.then(re)}function at(e,n,t){const o=n.limit?{error:n.limit.error,args:n.limit.args,tests:n.limit.tests}:null;if(o&&!t)throw o.error;return{iterations:e.iterations,bestError:o}}const ce=2**31;function ut(e){if(e==null)return{parallel:1,sequentialOnError:!1};if(typeof e=="boolean")return{parallel:e?ce:1,sequentialOnError:!1};if(typeof e=="number")return{parallel:e>0?e:1,sequentialOnError:!1};const n=e.count;let t=1;return n===!0?t=ce:typeof n=="number"&&n>0&&(t=n),{parallel:t,sequentialOnError:e.sequentialOnError??!1}}function ct(e){const n=e?.saveErrorVariants,t=n&&e.createSaveErrorVariantsStore?e.createSaveErrorVariantsStore(n):null,o=e?.findBestError,{parallel:i,sequentialOnError:l}=ut(e?.parallel);return{store:t,GC_Iterations:e?.GC_Iterations??1e6,GC_IterationsAsync:e?.GC_IterationsAsync??1e4,GC_Interval:e?.GC_Interval??1e3,logOptions:me(e?.log),abortSignalExternal:e?.abortSignal,findBestError:o,dontThrowIfError:o?.dontThrowIfError,timeController:e?.timeController??ee.timeControllerDefault,parallel:i,sequentialOnError:l}}function B(e,n,t){const{options:o,variantsIterator:i}=e,l=i.limit?.args??n;if(!o.store)return;const r=o.store.save(l);if(t)return r}function ft(e,n,t,o){const{abortControllerParallel:i,state:l,options:r}=e,{logOptions:a}=r;if(e.options.findBestError)e.variantsIterator.addLimit({args:n,error:t,tests:o}),l.debugMode=!1,B(e,n,!1),r.sequentialOnError&&!i.signal.aborted?(a.debug&&a.func("debug","[test-variants] sequentialOnError: aborting parallel, switching to sequential"),i.abort(new T)):a.debug&&a.func("debug","[test-variants] parallel error in findBestError mode, continuing with new limits");else{if(i.signal.aborted)return;B(e,n,!1),i.abort(t)}}function fe(e,n,t,o){const{state:i}=e;if(e.options.findBestError){e.variantsIterator.addLimit({args:n,error:t,tests:o});const r=B(e,n,!0);if(r)return r.then(()=>{i.debugMode=!1});i.debugMode=!1;return}const l=B(e,n,!0);if(l)return l.then(()=>{throw t});throw t}function dt(e,n){const{GC_Iterations:t,GC_IterationsAsync:o,GC_Interval:i}=e.options;return t>0&&e.state.iterations-e.state.prevGcIterations>=t||o>0&&e.state.iterationsAsync-e.state.prevGcIterationsAsync>=o||i>0&&n-e.state.prevGcTime>=i}async function mt(e,n){e.prevGcIterations=e.iterations,e.prevGcIterationsAsync=e.iterationsAsync,e.prevGcTime=n,await re(1)}function ne(e){const n=e/1e3;if(n<60)return`${n.toFixed(1)}s`;const t=n/60;return t<60?`${t.toFixed(1)}m`:`${(t/60).toFixed(1)}h`}function Z(e){const n=e/1073741824;if(n>=1)return n>=10?`${Math.round(n)}GB`:`${n.toFixed(1)}GB`;const t=e/(1024*1024);return t>=10?`${Math.round(t)}MB`:`${t.toFixed(1)}MB`}function gt(e,n){if(!e)return`mode[${n}]: null`;let t=`mode[${n}]: ${e.mode}`;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=${ne(e.limitTime)}`),e.limitTests!=null&&(t+=`, limitTests=${e.limitTests}`),t}function pe(e,n){const t=e-n,o=t>=0?"+":"";return`${Z(e)} (${o}${Z(t)})`}function pt(e,n){if(!e.start)return;let t="[test-variants] start";n!=null&&(t+=`, memory: ${Z(n)}`),e.func("start",t)}function ht(e){const{options:n,state:t}=e,{logOptions:o,timeController:i}=n;if(!o.completed)return;const l=i.now()-t.startTime;let r=`[test-variants] end, tests: ${t.tests} (${ne(l)}), async: ${t.iterationsAsync}`;if(t.startMemory!=null){const a=te();a!=null&&(r+=`, memory: ${pe(a,t.startMemory)}`)}o.func("completed",r)}function he(e){const{options:n,state:t}=e,{logOptions:o}=n,i=t.pendingModeChange;!o.modeChange||i==null||(o.func("modeChange",`[test-variants] ${gt(i.mode,i.modeIndex)}`),t.pendingModeChange=null)}function bt(e){const{options:n,state:t}=e,{logOptions:o,timeController:i}=n,l=i.now();if(!o.progress||l-t.prevLogTime<o.progress)return!1;he(e);const r=l-t.startTime;let a=`[test-variants] tests: ${t.tests} (${ne(r)}), async: ${t.iterationsAsync}`;if(t.prevLogMemory!=null){const u=te();u!=null&&(a+=`, memory: ${pe(u,t.prevLogMemory)}`,t.prevLogMemory=u)}return o.func("progress",a),t.prevLogTime=l,!0}function K(e,n){e.debugMode=!1,n&&(e.iterationsAsync+=n.iterationsAsync,e.iterations+=n.iterationsSync+n.iterationsAsync)}function Q(e){e.state.debugMode=!0,e.abortControllerParallel.abort(new T)}function be(e,n){const{testRun:t,testOptions:o,state:i}=e,l=i.tests;i.tests++;try{const r=t(n,l,o);if(E.isPromiseLike(r))return r.then(a=>{if(!a){Q(e);return}K(i,a)},a=>fe(e,n,a,l));if(!r){Q(e);return}K(i,r)}catch(r){return r instanceof T?void 0:fe(e,n,r,l)}}function yt(e,n){const{pool:t,abortSignal:o,testRun:i,testOptionsParallel:l,state:r}=e;if(!t)return;const a=r.tests;r.tests++,(async()=>{try{if(o.aborted)return;let u=i(n,a,l);if(E.isPromiseLike(u)&&(u=await u),!u){Q(e);return}K(r,u)}catch(u){if(u instanceof T)return;ft(e,n,u,a)}finally{t.release(1)}})()}function ye(e){const{options:n,state:t}=e,{logOptions:o,timeController:i,GC_Interval:l}=n;if(!o.progress&&!l)return;bt(e);const r=i.now();if(dt(e,r))return mt(t,r)}function R(e){return e.options.abortSignalExternal?.aborted??!1}function Y(e){return e.abortSignal.aborted}function ve(e,n){return e.state.debugMode?n:e.variantsIterator.next()}async function z(e,n){const{pool:t,state:o,options:i}=e,{parallel:l,logOptions:r}=i;let a=n??null;for(;!R(e);){const u=t&&!Y(e);let f=!1;u&&(t.hold(1)||await J.poolWait({pool:t,count:1,hold:!0}),f=!0);try{if(a==null&&(a=ve(e,a),a==null))break;const d=ye(e);if(E.isPromiseLike(d)&&await d,R(e)){a=null;continue}if(u)yt(e,a),f=!1;else{r.debug&&t&&Y(e)&&r.func("debug",`[test-variants] parallel aborted, running sequential: tests=${o.tests}`);const h=be(e,a);E.isPromiseLike(h)&&await h}a=null}finally{f&&t.release(1)}}t&&(await J.poolWait({pool:t,count:l,hold:!0}),t.release(l))}function vt(e){const{pool:n,state:t,options:o}=e,{logOptions:i}=o;if(n)return z(e);let l=null;for(;!R(e)&&(l=ve(e,l),l!=null);){const r=ye(e);if(E.isPromiseLike(r)){const u=l;return r.then(()=>z(e,u))}if(R(e))continue;i.debug&&Y(e)&&i.func("debug",`[test-variants] parallel aborted, running sequential: tests=${t.tests}`);const a=be(e,l);if(E.isPromiseLike(a))return a.then(()=>z(e))}}async function Et(e,n,t,o){const i=ct(o),{store:l,logOptions:r,abortSignalExternal:a,findBestError:u,dontThrowIfError:f,timeController:d,parallel:h}=i,y=new H.AbortControllerFast,p=new H.AbortControllerFast,b=E.combineAbortSignals(a,y.signal),S=E.combineAbortSignals(b,p.signal),L={abortSignal:b,timeController:d},g={abortSignal:S,timeController:d};l&&await l.replay({testRun:e,variantsIterator:n,testOptions:L,findBestErrorEnabled:!!u});const w=h<=1?null:new J.Pool(h);pt(r,t.startMemory);const A={options:i,testRun:e,variantsIterator:n,testOptions:L,testOptionsParallel:g,abortControllerGlobal:y,abortControllerParallel:p,abortSignal:S,pool:w,state:t};he(A);try{await vt(A),S.throwIfAborted()}catch(N){throw y.abort(new T),N}return b.throwIfAborted(),y.abort(new T),ht(A),await re(1),at(t,n,f)}function St(e){return function(t){return async function(i){const l=me(i?.log),r=tt(e,{onError:i?.onError,log:l,pauseDebuggerOnError:i?.pauseDebuggerOnError}),a=i?.timeController??ee.timeControllerDefault,u=te(),f=Qe(a,u),d=i?.onModeChange;function h(p){f.pendingModeChange=p,d?.(p)}const y=lt({argsTemplates:t,getSeed:i?.getSeed,iterationModes:i?.iterationModes,equals:i?.findBestError?.equals,limitArgOnError:i?.findBestError?.limitArgOnError,includeErrorVariant:i?.findBestError?.includeErrorVariant,timeController:a,onModeChange:h,limitCompletionCount:i?.cycles??1,limitTests:i?.limitTests,limitTime:i?.limitTime});return Et(r,y,f,i)}}}exports.createTestVariants=St;
|
|
4
|
+
${k.formatAny(a)}`));const d=Date.now();if(o&&Function("debugger")(),Date.now()-d>Qe&&l<Ye){t.func("debug",`[test-variants] debug iteration: ${l}`),l++;return}const y=i;throw i=null,n.onError&&n.onError(y),y.error}return function(u,f,d){try{const h=e(u,d);return E.isPromiseLike(h)?h.then(y=>le(y,!0),y=>r(y,u,f)):le(h,!1)}catch(h){return h instanceof T?void 0:r(h,u,f)}}}function U(e,n,t){for(let o=0,i=e.length;o<i;o++)if(t?t(e[o],n):e[o]===n)return o;return-1}function ae(e,n,t,o){const i=Object.keys(e.templates),l={},r=[],a=[],u=[],f=i.length;for(let d=0;d<f;d++){const h=i[d];l[h]=void 0,r.push(-1),a.push(void 0),u.push(null)}return{args:l,argsNames:i,indexes:r,argValues:a,argLimits:u,attempts:0,templates:e,limitArgOnError:t,equals:n,includeErrorVariant:o??!1}}function O(e,n){const t=e.templates.templates[n],o=e.templates.extra[n];let i;if(typeof t=="function"?i=t(e.args):i=t,o==null)return i;let l=null;const r=o.length;for(let a=0;a<r;a++){const u=o[a];U(i,u,e.equals)<0&&(l==null?l=[...i,u]:l.push(u))}return l??i}function M(e,n,t){const o=e.argValues[n].length;if(o===0)return-1;const i=e.argLimits[n];if(i==null)return o-1;let l=e.limitArgOnError;if(typeof l=="function"){const r=e.argsNames[n];l=l({name:r,values:e.argValues[n],maxValueIndex:i})}return!t||l?Math.min(i,o-1):o-1}function V(e){const n=e.indexes.length;for(let t=0;t<n;t++){const o=e.argLimits[t];if(o==null)return!1;const i=e.indexes[t];if(i>o)return!0;if(i<o)return!1}return!e.includeErrorVariant}function C(e){const n=e.indexes.length;for(let t=0;t<n;t++)e.indexes[t]=-1,e.argValues[t]=void 0,e.args[e.argsNames[t]]=void 0}function ge(e){let n=!1,t=!0;const o=e.indexes.length;let i=o,l=!1,r=0;for(;r<o;r++){const a=e.argValues[r]==null;(a||l)&&(a&&(n=!0),e.argValues[r]=O(e,e.argsNames[r]));const u=M(e,r,r>i);if(u<0){t=!1,e.indexes[r]=-1;break}a&&(e.indexes[r]=0,e.args[e.argsNames[r]]=e.argValues[r][0]),(l||e.indexes[r]>u)&&(e.indexes[r]=u,e.args[e.argsNames[r]]=e.argValues[r][u],l=!0),i===o&&e.indexes[r]<u&&(i=r)}if(V(e))return C(e),!1;if(n&&t)return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let a=r>i;const u=M(e,r,a),f=e.indexes[r]+1;if(f<=u){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(a=!0);for(let d=r+1;d<o;d++)e.args[e.argsNames[d]]=void 0;for(r++;r<o;r++){e.argValues[r]=O(e,e.argsNames[r]);const d=M(e,r,a);if(d<0)break;e.indexes[r]=0,e.args[e.argsNames[r]]=e.argValues[r][0],d>0&&(a=!0)}if(r>=o)return V(e)?(C(e),!1):!0}}return C(e),!1}function X(e){V(e)&&C(e);let n=!1,t=!0;const o=e.indexes.length;let i=o,l=!1,r=0;for(;r<o;r++){const a=e.argValues[r]==null;(a||l)&&(a&&(n=!0),e.argValues[r]=O(e,e.argsNames[r]));const u=M(e,r,r>i);if(u<0){t=!1,e.indexes[r]=-1;break}a&&(e.indexes[r]=u,e.args[e.argsNames[r]]=e.argValues[r][u]),(l||e.indexes[r]>u)&&(e.indexes[r]=u,e.args[e.argsNames[r]]=e.argValues[r][u],l=!0),i===o&&e.indexes[r]<u&&(i=r)}if((n||l)&&t&&!V(e))return!0;for(r--;r>=0;r--){if(e.argValues[r]==null)continue;let a=r>i;const u=M(e,r,a);let f=e.indexes[r]-1;if(f>u&&(f=u),f>=0){e.indexes[r]=f,e.args[e.argsNames[r]]=e.argValues[r][f],f<u&&(a=!0);for(let d=r+1;d<o;d++)e.args[e.argsNames[d]]=void 0;for(r++;r<o;r++){e.argValues[r]=O(e,e.argsNames[r]);const d=M(e,r,a);if(d<0)break;e.indexes[r]=d,e.args[e.argsNames[r]]=e.argValues[r][d],d>0&&(a=!0)}if(r>=o)return!0}}return C(e),!1}function tt(e,n){C(e);const t=e.argsNames,o=t.length;let i=!1;for(let l=0;l<o;l++){const r=t[l],a=n[r];if(a===void 0)return null;e.argValues[l]=O(e,r);const u=M(e,l,i);if(u<0)return null;const f=U(e.argValues[l],a,e.equals);if(f<0||f>u)return null;e.indexes[l]=f,e.args[e.argsNames[l]]=e.argValues[l][f],e.indexes[l]<u&&(i=!0)}return V(e)?null:e.indexes.slice()}function rt(e){const n=e.indexes.length;if(n===0)return!1;let t=!1;for(let o=0;o<n;o++){e.argValues[o]=O(e,e.argsNames[o]);const i=M(e,o,t);if(i<0)return Math.random()<.5?ge(e):X(e);e.indexes[o]=Math.floor(Math.random()*(i+1)),e.args[e.argsNames[o]]=e.argValues[o][e.indexes[o]],e.indexes[o]<i&&(t=!0)}return V(e)?X(e):!0}function D(e){return e.mode==="forward"||e.mode==="backward"}function nt(e,n,t,o){const i=n[t],l=e.templates[t];if(typeof l!="function"){if(U(l,i,o)>=0)return;l.push(i);return}const r=e.extra[t];if(r==null){e.extra[t]=[i];return}U(r,i,o)>=0||r.push(i)}function it(e,n,t){for(const o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(o==="seed")continue;nt(e,n,o,t)}}function ue(e,n){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(t==="seed")continue;if(!e[t])return!1}return!0}const ot=[{mode:"forward"}];function st(e){const{argsTemplates:n,equals:t,limitArgOnError:o,includeErrorVariant:i,getSeed:l,iterationModes:r,onModeChange:a,limitCompletionCount:u,limitTests:f,limitTime:d}=e,h=e.timeController??ee.timeControllerDefault,y={templates:k.deepCloneJsonLike(n),extra:{}},p=r==null||r.length===0?ot:r,b=[];let S=null,L=null,g=0,w=0,I=!1,N=0;function $(){I||(I=!0,N=h.now(),ve(),g=0,ie(),Se())}function ve(){for(let s=0,c=p.length;s<c;s++)b.push(Ee())}function Ee(){return{navigationState:ae(y,t??null,o??null,i??null),cycleCount:0,completedCount:0,testsInLastTurn:0,tryNextVariantAttempts:0,startTime:null}}function Se(){S=ae(y,t??null,!1,!1)}function ie(){a?.({mode:p[g],modeIndex:g,tests:w})}function we(s){$(),ue(y.templates,s)&&it(y,s,t)}function oe(s,c){return $(),ue(y.templates,s)?(S.limitArgOnError=c?.limitArg??o??null,S.includeErrorVariant=c?.includeLimit??i??!1,tt(S,s)):null}function xe(s){const c=s?.args;if(c==null)return;$();const m=oe(c);if(m!=null){L={args:c,error:s?.error,tests:s?.tests??w},S.argLimits=m;for(let v=0,q=b.length;v<q;v++){const W=b[v].navigationState;W.argLimits=m}}}function Me(){return $(),Te()}function Te(){for(;;){if(!Ve())return null;for(;;){const s=qe();if(s!=null)return b[g].testsInLastTurn++,w++,s;if(Pe()){if(!Ne())return null;Ge();break}}}}function Ve(){return!(Ie()||Ae()||G()&&(Ce()||!Oe())||!Le())}function Ie(){return f!=null&&w>=f}function Ae(){return d!=null&&h.now()-N>=d}function Ce(){if(!G())throw new Error("Unexpected behavior");return u!=null&&u<=0}function Oe(){if(!G())throw new Error("Unexpected behavior");for(let s=0,c=p.length;s<c;s++)if(A(p[s])&&F(s))return!0;return!1}function Le(){for(let s=0,c=p.length;s<c;s++)if(F(s))return!0;return!1}function Pe(){g++;const s=g>=p.length;return s&&(g=0),ie(),s}function Ne(){if(G()){const s=$e();if(u!=null&&s>=u)return!1}return!0}function G(){for(let s=0,c=p.length;s<c;s++)if(D(p[s]))return!0;return!1}function $e(){let s=!1,c=1/0;for(let m=0,v=b.length;m<v;m++){const q=b[m],W=p[m];D(W)&&(s=!0,F(m)&&q.completedCount<c&&(c=q.completedCount))}if(!s)throw new Error("Unexpected behavior");return c}function F(s){const c=p[s],m=b[s];return c.limitTests!=null&&c.limitTests<=0||A(c)&&(c.cycles!=null&&c.cycles<=0||c.attemptsPerVariant!=null&&c.attemptsPerVariant<=0)?!1:m.tryNextVariantAttempts<2}function Ge(){g=0;for(let s=0,c=b.length;s<c;s++){const m=b[s];m.testsInLastTurn=0,m.startTime=null}}function qe(){let s=0;for(;s<2;){if(!De())return null;const c=Re();if(c!=null)return c;if(A(p[g])&&Be())return null;s++}return null}function De(){const s=p[g];return!(_e()||ke()||A(s)&&!Ue(g))}function _e(){const s=p[g],c=b[g];return s.limitTests!=null&&c.testsInLastTurn>=s.limitTests}function ke(){const s=p[g],c=b[g];return s.limitTime!=null&&c.startTime!=null&&h.now()-c.startTime>=s.limitTime}function A(s){return D(s)}function Ue(s){const c=p[s],m=b[s];if(!A(c))throw new Error("Unexpected behavior");return m.cycleCount<(c.cycles??1)}function Be(){const s=p[g],c=b[g];if(!A(s))throw new Error("Unexpected behavior");return c.cycleCount++,c.cycleCount>=(s.cycles??1)?(c.cycleCount=0,c.completedCount++,!0):!1}function Re(){const s=p[g],c=b[g],m=c.navigationState;if(P(s)){if(j())return null;const v=Fe();if(v!=null)return c.startTime==null&&(c.startTime=h.now()),v}return We()?(c.tryNextVariantAttempts=0,P(s)&&je(),c.startTime==null&&(c.startTime=h.now()),se(m.args)):(c.tryNextVariantAttempts++,null)}function Fe(){const s=p[g],m=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(j())throw new Error("Unexpected behavior");const v=s.attemptsPerVariant??1;return m.attempts>0&&m.attempts<v?V(m)?null:(m.attempts++,se(m.args)):null}function je(){const s=p[g],m=b[g].navigationState;if(!P(s))throw new Error("Unexpected behavior");if(j())throw new Error("Unexpected behavior");m.attempts=1}function P(s){return D(s)}function j(){const s=p[g];if(!P(s))throw new Error("Unexpected behavior");return(s.attemptsPerVariant??1)<=0}function We(){const s=p[g],m=b[g].navigationState;switch(s.mode){case"forward":return ge(m);case"backward":return X(m);case"random":return rt(m);default:throw new Error(`Unknown mode: ${s.mode}`)}}function se(s){const c={...s};return l!=null&&(c.seed=l({tests:w})),c}return{get limit(){return L},get modeIndex(){return g},get modeConfigs(){return p},get modeStates(){return b},get tests(){return w},calcIndexes:oe,extendTemplates:we,addLimit:xe,next:Me}}function re(e){if(e==null||e<=0)throw new Error(`Iterations = ${e}`);e--;const n=E.waitMicrotasks().then(()=>e);return e<=0?n:n.then(re)}function lt(e,n,t){const o=n.limit?{error:n.limit.error,args:n.limit.args,tests:n.limit.tests}:null;if(o&&!t)throw o.error;return{iterations:e.iterations,bestError:o}}const ce=2**31;function at(e){if(e==null)return{parallel:1,sequentialOnError:!1};if(typeof e=="boolean")return{parallel:e?ce:1,sequentialOnError:!1};if(typeof e=="number")return{parallel:e>0?e:1,sequentialOnError:!1};const n=e.count;let t=1;return n===!0?t=ce:typeof n=="number"&&n>0&&(t=n),{parallel:t,sequentialOnError:e.sequentialOnError??!1}}function ut(e){const n=e?.saveErrorVariants,t=n&&e.createSaveErrorVariantsStore?e.createSaveErrorVariantsStore(n):null,o=e?.findBestError,{parallel:i,sequentialOnError:l}=at(e?.parallel);return{store:t,GC_Iterations:e?.GC_Iterations??1e6,GC_IterationsAsync:e?.GC_IterationsAsync??1e4,GC_Interval:e?.GC_Interval??1e3,logOptions:me(e?.log),abortSignalExternal:e?.abortSignal,findBestError:o,dontThrowIfError:o?.dontThrowIfError,timeController:e?.timeController??ee.timeControllerDefault,parallel:i,sequentialOnError:l}}function B(e,n,t){const{options:o,variantsIterator:i}=e,l=i.limit?.args??n;if(!o.store)return;const r=o.store.save(l);if(t)return r}function ct(e,n,t,o){const{abortControllerParallel:i,state:l,options:r}=e,{logOptions:a}=r;if(e.options.findBestError)e.variantsIterator.addLimit({args:n,error:t,tests:o}),l.debugMode=!1,B(e,n,!1),r.sequentialOnError&&!i.signal.aborted?(a.debug&&a.func("debug","[test-variants] sequentialOnError: aborting parallel, switching to sequential"),i.abort(new T)):a.debug&&a.func("debug","[test-variants] parallel error in findBestError mode, continuing with new limits");else{if(i.signal.aborted)return;B(e,n,!1),i.abort(t)}}function fe(e,n,t,o){const{state:i}=e;if(e.options.findBestError){e.variantsIterator.addLimit({args:n,error:t,tests:o});const r=B(e,n,!0);if(r)return r.then(()=>{i.debugMode=!1});i.debugMode=!1;return}const l=B(e,n,!0);if(l)return l.then(()=>{throw t});throw t}function ft(e,n){const{GC_Iterations:t,GC_IterationsAsync:o,GC_Interval:i}=e.options;return t>0&&e.state.iterations-e.state.prevGcIterations>=t||o>0&&e.state.iterationsAsync-e.state.prevGcIterationsAsync>=o||i>0&&n-e.state.prevGcTime>=i}async function dt(e,n){e.prevGcIterations=e.iterations,e.prevGcIterationsAsync=e.iterationsAsync,e.prevGcTime=n,await re(1)}function ne(e){const n=e/1e3;if(n<60)return`${n.toFixed(1)}s`;const t=n/60;return t<60?`${t.toFixed(1)}m`:`${(t/60).toFixed(1)}h`}function Z(e){const n=e/1073741824;if(n>=1)return n>=10?`${Math.round(n)}GB`:`${n.toFixed(1)}GB`;const t=e/(1024*1024);return t>=10?`${Math.round(t)}MB`:`${t.toFixed(1)}MB`}function mt(e,n){if(!e)return`mode[${n}]: null`;let t=`mode[${n}]: ${e.mode}`;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=${ne(e.limitTime)}`),e.limitTests!=null&&(t+=`, limitTests=${e.limitTests}`),t}function pe(e,n){const t=e-n,o=t>=0?"+":"";return`${Z(e)} (${o}${Z(t)})`}function gt(e,n){if(!e.start)return;let t="[test-variants] start";n!=null&&(t+=`, memory: ${Z(n)}`),e.func("start",t)}function pt(e){const{options:n,state:t}=e,{logOptions:o,timeController:i}=n;if(!o.completed)return;const l=i.now()-t.startTime;let r=`[test-variants] end, tests: ${t.tests} (${ne(l)}), async: ${t.iterationsAsync}`;if(t.startMemory!=null){const a=te();a!=null&&(r+=`, memory: ${pe(a,t.startMemory)}`)}o.func("completed",r)}function he(e){const{options:n,state:t}=e,{logOptions:o}=n,i=t.pendingModeChange;!o.modeChange||i==null||(o.func("modeChange",`[test-variants] ${mt(i.mode,i.modeIndex)}`),t.pendingModeChange=null)}function ht(e){const{options:n,state:t}=e,{logOptions:o,timeController:i}=n,l=i.now();if(!o.progress||l-t.prevLogTime<o.progress)return!1;he(e);const r=l-t.startTime;let a=`[test-variants] tests: ${t.tests} (${ne(r)}), async: ${t.iterationsAsync}`;if(t.prevLogMemory!=null){const u=te();u!=null&&(a+=`, memory: ${pe(u,t.prevLogMemory)}`,t.prevLogMemory=u)}return o.func("progress",a),t.prevLogTime=l,!0}function K(e,n){e.debugMode=!1,n&&(e.iterationsAsync+=n.iterationsAsync,e.iterations+=n.iterationsSync+n.iterationsAsync)}function Q(e){e.state.debugMode=!0,e.abortControllerParallel.abort(new T)}function be(e,n){const{testRun:t,testOptions:o,state:i}=e,l=i.tests;i.tests++;try{const r=t(n,l,o);if(E.isPromiseLike(r))return r.then(a=>{if(!a){Q(e);return}K(i,a)},a=>fe(e,n,a,l));if(!r){Q(e);return}K(i,r)}catch(r){return r instanceof T?void 0:fe(e,n,r,l)}}function bt(e,n){const{pool:t,abortSignal:o,testRun:i,testOptionsParallel:l,state:r}=e;if(!t)return;const a=r.tests;r.tests++,(async()=>{try{if(o.aborted)return;let u=i(n,a,l);if(E.isPromiseLike(u)&&(u=await u),!u){Q(e);return}K(r,u)}catch(u){if(u instanceof T)return;ct(e,n,u,a)}finally{t.release(1)}})()}function ye(e){const{options:n,state:t}=e,{logOptions:o,timeController:i,GC_Interval:l}=n;if(!o.progress&&!l)return;ht(e);const r=i.now();if(ft(e,r))return dt(t,r)}function R(e){return e.options.abortSignalExternal?.aborted??!1}function Y(e){return e.abortSignal.aborted}async function z(e,n){const{pool:t,state:o,options:i}=e,{parallel:l,logOptions:r}=i;let a=null;for(;!R(e);){const u=t&&!Y(e);let f=!1;u&&(t.hold(1)||await J.poolWait({pool:t,count:1,hold:!0}),f=!0);try{if(n!=null?(a=n,n=null):e.state.debugMode||(a=e.variantsIterator.next()),a==null)break;const d=ye(e);if(E.isPromiseLike(d)&&await d,R(e))continue;if(u)bt(e,a),f=!1;else{r.debug&&t&&Y(e)&&r.func("debug",`[test-variants] parallel aborted, running sequential: tests=${o.tests}`);const h=be(e,a);E.isPromiseLike(h)&&await h}}finally{f&&t.release(1)}}t&&(await J.poolWait({pool:t,count:l,hold:!0}),t.release(l))}function yt(e){const{pool:n,state:t,options:o}=e,{logOptions:i}=o;if(n)return z(e);let l=null;for(;!R(e)&&(e.state.debugMode||(l=e.variantsIterator.next()),l!=null);){const r=ye(e);if(E.isPromiseLike(r))return r.then(()=>z(e,l));if(R(e))continue;i.debug&&Y(e)&&i.func("debug",`[test-variants] parallel aborted, running sequential: tests=${t.tests}`);const a=be(e,l);if(E.isPromiseLike(a))return a.then(()=>z(e))}}async function vt(e,n,t,o){const i=ut(o),{store:l,logOptions:r,abortSignalExternal:a,findBestError:u,dontThrowIfError:f,timeController:d,parallel:h}=i,y=new H.AbortControllerFast,p=new H.AbortControllerFast,b=E.combineAbortSignals(a,y.signal),S=E.combineAbortSignals(b,p.signal),L={abortSignal:b,timeController:d},g={abortSignal:S,timeController:d};l&&await l.replay({testRun:e,variantsIterator:n,testOptions:L,findBestErrorEnabled:!!u});const w=h<=1?null:new J.Pool(h);gt(r,t.startMemory);const I={options:i,testRun:e,variantsIterator:n,testOptions:L,testOptionsParallel:g,abortControllerGlobal:y,abortControllerParallel:p,abortSignal:S,pool:w,state:t};he(I);try{await yt(I),S.throwIfAborted()}catch(N){throw y.abort(new T),N}return b.throwIfAborted(),y.abort(new T),pt(I),await re(1),lt(t,n,f)}function Et(e){return function(t){return async function(i){const l=me(i?.log),r=et(e,{onError:i?.onError,log:l,pauseDebuggerOnError:i?.pauseDebuggerOnError}),a=i?.timeController??ee.timeControllerDefault,u=te(),f=Ke(a,u),d=i?.onModeChange;function h(p){f.pendingModeChange=p,d?.(p)}const y=st({argsTemplates:t,getSeed:i?.getSeed,iterationModes:i?.iterationModes,equals:i?.findBestError?.equals,limitArgOnError:i?.findBestError?.limitArgOnError,includeErrorVariant:i?.findBestError?.includeErrorVariant,timeController:a,onModeChange:h,limitCompletionCount:i?.cycles??1,limitTests:i?.limitTests,limitTime:i?.limitTime});return vt(r,y,f,i)}}}exports.createTestVariants=Et;
|
package/build/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("../createTestVariants-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("../createTestVariants-BYmqvvhv.js"),F=require("path"),O=require("@flemist/async-utils"),y=require("@flemist/simple-utils"),x=require("@flemist/simple-utils/node"),P=require("fs");function v(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const m=v(F),u=v(P);async function b(e){const t=await u.promises.stat(e).catch(()=>null);if(t==null)return[];if(!t.isDirectory())throw new Error(`[saveErrorVariants] path is not a directory: ${e}`);return(await u.promises.readdir(e)).filter(n=>n.endsWith(".json")).sort((n,a)=>n>a?-1:n<a?1:0).map(n=>m.join(e,n))}async function A(e,t){const s=await u.promises.readFile(e,"utf-8");let r;try{r=JSON.parse(s)}catch{throw new Error(`[saveErrorVariants] invalid JSON in file: ${e}`)}if(t)try{return t(r)}catch{throw new Error(`[saveErrorVariants] jsonToArgs failed for file: ${e}`)}return r}function q(e){const t=Math.random().toString(36).substring(2);return y.formatDateFileName(e.sessionDate,"UTC")+"_"+t+".json"}async function D(e,t,s){let r;if(s){const n=s(e);typeof n=="string"?r=n:r=JSON.stringify(n,null,2)}else r=JSON.stringify(e,null,2);await u.promises.mkdir(m.dirname(t),{recursive:!0}),await u.promises.writeFile(t,r,"utf-8")}function L(e,t){const s=Math.max(e.length,t.length);for(let r=0;r<s;r++){const n=e[r],a=t[r];if(n==null){if(a==null)continue;return 1}if(a==null||n<a)return-1;if(n>a)return 1}return 0}class N{options;filePath;lastSavedArgs=null;constructor(t){this.options=t;const s=new Date;this.filePath=m.resolve(t.dir,t.getFilePath?.({sessionDate:s})??q({sessionDate:s}))}async save(t){y.deepEqualJsonLike(t,this.lastSavedArgs)||(this.lastSavedArgs={...t},await x.fileLock({filePath:this.filePath,func:()=>D(t,this.filePath,this.options.argsToJson)}))}async replay(t){const{testRun:s,variantsIterator:r,testOptions:n,findBestErrorEnabled:a}=t,h=this.options.useToFindBestError,E=this.options.limitArg??!1,V=this.options.extendTemplates??!1,S=this.options.attemptsPerVariant??1,g=new Map;function d(i){let o=g.get(i);return o===void 0&&(o=r.calcIndexes(i,{includeLimit:!1,limitArg:E}),g.set(i,o)),o}const w=await b(this.options.dir),f=[];for(let i=0,o=w.length;i<o;i++){const p=w[i],c=await A(p,this.options.jsonToArgs);V&&r.extendTemplates(c),d(c)!=null&&f.push(c)}function T(i,o){return L(d(i),d(o))}f.sort(T);for(let i=0,o=f.length;i<o;i++){const p=f[i];for(let c=0;c<S;c++)try{const l=s(p,0,n);O.isPromiseLike(l)&&await l}catch(l){if(h&&a){r.addLimit({args:p,error:l});break}throw l}}}}function k(e){return new N(e)}function _(e){const t=j.createTestVariants(e);return function(r){const n=t(r);return function(h){return n({...h,createSaveErrorVariantsStore:k})}}}exports.createTestVariants=_;
|
package/build/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as x } from "../createTestVariants-
|
|
1
|
+
import { c as x } from "../createTestVariants-BXmWQaT8.mjs";
|
|
2
2
|
import * as d from "path";
|
|
3
3
|
import { isPromiseLike as F } from "@flemist/async-utils";
|
|
4
4
|
import { formatDateFileName as S, deepEqualJsonLike as A } from "@flemist/simple-utils";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemist/test-variants",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"description": "Runs a test function with all possible combinations of its parameters.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"types": "build/common/index.d.ts",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"default": "./src/common/index.ts"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
|
+
"packageManager": "pnpm@10.18.3",
|
|
45
46
|
"engines": {
|
|
46
47
|
"node": ">=20"
|
|
47
48
|
},
|
|
@@ -76,6 +77,38 @@
|
|
|
76
77
|
"publishConfig": {
|
|
77
78
|
"access": "public"
|
|
78
79
|
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"========================= install =========================": "",
|
|
82
|
+
"_prepublishOnly": "run-p audit lint build test:all && npm login",
|
|
83
|
+
"prepare": "node .husky/install.mjs",
|
|
84
|
+
"install:playwright": "pnpm exec playwright install --with-deps",
|
|
85
|
+
"========================= deploy =========================": "",
|
|
86
|
+
"build": "vite build",
|
|
87
|
+
"========================= lint =========================": "",
|
|
88
|
+
"audit": "pnpm audit --prod",
|
|
89
|
+
"lint:es": "eslint .",
|
|
90
|
+
"lint:es:fix": "eslint --fix .",
|
|
91
|
+
"lint": "run-p lint:es",
|
|
92
|
+
"lint:fix": "run-s lint:es:fix",
|
|
93
|
+
"lint-staged": "lint-staged",
|
|
94
|
+
"check:types": "tsc --noEmit",
|
|
95
|
+
"check": "run-p audit check:types lint",
|
|
96
|
+
"========================= test =========================": "",
|
|
97
|
+
"test:node": "vitest --run --config vite.projects.ts --project node --bail 3",
|
|
98
|
+
"test:browser": "vitest --run --config vite.projects.ts --project browser --bail 3",
|
|
99
|
+
"test:chrome": "vitest --run --config vite.projects.ts --project browser --browser chromium --bail 3",
|
|
100
|
+
"test:all": "vitest --run --config vite.projects.ts --bail 3",
|
|
101
|
+
"test": "run-s test:node test:browser",
|
|
102
|
+
"========================= dev =========================": "",
|
|
103
|
+
"kill-node": "taskkill /F /IM node.exe",
|
|
104
|
+
"kill-java": "taskkill /F /IM java.exe",
|
|
105
|
+
"kill-chrome": "taskkill /F /IM chrome.exe",
|
|
106
|
+
"========================= mcp =========================": "",
|
|
107
|
+
"mcp:playwright": "mcp-server-playwright --port 8002 --host local.host --isolated",
|
|
108
|
+
"========================= other =========================": "",
|
|
109
|
+
"mcp:tools": "mcp-project-tools",
|
|
110
|
+
"dep:fix": "tsx tools/dep-fix.ts"
|
|
111
|
+
},
|
|
79
112
|
"devDependencies": {
|
|
80
113
|
"@eslint/compat": "1.2.4",
|
|
81
114
|
"@eslint/eslintrc": "3.2.0",
|
|
@@ -115,35 +148,5 @@
|
|
|
115
148
|
"@flemist/time-controller": "^1.0.4",
|
|
116
149
|
"@flemist/time-limits": "^2.0.4",
|
|
117
150
|
"tslib": ">=2.8.1"
|
|
118
|
-
},
|
|
119
|
-
"scripts": {
|
|
120
|
-
"========================= install =========================": "",
|
|
121
|
-
"install:playwright": "pnpm exec playwright install --with-deps",
|
|
122
|
-
"========================= deploy =========================": "",
|
|
123
|
-
"build": "vite build",
|
|
124
|
-
"========================= lint =========================": "",
|
|
125
|
-
"audit": "pnpm audit --prod",
|
|
126
|
-
"lint:es": "eslint .",
|
|
127
|
-
"lint:es:fix": "eslint --fix .",
|
|
128
|
-
"lint": "run-p lint:es",
|
|
129
|
-
"lint:fix": "run-s lint:es:fix",
|
|
130
|
-
"lint-staged": "lint-staged",
|
|
131
|
-
"check:types": "tsc --noEmit",
|
|
132
|
-
"check": "run-p audit check:types lint",
|
|
133
|
-
"========================= test =========================": "",
|
|
134
|
-
"test:node": "vitest --run --config vite.projects.ts --project node --bail 3",
|
|
135
|
-
"test:browser": "vitest --run --config vite.projects.ts --project browser --bail 3",
|
|
136
|
-
"test:chrome": "vitest --run --config vite.projects.ts --project browser --browser chromium --bail 3",
|
|
137
|
-
"test:all": "vitest --run --config vite.projects.ts --bail 3",
|
|
138
|
-
"test": "run-s test:node test:browser",
|
|
139
|
-
"========================= dev =========================": "",
|
|
140
|
-
"kill-node": "taskkill /F /IM node.exe",
|
|
141
|
-
"kill-java": "taskkill /F /IM java.exe",
|
|
142
|
-
"kill-chrome": "taskkill /F /IM chrome.exe",
|
|
143
|
-
"========================= mcp =========================": "",
|
|
144
|
-
"mcp:playwright": "mcp-server-playwright --port 8002 --host local.host --isolated",
|
|
145
|
-
"========================= other =========================": "",
|
|
146
|
-
"mcp:tools": "mcp-project-tools",
|
|
147
|
-
"dep:fix": "tsx tools/dep-fix.ts"
|
|
148
151
|
}
|
|
149
|
-
}
|
|
152
|
+
}
|