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