@flemist/test-variants 3.0.0 → 3.0.1
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/dist/bundle/browser.js +165 -159
- package/dist/lib/test-variants/createTestVariants.cjs +3 -1
- package/dist/lib/test-variants/createTestVariants.mjs +3 -1
- package/dist/lib/test-variants/testVariantsIterator.d.ts +7 -7
- package/dist/lib/test-variants/testVariantsRun.cjs +12 -2
- package/dist/lib/test-variants/testVariantsRun.d.ts +11 -3
- package/dist/lib/test-variants/testVariantsRun.mjs +12 -2
- package/package.json +20 -19
package/dist/bundle/browser.js
CHANGED
|
@@ -13,17 +13,17 @@ for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prot
|
|
|
13
13
|
;return e},o.apply(this,arguments)}
|
|
14
14
|
;function l(e,t,n,r){
|
|
15
15
|
return new(n||(n=Promise))(function(i,s){
|
|
16
|
-
function o(e){try{
|
|
17
|
-
function l(e){try{
|
|
18
|
-
function
|
|
16
|
+
function o(e){try{a(r.next(e))}catch(e){s(e)}}
|
|
17
|
+
function l(e){try{a(r.throw(e))}catch(e){s(e)}}
|
|
18
|
+
function a(e){var t
|
|
19
19
|
;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){
|
|
20
|
-
e(t)})).then(o,l)}
|
|
21
|
-
}function
|
|
20
|
+
e(t)})).then(o,l)}a((r=r.apply(e,t||[])).next())})
|
|
21
|
+
}function a(e,t){var n,r,i,s,o={label:0,
|
|
22
22
|
sent:function(){if(1&i[0])throw i[1];return i[1]},
|
|
23
23
|
trys:[],ops:[]};return s={next:l(0),throw:l(1),
|
|
24
24
|
return:l(2)
|
|
25
25
|
},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){
|
|
26
|
-
return this}),s;function l(l){return function(
|
|
26
|
+
return this}),s;function l(l){return function(a){
|
|
27
27
|
return function(l){
|
|
28
28
|
if(n)throw new TypeError("Generator is already executing.")
|
|
29
29
|
;for(;s&&(s=0,l[0]&&(o=0)),o;)try{
|
|
@@ -43,8 +43,8 @@ o.label=i[2],o.ops.push(l);break}
|
|
|
43
43
|
i[2]&&o.ops.pop(),o.trys.pop();continue}
|
|
44
44
|
l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=i=0}
|
|
45
45
|
if(5&l[0])throw l[1];return{
|
|
46
|
-
value:l[0]?l[1]:void 0,done:!0}}([l,
|
|
47
|
-
function
|
|
46
|
+
value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}
|
|
47
|
+
function c(e){
|
|
48
48
|
var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0
|
|
49
49
|
;if(n)return n.call(e)
|
|
50
50
|
;if(e&&"number"==typeof e.length)return{
|
|
@@ -54,7 +54,7 @@ value:e&&e[r++],done:!e}}}
|
|
|
54
54
|
;throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")
|
|
55
55
|
}function u(e){
|
|
56
56
|
return l(this,void 0,void 0,function(){var t,n
|
|
57
|
-
;return
|
|
57
|
+
;return a(this,function(r){switch(r.label){case 0:
|
|
58
58
|
return[4,i.promises.stat(e).catch(function(){
|
|
59
59
|
return null})];case 1:
|
|
60
60
|
if(null==(t=r.sent()))return[2,[]]
|
|
@@ -65,7 +65,7 @@ return e.endsWith(".json")}).sort(function(e,t){
|
|
|
65
65
|
return e>t?-1:e<t?1:0}).map(function(t){
|
|
66
66
|
return s.join(e,t)})]}})})}function h(e,t){
|
|
67
67
|
return l(this,void 0,void 0,function(){var n,r
|
|
68
|
-
;return
|
|
68
|
+
;return a(this,function(s){switch(s.label){case 0:
|
|
69
69
|
return[4,i.promises.readFile(e,"utf-8")];case 1:
|
|
70
70
|
n=s.sent();try{r=JSON.parse(n)}catch(t){
|
|
71
71
|
throw new Error("[saveErrorVariants] invalid JSON in file: ".concat(e))
|
|
@@ -75,7 +75,7 @@ throw new Error("[saveErrorVariants] jsonToArgs failed for file: ".concat(e))
|
|
|
75
75
|
return e.sessionDate.toISOString().substring(0,19).replace("T","_").replaceAll(":","-")+".json"
|
|
76
76
|
}function d(e,t,n){
|
|
77
77
|
return l(this,void 0,void 0,function(){var r,o
|
|
78
|
-
;return
|
|
78
|
+
;return a(this,function(l){switch(l.label){case 0:
|
|
79
79
|
return n?(o=n(e),r="string"==typeof o?o:JSON.stringify(o,null,2)):r=JSON.stringify(e,null,2),
|
|
80
80
|
[4,i.promises.mkdir(s.dirname(t),{recursive:!0})]
|
|
81
81
|
;case 1:
|
|
@@ -137,9 +137,9 @@ for(;x.length>0;){yield 0;const e=x
|
|
|
137
137
|
console.error("Unhandled promise rejection",e)}})}
|
|
138
138
|
m=null})}())}function j(e,t,n){w(()=>{try{
|
|
139
139
|
const r=t?t(e):e;n._resolve(r)}catch(e){
|
|
140
|
-
n._reject(e)}})}function
|
|
140
|
+
n._reject(e)}})}function E(e,t,n){w(()=>{if(t)try{
|
|
141
141
|
const r=t(e);n._resolve(r)}catch(e){n._reject(e)
|
|
142
|
-
}else n._reject(e)})}const
|
|
142
|
+
}else n._reject(e)})}const S=function(){};class A{
|
|
143
143
|
constructor(e){
|
|
144
144
|
this.status="pending",this.value=void 0,this.reason=void 0,this._handlers=null
|
|
145
145
|
;const t=this._resolve,n=this._reject,r=this._resolveAsync,i=this._rejectAsync,s=this
|
|
@@ -161,25 +161,25 @@ this.status="rejected",b(e)?e.then(this._rejectAsync,this._rejectAsync):this._re
|
|
|
161
161
|
}_rejectSync(e){const t=this._handlers
|
|
162
162
|
;if(this.reason=e,null!=t){this._handlers=null
|
|
163
163
|
;for(let n=0,r=t.length;n<r;n++){const[,r,i]=t[n]
|
|
164
|
-
;
|
|
164
|
+
;E(e,r,i)}}}then(e,t){const n=new A(S)
|
|
165
165
|
;return"pending"===this.status?(null==this._handlers&&(this._handlers=[]),
|
|
166
|
-
this._handlers.push([e,t,n])):"fulfilled"===this.status?j(this.value,e,n):
|
|
166
|
+
this._handlers.push([e,t,n])):"fulfilled"===this.status?j(this.value,e,n):E(this.reason,t,n),
|
|
167
167
|
n}catch(e){return this.then(void 0,e)}finally(e){
|
|
168
168
|
const t=e&&function(t){const n=e()
|
|
169
|
-
;return b(n)?n.then(()=>t):
|
|
169
|
+
;return b(n)?n.then(()=>t):A.resolve(t)
|
|
170
170
|
},n=e&&function(t){const n=e()
|
|
171
|
-
;return b(n)?n.then(()=>
|
|
171
|
+
;return b(n)?n.then(()=>A.reject(t)):A.reject(t)}
|
|
172
172
|
;return this.then(t,n)}static resolve(e){
|
|
173
|
-
const t=new
|
|
174
|
-
static reject(e){const t=new
|
|
173
|
+
const t=new A(S);return t._resolve(e),t}
|
|
174
|
+
static reject(e){const t=new A(S)
|
|
175
175
|
;return t._reject(e),t}get[Symbol.toStringTag](){
|
|
176
176
|
return"Promise"}static get[Symbol.species](){
|
|
177
|
-
return
|
|
177
|
+
return A}static all(e){return function(e,t){
|
|
178
178
|
let n,r;t||(t=Promise);const i=new t((e,t)=>{
|
|
179
179
|
n=e,r=t});let s=e.length;const o=[]
|
|
180
180
|
;return e.forEach((e,t)=>{b(e)?e.then(e=>{
|
|
181
181
|
o[t]=e,0===--s&&n(o)},r):(o[t]=e,0===--s&&n(o))
|
|
182
|
-
}),i}(e,
|
|
182
|
+
}),i}(e,A)}static allSettled(e){
|
|
183
183
|
return function(e,t){let n;t||(t=Promise)
|
|
184
184
|
;const r=new t((e,t)=>{n=e});let i=e.length
|
|
185
185
|
;const s=[];return e.forEach((e,t)=>{
|
|
@@ -187,17 +187,17 @@ b(e)?e.then(e=>{s[t]={status:"fulfilled",value:e
|
|
|
187
187
|
},0===--i&&n(s)},e=>{s[t]={status:"rejected",
|
|
188
188
|
reason:e},0===--i&&n(s)}):(s[t]={
|
|
189
189
|
status:"fulfilled",value:e},0===--i&&n(s))}),r
|
|
190
|
-
}(e,
|
|
190
|
+
}(e,A)}static any(e){return function(e,t){let n,r
|
|
191
191
|
;t||(t=Promise);const i=new t((e,t)=>{n=e,r=t})
|
|
192
192
|
;let s=e.length;const o=[]
|
|
193
193
|
;return e.forEach((e,t)=>{b(e)?e.then(n,e=>{
|
|
194
194
|
o[t]=e,0===--s&&r(new AggregateError(o))}):n(e)
|
|
195
|
-
}),i}(e,
|
|
195
|
+
}),i}(e,A)}static race(e){return function(e,t){
|
|
196
196
|
let n,r;t||(t=Promise);const i=new t((e,t)=>{
|
|
197
197
|
n=e,r=t});return e.forEach(e=>{
|
|
198
|
-
b(e)?e.then(n,r):n(e)}),i}(e,
|
|
199
|
-
const P=function(){};class
|
|
200
|
-
if(this._status="pending",e&&e.aborted)this.promise=
|
|
198
|
+
b(e)?e.then(n,r):n(e)}),i}(e,A)}}
|
|
199
|
+
const P=function(){};class k{constructor(e){
|
|
200
|
+
if(this._status="pending",e&&e.aborted)this.promise=A.reject(e.reason),
|
|
201
201
|
this.resolve=P,this.reject=P;else{let t,n
|
|
202
202
|
;if(this.promise=new Promise(function(e){
|
|
203
203
|
t=e,n=function(t){p(e,t)}}),e){
|
|
@@ -207,11 +207,11 @@ const r=e.subscribe(function(e){n(e)})
|
|
|
207
207
|
}else this.resolve=t,this.reject=n}
|
|
208
208
|
this.promise.then(()=>{this._status="resolved"
|
|
209
209
|
},()=>{this._status="rejected"})}get state(){
|
|
210
|
-
return this._status}}class
|
|
210
|
+
return this._status}}class I extends Error{
|
|
211
211
|
constructor(e,t){
|
|
212
|
-
super(e),Object.setPrototypeOf(this,
|
|
212
|
+
super(e),Object.setPrototypeOf(this,I.prototype),this.reason=t,
|
|
213
213
|
this.name="AbortError",this._internal=!1}}
|
|
214
|
-
const T=()=>{};class
|
|
214
|
+
const T=()=>{};class O{constructor(){
|
|
215
215
|
this.aborted=!1,this.reason=void 0,this._callbacks=void 0
|
|
216
216
|
}subscribe(e){var t
|
|
217
217
|
;if(null===(t=this._callbacks)||void 0===t?void 0:t.has(e))throw new Error("Already subscribed: "+e)
|
|
@@ -223,13 +223,13 @@ this._callbacks.add(e),()=>{var t
|
|
|
223
223
|
;this.aborted=!0,this.reason=e,null===(t=this._callbacks)||void 0===t||t.forEach(e=>{
|
|
224
224
|
e.call(this,this.reason)}),this._callbacks=void 0}
|
|
225
225
|
throwIfAborted(){if(this.aborted)throw this.reason
|
|
226
|
-
}}class
|
|
226
|
+
}}class z{constructor(){this.signal=new O}
|
|
227
227
|
abort(e){
|
|
228
|
-
this.signal.aborted||(void 0===e&&((e=new
|
|
228
|
+
this.signal.aborted||(void 0===e&&((e=new I("Aborted with no reason",e))._internal=!0),
|
|
229
229
|
this.signal.abort(e))}}function L(e,t){
|
|
230
230
|
var n=0,r=null;function i(e,i,s){
|
|
231
231
|
return l(this,void 0,void 0,function(){var o
|
|
232
|
-
;return
|
|
232
|
+
;return a(this,function(l){switch(l.label){case 0:
|
|
233
233
|
return r={error:e,args:i,index:s
|
|
234
234
|
},console.error("[test-variants] error variant: ".concat(s,"\n").concat(function(e){
|
|
235
235
|
return JSON.stringify(e,function(e,t){
|
|
@@ -263,9 +263,9 @@ for(;M.length>0;){yield 0;const e=M
|
|
|
263
263
|
console.error("Unhandled promise rejection",e)}})}
|
|
264
264
|
D=null})}())}function R(e,t,n){C(()=>{try{
|
|
265
265
|
const r=t?t(e):e;n._resolve(r)}catch(e){
|
|
266
|
-
n._reject(e)}})}function
|
|
266
|
+
n._reject(e)}})}function q(e,t,n){C(()=>{if(t)try{
|
|
267
267
|
const r=t(e);n._resolve(r)}catch(e){n._reject(e)
|
|
268
|
-
}else n._reject(e)})}const
|
|
268
|
+
}else n._reject(e)})}const B=function(){};class J{
|
|
269
269
|
constructor(e){
|
|
270
270
|
this.status="pending",this.value=void 0,this.reason=void 0,this._handlers=null
|
|
271
271
|
;const t=this._resolve,n=this._reject,r=this._resolveAsync,i=this._rejectAsync,s=this
|
|
@@ -287,25 +287,25 @@ this.status="rejected",V(e)?e.then(this._rejectAsync,this._rejectAsync):this._re
|
|
|
287
287
|
}_rejectSync(e){const t=this._handlers
|
|
288
288
|
;if(this.reason=e,null!=t){this._handlers=null
|
|
289
289
|
;for(let n=0,r=t.length;n<r;n++){const[,r,i]=t[n]
|
|
290
|
-
;
|
|
290
|
+
;q(e,r,i)}}}then(e,t){const n=new J(B)
|
|
291
291
|
;return"pending"===this.status?(null==this._handlers&&(this._handlers=[]),
|
|
292
|
-
this._handlers.push([e,t,n])):"fulfilled"===this.status?R(this.value,e,n):
|
|
292
|
+
this._handlers.push([e,t,n])):"fulfilled"===this.status?R(this.value,e,n):q(this.reason,t,n),
|
|
293
293
|
n}catch(e){return this.then(void 0,e)}finally(e){
|
|
294
294
|
const t=e&&function(t){const n=e()
|
|
295
|
-
;return V(n)?n.then(()=>t)
|
|
295
|
+
;return V(n)?n.then(()=>t):J.resolve(t)
|
|
296
296
|
},n=e&&function(t){const n=e()
|
|
297
|
-
;return V(n)?n.then(()
|
|
297
|
+
;return V(n)?n.then(()=>J.reject(t)):J.reject(t)}
|
|
298
298
|
;return this.then(t,n)}static resolve(e){
|
|
299
|
-
const t=new
|
|
300
|
-
static reject(e){const t=new
|
|
299
|
+
const t=new J(B);return t._resolve(e),t}
|
|
300
|
+
static reject(e){const t=new J(B)
|
|
301
301
|
;return t._reject(e),t}get[Symbol.toStringTag](){
|
|
302
302
|
return"Promise"}static get[Symbol.species](){
|
|
303
|
-
return
|
|
303
|
+
return J}static all(e){return function(e,t){
|
|
304
304
|
let n,r;t||(t=Promise);const i=new t((e,t)=>{
|
|
305
305
|
n=e,r=t});let s=e.length;const o=[]
|
|
306
306
|
;return e.forEach((e,t)=>{V(e)?e.then(e=>{
|
|
307
307
|
o[t]=e,0===--s&&n(o)},r):(o[t]=e,0===--s&&n(o))
|
|
308
|
-
}),i}(e
|
|
308
|
+
}),i}(e,J)}static allSettled(e){
|
|
309
309
|
return function(e,t){let n;t||(t=Promise)
|
|
310
310
|
;const r=new t((e,t)=>{n=e});let i=e.length
|
|
311
311
|
;const s=[];return e.forEach((e,t)=>{
|
|
@@ -313,18 +313,18 @@ V(e)?e.then(e=>{s[t]={status:"fulfilled",value:e
|
|
|
313
313
|
},0===--i&&n(s)},e=>{s[t]={status:"rejected",
|
|
314
314
|
reason:e},0===--i&&n(s)}):(s[t]={
|
|
315
315
|
status:"fulfilled",value:e},0===--i&&n(s))}),r
|
|
316
|
-
}(e
|
|
316
|
+
}(e,J)}static any(e){return function(e,t){let n,r
|
|
317
317
|
;t||(t=Promise);const i=new t((e,t)=>{n=e,r=t})
|
|
318
318
|
;let s=e.length;const o=[]
|
|
319
319
|
;return e.forEach((e,t)=>{V(e)?e.then(n,e=>{
|
|
320
320
|
o[t]=e,0===--s&&r(new AggregateError(o))}):n(e)
|
|
321
|
-
}),i}(e
|
|
321
|
+
}),i}(e,J)}static race(e){return function(e,t){
|
|
322
322
|
let n,r;t||(t=Promise);const i=new t((e,t)=>{
|
|
323
323
|
n=e,r=t});return e.forEach(e=>{
|
|
324
|
-
V(e)?e.then(n,r):n(e)}),i}(e
|
|
325
|
-
const
|
|
326
|
-
if(this._status="pending",e&&e.aborted)this.promise
|
|
327
|
-
this.resolve=
|
|
324
|
+
V(e)?e.then(n,r):n(e)}),i}(e,J)}}
|
|
325
|
+
const N=function(){};class ${constructor(e){
|
|
326
|
+
if(this._status="pending",e&&e.aborted)this.promise=J.reject(e.reason),
|
|
327
|
+
this.resolve=N,this.reject=N;else{let t,n
|
|
328
328
|
;if(this.promise=new Promise(function(e){
|
|
329
329
|
t=e,n=function(t){!function(e,t){e(function(e){
|
|
330
330
|
return{then(t,n){n(e)}}}(t))}(e,t)}}),e){
|
|
@@ -337,7 +337,7 @@ this.promise.then(()=>{this._status="resolved"
|
|
|
337
337
|
return this._status}}
|
|
338
338
|
var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}
|
|
339
339
|
;!function(e){if(!e.setImmediate){
|
|
340
|
-
var t,n,r,i,s,o=1,l={},
|
|
340
|
+
var t,n,r,i,s,o=1,l={},a=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e)
|
|
341
341
|
;u=u&&u.setTimeout?u:e,
|
|
342
342
|
"[object process]"==={}.toString.call(e.process)?t=function(e){
|
|
343
343
|
process.nextTick(function(){f(e)})}:!function(){
|
|
@@ -347,8 +347,8 @@ var t=!0,n=e.onmessage
|
|
|
347
347
|
},e.postMessage("","*"),e.onmessage=n,t}
|
|
348
348
|
}()?e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){
|
|
349
349
|
f(e.data)},t=function(e){r.port2.postMessage(e)
|
|
350
|
-
}):
|
|
351
|
-
t=function(e){var t=
|
|
350
|
+
}):c&&"onreadystatechange"in c.createElement("script")?(n=c.documentElement,
|
|
351
|
+
t=function(e){var t=c.createElement("script")
|
|
352
352
|
;t.onreadystatechange=function(){
|
|
353
353
|
f(e),t.onreadystatechange=null,n.removeChild(t),
|
|
354
354
|
t=null},n.appendChild(t)}):t=function(e){
|
|
@@ -363,12 +363,12 @@ t=function(t){e.postMessage(i+t,"*")
|
|
|
363
363
|
;for(var n=new Array(arguments.length-1),r=0;r<n.length;r++)n[r]=arguments[r+1]
|
|
364
364
|
;var i={callback:e,args:n};return l[o]=i,t(o),o++
|
|
365
365
|
},u.clearImmediate=h}function h(e){delete l[e]}
|
|
366
|
-
function f(e){if(
|
|
367
|
-
var t=l[e];if(t){
|
|
366
|
+
function f(e){if(a)setTimeout(f,0,e);else{
|
|
367
|
+
var t=l[e];if(t){a=!0;try{!function(e){
|
|
368
368
|
var t=e.callback,n=e.args;switch(n.length){case 0:
|
|
369
369
|
t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1])
|
|
370
370
|
;break;case 3:t(n[0],n[1],n[2]);break;default:
|
|
371
|
-
t.apply(void 0,n)}}(t)}finally{h(e),
|
|
371
|
+
t.apply(void 0,n)}}(t)}finally{h(e),a=!1}}}}
|
|
372
372
|
}("undefined"==typeof self?G:self)
|
|
373
373
|
;const U=function(e){return e};function W(e,t){
|
|
374
374
|
return function(e,t){
|
|
@@ -380,7 +380,7 @@ const t=e>=i?0:n[i-1-e],o=e>=s?0:r[s-1-e]
|
|
|
380
380
|
constructor(){this._queue=new g({lessThanFunc:W})}
|
|
381
381
|
run(e,t,n){return this._run(!1,e,t,n)}
|
|
382
382
|
runTask(e,t,n){return this._run(!0,e,t,n)}
|
|
383
|
-
_run(e,t,n,r){const i=new
|
|
383
|
+
_run(e,t,n,r){const i=new $(r),s={
|
|
384
384
|
priority:(o=Q++,l=n,null==o?null==l?null:l:new F(o,l)),
|
|
385
385
|
func:t,abortSignal:r,resolve:i.resolve,
|
|
386
386
|
reject:i.reject,readyToRun:!e};var o,l
|
|
@@ -406,7 +406,7 @@ let e=t.func&&t.func(t.abortSignal)
|
|
|
406
406
|
const e=new K;return function(t,n){
|
|
407
407
|
return e.run(void 0,t,n)}}();class X{
|
|
408
408
|
constructor(e){
|
|
409
|
-
if(this._maxSize=0,this._size=0,this._tickPromise=new
|
|
409
|
+
if(this._maxSize=0,this._size=0,this._tickPromise=new k,!e)throw new Error("maxSize should be > 0")
|
|
410
410
|
;this._maxSize=e,
|
|
411
411
|
this._size=e,this._priorityQueue=new K}
|
|
412
412
|
get maxSize(){return this._maxSize}get size(){
|
|
@@ -421,7 +421,7 @@ if(!t)throw new Error(`count (${e} > maxReleaseCount (${r}))`)
|
|
|
421
421
|
const e=this._tickPromise
|
|
422
422
|
;this._tickPromise=null,e.resolve()}return e}
|
|
423
423
|
tick(e){
|
|
424
|
-
if(!(this._size>=this._maxSize))return this._tickPromise||(this._tickPromise=new
|
|
424
|
+
if(!(this._size>=this._maxSize))return this._tickPromise||(this._tickPromise=new k),
|
|
425
425
|
function(e,t){return e?new Promise(function(n){
|
|
426
426
|
if(e&&e.aborted)return void p(n,e.reason);let r,i
|
|
427
427
|
;function s(e){i||(i=!0,r&&r(),p(n,e))}
|
|
@@ -443,98 +443,102 @@ setTimeout(function(){t(e)},1)})
|
|
|
443
443
|
;return n<60?"".concat(n.toFixed(1),"m"):"".concat((n/60).toFixed(1),"h")
|
|
444
444
|
}function ee(e,t,n){var r,i,o,v,g,_,y,p,m
|
|
445
445
|
;return void 0===n&&(n={}),l(this,void 0,void 0,function(){
|
|
446
|
-
var x,w,j,S,A,
|
|
447
|
-
;return
|
|
446
|
+
var x,w,j,E,S,A,P,k,I,T,O,L,F,V,D,M,C,R,q,B,J,N,$,G,U,W,Q,K,H,ee,te,ne,re,ie,se,oe,le,ae,ce,ue,he,fe,de,ve,ge=this
|
|
447
|
+
;return a(this,function(_e){switch(_e.label){
|
|
448
448
|
case 0:
|
|
449
449
|
return x=n.saveErrorVariants,w=null!==(r=null==x?void 0:x.retriesPerVariant)&&void 0!==r?r:1,
|
|
450
450
|
j=null==x?void 0:x.useToFindBestError,
|
|
451
|
-
|
|
452
|
-
sessionDate:
|
|
453
|
-
})):null,
|
|
451
|
+
E=new Date,S=x?s.resolve(x.dir,null!==(o=null===(i=x.getFilePath)||void 0===i?void 0:i.call(x,{
|
|
452
|
+
sessionDate:E}))&&void 0!==o?o:f({sessionDate:E
|
|
453
|
+
})):null,A=null!==(v=n.GC_Iterations)&&void 0!==v?v:1e6,
|
|
454
454
|
P=null!==(g=n.GC_IterationsAsync)&&void 0!==g?g:1e4,
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
k=null!==(_=n.GC_Interval)&&void 0!==_?_:1e3,
|
|
456
|
+
I=null!==(y=n.logInterval)&&void 0!==y?y:5e3,
|
|
457
457
|
T=null===(p=n.logCompleted)||void 0===p||p,
|
|
458
|
-
|
|
459
|
-
V
|
|
458
|
+
O=n.abortSignal,L=n.findBestError,F=null!==(m=null==L?void 0:L.cycles)&&void 0!==m?m:1,
|
|
459
|
+
V=null==L?void 0:L.dontThrowIfError,
|
|
460
|
+
D=n.limitTime,M=!0===n.parallel?Math.pow(2,31):!n.parallel||n.parallel<=0?1:n.parallel,
|
|
460
461
|
null!=n.limitVariantsCount&&t.addLimit({
|
|
461
462
|
index:n.limitVariantsCount}),x?[4,u(x.dir)]:[3,15]
|
|
462
|
-
;case 1:
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return
|
|
466
|
-
;case 4:
|
|
467
|
-
if(!(
|
|
468
|
-
return
|
|
469
|
-
;case 7:
|
|
470
|
-
;case 9:if(N=
|
|
471
|
-
args:
|
|
472
|
-
return
|
|
463
|
+
;case 1:C=_e.sent(),_e.label=2;case 2:
|
|
464
|
+
_e.trys.push([2,13,14,15]),R=c(C),q=R.next(),
|
|
465
|
+
_e.label=3;case 3:
|
|
466
|
+
return q.done?[3,12]:[4,h(q.value,x.jsonToArgs)]
|
|
467
|
+
;case 4:ue=_e.sent(),B=0,_e.label=5;case 5:
|
|
468
|
+
if(!(B<w))return[3,11];_e.label=6;case 6:
|
|
469
|
+
return _e.trys.push([6,9,,10]),b(J=e(ue,-1,null))?[4,J]:[3,8]
|
|
470
|
+
;case 7:_e.sent(),_e.label=8;case 8:return[3,10]
|
|
471
|
+
;case 9:if(N=_e.sent(),j&&L)return t.addLimit({
|
|
472
|
+
args:ue,error:N}),[3,11];throw N;case 10:
|
|
473
|
+
return B++,[3,5];case 11:return q=R.next(),[3,3]
|
|
473
474
|
;case 12:return[3,15];case 13:
|
|
474
|
-
return $=
|
|
475
|
-
try{
|
|
476
|
-
if(
|
|
477
|
-
|
|
475
|
+
return $=_e.sent(),de={error:$},[3,15];case 14:
|
|
476
|
+
try{q&&!q.done&&(ve=R.return)&&ve.call(R)}finally{
|
|
477
|
+
if(de)throw de.error}return[7];case 15:
|
|
478
|
+
G=null,U=null,W=Date.now(),Q=W,K=new z,H=function(...e){
|
|
478
479
|
let t,n;function r(e){t.abort(e)}
|
|
479
480
|
for(let i=0;i<e.length;i++){const s=e[i];if(s){
|
|
480
481
|
if(s.aborted)return s
|
|
481
|
-
;n?(t||(t=new
|
|
482
|
-
}}return t?t.signal:n||(new
|
|
483
|
-
}(
|
|
484
|
-
|
|
485
|
-
t.start(),
|
|
486
|
-
if(!(t.cycleIndex<F))return[3,20]
|
|
487
|
-
;
|
|
488
|
-
var n,r,i,s,o,
|
|
489
|
-
;return
|
|
490
|
-
return n=t.index,r=
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
null!=u
|
|
494
|
-
|
|
482
|
+
;n?(t||(t=new z,n.subscribe(r)),s.subscribe(r)):n=s
|
|
483
|
+
}}return t?t.signal:n||(new z).signal
|
|
484
|
+
}(O,K.signal),ee=H,te=!1,ne=0,re=0,ie=Date.now(),
|
|
485
|
+
se=ie,oe=ne,le=re,ae=M<=1?null:new X(M),
|
|
486
|
+
ce=!1,t.start(),_e.label=16;case 16:
|
|
487
|
+
if(!(t.cycleIndex<F)||ce)return[3,20]
|
|
488
|
+
;ue=void 0,he=function(){
|
|
489
|
+
var n,r,i,s,o,c,u,h,f,v,g,_,y,p,m,w
|
|
490
|
+
;return a(this,function(j){switch(j.label){case 0:
|
|
491
|
+
return n=t.index,r=ue,i=(I||k||D)&&Date.now(),
|
|
492
|
+
D&&i-W>=D?(ce=!0,[2,"break"]):(I&&i-ie>=I&&(s="",
|
|
493
|
+
o=i-Q,c=i-W,L?(s+="cycle: ".concat(t.cycleIndex,", variant: ").concat(t.index),
|
|
494
|
+
null!=(u=t.count)&&null!=G&&G<u&&(u=G),
|
|
495
|
+
null!=u&&t.index>0?(h=void 0,null!=U&&null!=G&&t.index<G&&o<U?(f=U-o,
|
|
496
|
+
v=G-t.index,
|
|
495
497
|
g=f/v,_=(u-t.index)*g,h=o+_):h=o*u/t.index,s+="/".concat(u," (").concat(Z(o),"/").concat(Z(h),")")):s+=" (".concat(Z(o),")")):s+="variant: ".concat(t.index," (").concat(Z(o),")"),
|
|
496
|
-
s+=", total: ".concat(
|
|
497
|
-
console.log(s),
|
|
498
|
-
|
|
498
|
+
s+=", total: ".concat(ne," (").concat(Z(c),")"),
|
|
499
|
+
console.log(s),ie=i),A&&ne-oe>=A||P&&re-le>=P||k&&i-se>=k?(oe=ne,
|
|
500
|
+
le=re,se=i,[4,Y(1)]):[3,2]);case 1:
|
|
499
501
|
j.sent(),j.label=2;case 2:
|
|
500
|
-
if(null==
|
|
501
|
-
;if(
|
|
502
|
-
return j.trys.push([3,6,,9]),b(y=e(r,n,
|
|
502
|
+
if(null==O?void 0:O.aborted)return[2,"continue"]
|
|
503
|
+
;if(ae&&!H.aborted)return[3,10];j.label=3;case 3:
|
|
504
|
+
return j.trys.push([3,6,,9]),b(y=e(r,n,H))?[4,y]:[3,5]
|
|
503
505
|
;case 4:y=j.sent(),j.label=5;case 5:
|
|
504
506
|
return y?(p=y.iterationsAsync,m=y.iterationsSync,
|
|
505
|
-
|
|
507
|
+
re+=p,ne+=m+p,[3,9]):(te=!0,K.abort(),
|
|
506
508
|
[2,"continue"]);case 6:
|
|
507
|
-
return w=j.sent(),
|
|
509
|
+
return w=j.sent(),S?[4,d(r,S,x.argsToJson)]:[3,8]
|
|
508
510
|
;case 7:j.sent(),j.label=8;case 8:if(!L)throw w
|
|
509
|
-
;return t.addLimit({error:w}),
|
|
511
|
+
;return t.addLimit({error:w}),te=!1,[3,9];case 9:
|
|
510
512
|
return[3,13];case 10:
|
|
511
|
-
return
|
|
513
|
+
return ae.hold(1)?[3,12]:[4,ae.holdWait(1)]
|
|
512
514
|
;case 11:j.sent(),j.label=12;case 12:
|
|
513
|
-
l(
|
|
514
|
-
;return
|
|
515
|
-
return
|
|
516
|
-
(null==
|
|
517
|
-
;case 1:i=
|
|
515
|
+
l(ge,void 0,void 0,function(){var i,s,o,l
|
|
516
|
+
;return a(this,function(a){switch(a.label){case 0:
|
|
517
|
+
return a.trys.push([0,3,6,7]),
|
|
518
|
+
(null==H?void 0:H.aborted)?[2]:b(i=e(r,n,H))?[4,i]:[3,2]
|
|
519
|
+
;case 1:i=a.sent(),a.label=2;case 2:
|
|
518
520
|
return i?(s=i.iterationsAsync,o=i.iterationsSync,
|
|
519
|
-
|
|
520
|
-
return l=
|
|
521
|
-
;case 4:
|
|
522
|
-
;return t.addLimit({error:l}),
|
|
523
|
-
return
|
|
524
|
-
}),j.label=13;case 13:return[2]}})},
|
|
521
|
+
re+=s,ne+=o+s,[3,7]):(te=!0,K.abort(),[2]);case 3:
|
|
522
|
+
return l=a.sent(),S?[4,d(r,S,x.argsToJson)]:[3,5]
|
|
523
|
+
;case 4:a.sent(),a.label=5;case 5:if(!L)throw l
|
|
524
|
+
;return t.addLimit({error:l}),te=!1,[3,7];case 6:
|
|
525
|
+
return ae.release(1),[7];case 7:return[2]}})
|
|
526
|
+
}),j.label=13;case 13:return[2]}})},_e.label=17
|
|
525
527
|
;case 17:
|
|
526
|
-
return(null==
|
|
527
|
-
;case 18:return
|
|
528
|
-
|
|
529
|
-
t.start(),[3,16]
|
|
530
|
-
return
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
[
|
|
528
|
+
return(null==O?void 0:O.aborted)||!te&&null==(ue=t.next())?[3,19]:[5,he()]
|
|
529
|
+
;case 18:return"break"===_e.sent()?[3,19]:[3,17]
|
|
530
|
+
;case 19:
|
|
531
|
+
return G=t.count,U=Date.now()-Q,Q=Date.now(),t.start(),[3,16]
|
|
532
|
+
;case 20:return ae?[4,ae.holdWait(M)]:[3,22]
|
|
533
|
+
;case 21:_e.sent(),ae.release(M),_e.label=22
|
|
534
|
+
;case 22:
|
|
535
|
+
if(null==ee?void 0:ee.aborted)throw ee.reason
|
|
536
|
+
;return T&&console.log("[test-variants] variants: ".concat(t.index,", iterations: ").concat(ne,", async: ").concat(re)),
|
|
537
|
+
[4,Y(1)];case 23:if(_e.sent(),(fe=t.limit?{
|
|
535
538
|
error:t.limit.error,args:t.limit.args,
|
|
536
|
-
index:t.count}:null
|
|
537
|
-
}]}})})}
|
|
539
|
+
index:t.count}:null)&&!V)throw fe.error;return[2,{
|
|
540
|
+
iterations:ne,bestError:fe}]}})})}
|
|
541
|
+
function te(e,t,n){if(n){
|
|
538
542
|
for(var r=e.length-1;r>=0;r--)if(n(e[r],t))return r
|
|
539
543
|
;return-1}
|
|
540
544
|
for(r=e.length-1;r>=0;r--)if(e[r]===t)return r
|
|
@@ -545,8 +549,8 @@ var n=e.variants[t].length,r=e.argLimits[t]
|
|
|
545
549
|
;return null==r?n:r<n?r:n}function ie(e,t,n){
|
|
546
550
|
var r,i,s=Object.keys(e).filter(function(e){
|
|
547
551
|
return"seed"!==e});if(s.length!==n)return!1;try{
|
|
548
|
-
for(var o=
|
|
549
|
-
var
|
|
552
|
+
for(var o=c(s),l=o.next();!l.done;l=o.next()){
|
|
553
|
+
var a=l.value;if(!t.has(a))return!1}}catch(e){r={
|
|
550
554
|
error:e}}finally{try{
|
|
551
555
|
l&&!l.done&&(i=o.return)&&i.call(o)}finally{
|
|
552
556
|
if(r)throw r.error}}return!0}
|
|
@@ -555,18 +559,18 @@ var o=t[s]
|
|
|
555
559
|
;if("function"!=typeof o)if(te(o,e[n[s]],i)<0)return!1
|
|
556
560
|
}return!0}function oe(e,t,n,r,i){
|
|
557
561
|
for(var s=!1,o=0;o<r;o++){
|
|
558
|
-
var l=e.indexes[o],
|
|
559
|
-
;if(!(
|
|
562
|
+
var l=e.indexes[o],a=t[n[o]],c=te(e.variants[o],a,i)
|
|
563
|
+
;if(!(c<0)){if(s=!0,l<c)return!1;if(l>c)return!0}}
|
|
560
564
|
return s}function le(e,t,n,r,i,s,o){
|
|
561
565
|
if(o)for(var l=0;l<i;l++){
|
|
562
|
-
var
|
|
566
|
+
var a=r[l],c=t[a],u=e.variants[l].length>0?e.variants[l]:ne(n,e.args,l),h=te(u,c,s)
|
|
563
567
|
;if(!(h<=0)){if("function"==typeof o)if(!o({
|
|
564
|
-
name:
|
|
568
|
+
name:a,valueIndex:h,values:u,
|
|
565
569
|
maxValueIndex:e.argLimits[l]}))continue
|
|
566
570
|
;var f=e.argLimits[l]
|
|
567
571
|
;(null==f||h<f)&&(e.argLimits[l]=h)}}}
|
|
568
|
-
function
|
|
569
|
-
for(var t=e.argsTemplates,n=e.getSeed,r=e.repeatsPerVariant,i=e.equals,s=e.limitArgOnError,l=null!=r?r:1,
|
|
572
|
+
function ae(e){
|
|
573
|
+
for(var t=e.argsTemplates,n=e.getSeed,r=e.repeatsPerVariant,i=e.equals,s=e.limitArgOnError,l=null!=r?r:1,a=Object.keys(t),c=Object.values(t),u=a.length,h=new Set(a),f=[],d=[],v=[],g=0;g<u;g++)f[g]=-1,
|
|
570
574
|
d[g]=[],v[g]=null;var _={args:{},indexes:f,
|
|
571
575
|
variants:d,argLimits:v,index:-1,cycleIndex:-1,
|
|
572
576
|
repeatIndex:0,count:null,limit:null,started:!1,
|
|
@@ -578,12 +582,12 @@ var t=void 0!==(null==e?void 0:e.args)&&null!==e.args,n=null!=(null==e?void 0:e.
|
|
|
578
582
|
;if(t||n)if(!n||t)if(!t||n){if(t&&n){
|
|
579
583
|
var r=null==_.count||e.index<_.count
|
|
580
584
|
;if(r&&(_.count=e.index),!ie(e.args,h,u))return
|
|
581
|
-
;if(!se(e.args,a,
|
|
585
|
+
;if(!se(e.args,c,a,u,i))return
|
|
582
586
|
;r&&(_.limit=void 0!==e.error?{args:e.args,
|
|
583
587
|
error:e.error}:{args:e.args
|
|
584
|
-
},le(_,e.args,a,
|
|
588
|
+
},le(_,e.args,c,a,u,i,s))}}else{
|
|
585
589
|
if(!ie(e.args,h,u))return
|
|
586
|
-
;if(!se(e.args,a,
|
|
590
|
+
;if(!se(e.args,c,a,u,i))return
|
|
587
591
|
;var o=void 0!==e.error?{args:e.args,error:e.error
|
|
588
592
|
}:{args:e.args};_.pendingLimits.push(o)
|
|
589
593
|
}else(null==_.count||e.index<_.count)&&(_.count=e.index);else{
|
|
@@ -591,12 +595,12 @@ if(_.index<0)throw new Error("[testVariantsIterator] addLimit() requires at leas
|
|
|
591
595
|
;(null==_.count||_.index<_.count)&&(_.count=_.index,
|
|
592
596
|
_.limit=void 0!==(null==e?void 0:e.error)?{
|
|
593
597
|
args:_.currentArgs,error:e.error}:{
|
|
594
|
-
args:_.currentArgs},le(_,_.args,a,
|
|
598
|
+
args:_.currentArgs},le(_,_.args,c,a,u,i,s))}},
|
|
595
599
|
start:function(){_.cycleIndex++,function(e,t,n){
|
|
596
600
|
e.index=-1,e.repeatIndex=0
|
|
597
601
|
;for(var r=0;r<n;r++)e.indexes[r]=-1,e.variants[r]=[]
|
|
598
602
|
;n>0&&(e.variants[0]=ne(t,e.args,0))
|
|
599
|
-
}(_,
|
|
603
|
+
}(_,c,u),_.started=!0},next:function(){
|
|
600
604
|
if(!_.started)throw new Error("[testVariantsIterator] start() must be called before next()")
|
|
601
605
|
;if(_.index>=0&&_.repeatIndex+1<l&&(null==_.count||_.index<_.count)){
|
|
602
606
|
if(_.repeatIndex++,n){var e=n({
|
|
@@ -607,37 +611,39 @@ repeatIndex:_.repeatIndex})
|
|
|
607
611
|
;return _.currentArgs}
|
|
608
612
|
if(_.repeatIndex=0,!function(e,t,n,r){
|
|
609
613
|
for(var i,s=r-1;s>=0;s--){var o=e.indexes[s]+1
|
|
610
|
-
;if(o<re(e,s)){var l=n[s],
|
|
611
|
-
;for(e.indexes[s]=o,e.args[l]=
|
|
612
|
-
var
|
|
613
|
-
;if(0===
|
|
614
|
-
;e.indexes[s]=0,e.variants[s]=
|
|
614
|
+
;if(o<re(e,s)){var l=n[s],a=e.variants[s][o]
|
|
615
|
+
;for(e.indexes[s]=o,e.args[l]=a,s++;s<r;s++){
|
|
616
|
+
var c=ne(t,e.args,s),u=null!==(i=e.argLimits[s])&&void 0!==i?i:c.length
|
|
617
|
+
;if(0===c.length||u<=0)break
|
|
618
|
+
;e.indexes[s]=0,e.variants[s]=c;var h=n[s],f=c[0]
|
|
615
619
|
;e.args[h]=f}if(s>=r)return!0}}return!1
|
|
616
|
-
}(_,a,
|
|
620
|
+
}(_,c,a,u))return null==_.count&&(_.count=_.index+1),
|
|
617
621
|
null
|
|
618
622
|
;if(_.index++,_.pendingLimits.length>0&&function(e,t,n,r,i,s){
|
|
619
623
|
for(var o=!1,l=e.pendingLimits.length-1;l>=0;l--){
|
|
620
|
-
var
|
|
621
|
-
;oe(e,
|
|
622
|
-
e.limit=void 0!==
|
|
623
|
-
error:
|
|
624
|
-
},le(e,
|
|
624
|
+
var a=e.pendingLimits[l]
|
|
625
|
+
;oe(e,a.args,n,r,i)&&((null==e.count||e.index<e.count)&&(e.count=e.index,
|
|
626
|
+
e.limit=void 0!==a.error?{args:a.args,
|
|
627
|
+
error:a.error}:{args:a.args
|
|
628
|
+
},le(e,a.args,t,n,r,i,s),o=!0),e.pendingLimits.splice(l,1))
|
|
625
629
|
}
|
|
626
|
-
}(_,a,
|
|
630
|
+
}(_,c,a,u,i,s),null!=_.count&&_.index>=_.count)return null
|
|
627
631
|
;if(n){e=n({variantIndex:_.index,
|
|
628
632
|
cycleIndex:_.cycleIndex,repeatIndex:_.repeatIndex
|
|
629
633
|
});_.currentArgs=o(o({},_.args),{seed:e})
|
|
630
634
|
}else _.currentArgs=o({},_.args)
|
|
631
635
|
;return _.currentArgs}};return y}
|
|
632
636
|
e.createTestVariants=function(e){
|
|
633
|
-
return function(t){return function(n){var r,i
|
|
634
|
-
;return l(this,void 0,void 0,function(){var
|
|
635
|
-
;return
|
|
636
|
-
onError:null==n?void 0:n.onError}),
|
|
637
|
+
return function(t){return function(n){var r,i,s,o
|
|
638
|
+
;return l(this,void 0,void 0,function(){var l,c
|
|
639
|
+
;return a(this,function(a){return l=L(e,{
|
|
640
|
+
onError:null==n?void 0:n.onError}),c=ae({
|
|
637
641
|
argsTemplates:t,
|
|
638
642
|
getSeed:null===(r=null==n?void 0:n.findBestError)||void 0===r?void 0:r.getSeed,
|
|
639
|
-
repeatsPerVariant:null===(i=null==n?void 0:n.findBestError)||void 0===i?void 0:i.repeatsPerVariant
|
|
640
|
-
|
|
641
|
-
|
|
643
|
+
repeatsPerVariant:null===(i=null==n?void 0:n.findBestError)||void 0===i?void 0:i.repeatsPerVariant,
|
|
644
|
+
equals:null===(s=null==n?void 0:n.findBestError)||void 0===s?void 0:s.equals,
|
|
645
|
+
limitArgOnError:null===(o=null==n?void 0:n.findBestError)||void 0===o?void 0:o.limitArgOnError
|
|
646
|
+
}),[2,ee(l,c,n)]})})}}
|
|
647
|
+
},e.generateErrorVariantFilePath=f,e.testVariantsIterator=ae,
|
|
642
648
|
Object.defineProperty(e,"__esModule",{value:!0})
|
|
643
649
|
}({},fs,path);
|
|
@@ -18,7 +18,7 @@ require('path');
|
|
|
18
18
|
function createTestVariants(test) {
|
|
19
19
|
return function testVariantsArgs(args) {
|
|
20
20
|
return function testVariantsCall(options) {
|
|
21
|
-
var _a, _b;
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
22
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const testRun = testVariants_testVariantsCreateTestRun.testVariantsCreateTestRun(test, {
|
|
24
24
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
@@ -27,6 +27,8 @@ function createTestVariants(test) {
|
|
|
27
27
|
argsTemplates: args,
|
|
28
28
|
getSeed: (_a = options === null || options === void 0 ? void 0 : options.findBestError) === null || _a === void 0 ? void 0 : _a.getSeed,
|
|
29
29
|
repeatsPerVariant: (_b = options === null || options === void 0 ? void 0 : options.findBestError) === null || _b === void 0 ? void 0 : _b.repeatsPerVariant,
|
|
30
|
+
equals: (_c = options === null || options === void 0 ? void 0 : options.findBestError) === null || _c === void 0 ? void 0 : _c.equals,
|
|
31
|
+
limitArgOnError: (_d = options === null || options === void 0 ? void 0 : options.findBestError) === null || _d === void 0 ? void 0 : _d.limitArgOnError,
|
|
30
32
|
});
|
|
31
33
|
return testVariants_testVariantsRun.testVariantsRun(testRun, variants, options);
|
|
32
34
|
});
|
|
@@ -14,7 +14,7 @@ import 'path';
|
|
|
14
14
|
function createTestVariants(test) {
|
|
15
15
|
return function testVariantsArgs(args) {
|
|
16
16
|
return function testVariantsCall(options) {
|
|
17
|
-
var _a, _b;
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const testRun = testVariantsCreateTestRun(test, {
|
|
20
20
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
@@ -23,6 +23,8 @@ function createTestVariants(test) {
|
|
|
23
23
|
argsTemplates: args,
|
|
24
24
|
getSeed: (_a = options === null || options === void 0 ? void 0 : options.findBestError) === null || _a === void 0 ? void 0 : _a.getSeed,
|
|
25
25
|
repeatsPerVariant: (_b = options === null || options === void 0 ? void 0 : options.findBestError) === null || _b === void 0 ? void 0 : _b.repeatsPerVariant,
|
|
26
|
+
equals: (_c = options === null || options === void 0 ? void 0 : options.findBestError) === null || _c === void 0 ? void 0 : _c.equals,
|
|
27
|
+
limitArgOnError: (_d = options === null || options === void 0 ? void 0 : options.findBestError) === null || _d === void 0 ? void 0 : _d.limitArgOnError,
|
|
26
28
|
});
|
|
27
29
|
return testVariantsRun(testRun, variants, options);
|
|
28
30
|
});
|
|
@@ -25,11 +25,11 @@ export declare type LimitArgOnError = (options: LimitArgOnErrorOptions) => boole
|
|
|
25
25
|
/** Options for creating test variants iterator */
|
|
26
26
|
export declare type TestVariantsIteratorOptions<Args extends Obj> = {
|
|
27
27
|
argsTemplates: TestVariantsTemplates<Args>;
|
|
28
|
-
/** Custom equality for comparing arg values
|
|
28
|
+
/** Custom equality for comparing arg values */
|
|
29
29
|
equals?: null | ((a: any, b: any) => boolean);
|
|
30
30
|
/** Limit per-arg indexes on error; boolean enables/disables, function for custom per-arg logic */
|
|
31
31
|
limitArgOnError?: null | boolean | LimitArgOnError;
|
|
32
|
-
/**
|
|
32
|
+
/** Generates seed for reproducible randomized testing; seed is added to args */
|
|
33
33
|
getSeed?: null | ((params: GetSeedParams) => any);
|
|
34
34
|
/** Number of repeat tests per variant within each cycle */
|
|
35
35
|
repeatsPerVariant?: null | number;
|
|
@@ -49,15 +49,15 @@ export declare type AddLimitOptions<Args> = {
|
|
|
49
49
|
export declare type TestVariantsIterator<Args extends Obj> = {
|
|
50
50
|
/** Current variant index; -1 before first next() */
|
|
51
51
|
readonly index: number;
|
|
52
|
-
/** Current cycle index;
|
|
52
|
+
/** Current cycle index; starts at 0 after first start() */
|
|
53
53
|
readonly cycleIndex: number;
|
|
54
|
-
/**
|
|
54
|
+
/** Maximum variant count; variants with index >= count are not yielded */
|
|
55
55
|
readonly count: number | null;
|
|
56
|
-
/** Last applied limit's args and error; null if no limit applied
|
|
56
|
+
/** Last applied limit's args and error; null if no args-based limit applied */
|
|
57
57
|
readonly limit: TestVariantsIteratorLimit<Args> | null;
|
|
58
|
-
/** Add or tighten limit
|
|
58
|
+
/** Add or tighten limit */
|
|
59
59
|
addLimit(options?: null | AddLimitOptions<Args>): void;
|
|
60
|
-
/** Reset to beginning of iteration
|
|
60
|
+
/** Reset to beginning of iteration for next cycle */
|
|
61
61
|
start(): void;
|
|
62
62
|
/** Get next variant or null when done */
|
|
63
63
|
next(): Args | null;
|
|
@@ -61,6 +61,8 @@ function testVariantsRun(testRun, variants, options = {}) {
|
|
|
61
61
|
const abortSignalExternal = options.abortSignal;
|
|
62
62
|
const findBestError = options.findBestError;
|
|
63
63
|
const cycles = (_j = findBestError === null || findBestError === void 0 ? void 0 : findBestError.cycles) !== null && _j !== void 0 ? _j : 1;
|
|
64
|
+
const dontThrowIfError = findBestError === null || findBestError === void 0 ? void 0 : findBestError.dontThrowIfError;
|
|
65
|
+
const limitTime = options.limitTime;
|
|
64
66
|
const parallel = options.parallel === true
|
|
65
67
|
? Math.pow(2, 31)
|
|
66
68
|
: !options.parallel || options.parallel <= 0
|
|
@@ -120,13 +122,18 @@ function testVariantsRun(testRun, variants, options = {}) {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
// Main iteration using iterator
|
|
125
|
+
let timeLimitExceeded = false;
|
|
123
126
|
variants.start();
|
|
124
|
-
while (variants.cycleIndex < cycles) {
|
|
127
|
+
while (variants.cycleIndex < cycles && !timeLimitExceeded) {
|
|
125
128
|
let args;
|
|
126
129
|
while (!(abortSignalExternal === null || abortSignalExternal === void 0 ? void 0 : abortSignalExternal.aborted) && (debug || (args = variants.next()) != null)) {
|
|
127
130
|
const _index = variants.index;
|
|
128
131
|
const _args = args;
|
|
129
|
-
const now = (logInterval || GC_Interval) && Date.now();
|
|
132
|
+
const now = (logInterval || GC_Interval || limitTime) && Date.now();
|
|
133
|
+
if (limitTime && now - startTime >= limitTime) {
|
|
134
|
+
timeLimitExceeded = true;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
130
137
|
if (logInterval && now - prevLogTime >= logInterval) {
|
|
131
138
|
// the log is required to prevent the karma browserNoActivityTimeout
|
|
132
139
|
let log = '';
|
|
@@ -269,6 +276,9 @@ function testVariantsRun(testRun, variants, options = {}) {
|
|
|
269
276
|
index: variants.count,
|
|
270
277
|
}
|
|
271
278
|
: null;
|
|
279
|
+
if (bestError && !dontThrowIfError) {
|
|
280
|
+
throw bestError.error;
|
|
281
|
+
}
|
|
272
282
|
return {
|
|
273
283
|
iterations,
|
|
274
284
|
bestError,
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { TestVariantsTestRun } from './testVariantsCreateTestRun';
|
|
2
2
|
import { type IAbortSignalFast } from '@flemist/abort-controller-fast';
|
|
3
3
|
import { Obj, type SaveErrorVariantsOptions } from "./types";
|
|
4
|
-
import { TestVariantsIterator, type GetSeedParams } from './testVariantsIterator';
|
|
4
|
+
import { TestVariantsIterator, type GetSeedParams, type LimitArgOnError } from './testVariantsIterator';
|
|
5
5
|
/** Options for finding the earliest failing variant across multiple test runs */
|
|
6
6
|
export declare type TestVariantsFindBestErrorOptions = {
|
|
7
7
|
/** Number of full passes through all variants */
|
|
8
8
|
cycles: number;
|
|
9
|
-
/**
|
|
9
|
+
/** Generates seed for reproducible randomized testing; seed is added to args */
|
|
10
10
|
getSeed?: null | ((params: GetSeedParams) => any);
|
|
11
|
-
/** Number of repeat tests per variant within each cycle
|
|
11
|
+
/** Number of repeat tests per variant within each cycle */
|
|
12
12
|
repeatsPerVariant?: null | number;
|
|
13
|
+
/** Custom equality for comparing arg values when finding indexes */
|
|
14
|
+
equals?: null | ((a: any, b: any) => boolean);
|
|
15
|
+
/** Limit per-arg indexes on error; boolean enables/disables, function for custom per-arg logic */
|
|
16
|
+
limitArgOnError?: null | boolean | LimitArgOnError;
|
|
17
|
+
/** Return found error instead of throwing after all cycles complete */
|
|
18
|
+
dontThrowIfError?: null | boolean;
|
|
13
19
|
};
|
|
14
20
|
export declare type TestVariantsRunOptions<Args extends Obj = Obj, SavedArgs = Args> = {
|
|
15
21
|
/** Wait for garbage collection after iterations */
|
|
@@ -29,6 +35,8 @@ export declare type TestVariantsRunOptions<Args extends Obj = Obj, SavedArgs = A
|
|
|
29
35
|
saveErrorVariants?: null | SaveErrorVariantsOptions<Args, SavedArgs>;
|
|
30
36
|
/** Tests only first N variants, ignores the rest. If null or not specified, tests all variants */
|
|
31
37
|
limitVariantsCount?: null | number;
|
|
38
|
+
/** Maximum test run duration in milliseconds; when exceeded, iteration stops and current results are returned */
|
|
39
|
+
limitTime?: null | number;
|
|
32
40
|
};
|
|
33
41
|
export declare type TestVariantsBestError<Args extends Obj> = {
|
|
34
42
|
error: any;
|
|
@@ -37,6 +37,8 @@ function testVariantsRun(testRun, variants, options = {}) {
|
|
|
37
37
|
const abortSignalExternal = options.abortSignal;
|
|
38
38
|
const findBestError = options.findBestError;
|
|
39
39
|
const cycles = (_j = findBestError === null || findBestError === void 0 ? void 0 : findBestError.cycles) !== null && _j !== void 0 ? _j : 1;
|
|
40
|
+
const dontThrowIfError = findBestError === null || findBestError === void 0 ? void 0 : findBestError.dontThrowIfError;
|
|
41
|
+
const limitTime = options.limitTime;
|
|
40
42
|
const parallel = options.parallel === true
|
|
41
43
|
? Math.pow(2, 31)
|
|
42
44
|
: !options.parallel || options.parallel <= 0
|
|
@@ -96,13 +98,18 @@ function testVariantsRun(testRun, variants, options = {}) {
|
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
// Main iteration using iterator
|
|
101
|
+
let timeLimitExceeded = false;
|
|
99
102
|
variants.start();
|
|
100
|
-
while (variants.cycleIndex < cycles) {
|
|
103
|
+
while (variants.cycleIndex < cycles && !timeLimitExceeded) {
|
|
101
104
|
let args;
|
|
102
105
|
while (!(abortSignalExternal === null || abortSignalExternal === void 0 ? void 0 : abortSignalExternal.aborted) && (debug || (args = variants.next()) != null)) {
|
|
103
106
|
const _index = variants.index;
|
|
104
107
|
const _args = args;
|
|
105
|
-
const now = (logInterval || GC_Interval) && Date.now();
|
|
108
|
+
const now = (logInterval || GC_Interval || limitTime) && Date.now();
|
|
109
|
+
if (limitTime && now - startTime >= limitTime) {
|
|
110
|
+
timeLimitExceeded = true;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
106
113
|
if (logInterval && now - prevLogTime >= logInterval) {
|
|
107
114
|
// the log is required to prevent the karma browserNoActivityTimeout
|
|
108
115
|
let log = '';
|
|
@@ -245,6 +252,9 @@ function testVariantsRun(testRun, variants, options = {}) {
|
|
|
245
252
|
index: variants.count,
|
|
246
253
|
}
|
|
247
254
|
: null;
|
|
255
|
+
if (bestError && !dontThrowIfError) {
|
|
256
|
+
throw bestError.error;
|
|
257
|
+
}
|
|
248
258
|
return {
|
|
249
259
|
iterations,
|
|
250
260
|
bestError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemist/test-variants",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Runs a test function with all possible combinations of its parameters.",
|
|
5
5
|
"main": "dist/lib/index.cjs",
|
|
6
6
|
"module": "dist/lib/index.mjs",
|
|
@@ -32,6 +32,24 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"_prepublishOnly": "pnpm run audit && pnpm run lint && pnpm run build && pnpm run test:mocha:ci && npm login",
|
|
37
|
+
"audit": "pnpm audit --prod",
|
|
38
|
+
"lint": "eslint ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
39
|
+
"lint:fix": "eslint --fix ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
40
|
+
"lint:wizard": "eslint-nibble --cache --multi ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
41
|
+
"build:js": "rimraf dist/lib && cpy \"**/assets/**\" \"**/*.{js,cjs,mjs}\" \"../dist/lib/\" --parents --cwd=src && rollup -c",
|
|
42
|
+
"build": "rimraf dist && pnpm run build:js",
|
|
43
|
+
"coverage:merge": "rimraf tmp/coverage/{all,merge} && cp-flat \"tmp/coverage/*/json/**/*.json\" \"tmp/coverage/merge\" && nyc report -r lcov --report-dir tmp/coverage/all/lcov --temp-dir \"tmp/coverage/merge/\"",
|
|
44
|
+
"coverage:check": "pnpm run coverage:merge && nyc check-coverage --report-dir tmp/coverage/all/lcov --lines 50 --functions 50 --branches 50 --statements 50",
|
|
45
|
+
"test:mocha": "mocha ./src/**/*.test.*",
|
|
46
|
+
"test:mocha:coverage": "rimraf tmp/coverage/mocha && nyc --all mocha ./src/**/*.test.*",
|
|
47
|
+
"test:mocha:watch": "mocha --watch ./src/**/*.test.*",
|
|
48
|
+
"test:karma": "rimraf tmp/coverage/karma && karma start --single-run --log-level debug",
|
|
49
|
+
"test:mocha:ci": "rimraf tmp/coverage/mocha && nyc --all mocha ./{src,dist/lib}/**/*.test.*",
|
|
50
|
+
"coveralls": "pnpm run coverage:check && nyc report --reporter=text-lcov --temp-dir \"tmp/coverage/merge/\" | coveralls",
|
|
51
|
+
"mcp:tools": "mcp-project-tools"
|
|
52
|
+
},
|
|
35
53
|
"devDependencies": {
|
|
36
54
|
"@anthropic-ai/claude-code": "^2.0.76",
|
|
37
55
|
"@babel/core": "7.18.5",
|
|
@@ -87,22 +105,5 @@
|
|
|
87
105
|
"@flemist/async-utils": "^1.0.0",
|
|
88
106
|
"@flemist/time-limits": "^1.0.1",
|
|
89
107
|
"tslib": "2.5.3"
|
|
90
|
-
},
|
|
91
|
-
"scripts": {
|
|
92
|
-
"audit": "pnpm audit --prod",
|
|
93
|
-
"lint": "eslint ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
94
|
-
"lint:fix": "eslint --fix ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
95
|
-
"lint:wizard": "eslint-nibble --cache --multi ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
96
|
-
"build:js": "rimraf dist/lib && cpy \"**/assets/**\" \"**/*.{js,cjs,mjs}\" \"../dist/lib/\" --parents --cwd=src && rollup -c",
|
|
97
|
-
"build": "rimraf dist && pnpm run build:js",
|
|
98
|
-
"coverage:merge": "rimraf tmp/coverage/{all,merge} && cp-flat \"tmp/coverage/*/json/**/*.json\" \"tmp/coverage/merge\" && nyc report -r lcov --report-dir tmp/coverage/all/lcov --temp-dir \"tmp/coverage/merge/\"",
|
|
99
|
-
"coverage:check": "pnpm run coverage:merge && nyc check-coverage --report-dir tmp/coverage/all/lcov --lines 50 --functions 50 --branches 50 --statements 50",
|
|
100
|
-
"test:mocha": "mocha ./src/**/*.test.*",
|
|
101
|
-
"test:mocha:coverage": "rimraf tmp/coverage/mocha && nyc --all mocha ./src/**/*.test.*",
|
|
102
|
-
"test:mocha:watch": "mocha --watch ./src/**/*.test.*",
|
|
103
|
-
"test:karma": "rimraf tmp/coverage/karma && karma start --single-run --log-level debug",
|
|
104
|
-
"test:mocha:ci": "rimraf tmp/coverage/mocha && nyc --all mocha ./{src,dist/lib}/**/*.test.*",
|
|
105
|
-
"coveralls": "pnpm run coverage:check && nyc report --reporter=text-lcov --temp-dir \"tmp/coverage/merge/\" | coveralls",
|
|
106
|
-
"mcp:tools": "mcp-project-tools"
|
|
107
108
|
}
|
|
108
|
-
}
|
|
109
|
+
}
|