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