@flemist/test-variants 2.0.2 → 2.0.4

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.
@@ -448,71 +448,75 @@ setTimeout(function(){e(t)},1)})
448
448
  var r,s,d,v,_,y,b,p,m
449
449
  ;return void 0===n&&(n={}),c(this,void 0,void 0,function(){
450
450
  function w(){
451
+ return null!=U&&null!=Q?Math.min(U,Q.index):null!=U?U:null!=Q?Q.index:null
452
+ }function j(){
451
453
  return c(this,void 0,void 0,function(){
452
454
  var n,r=this;return l(this,function(s){
453
455
  switch(s.label){case 0:n=function(){
454
- var e,n,s,i,a,u,h,d;return l(this,function(v){
455
- switch(v.label){case 0:return e=L,n=o(o({},Q),{
456
- seed:q
457
- }),s=(V||C)&&Date.now(),V&&s-st>=V&&(i="",i+=N?"cycle: ".concat(U,", variant: ").concat(L,"/").concat(G):"variant: ".concat(L),
458
- i+=", total: ".concat(nt),
459
- console.log(i),st=s),F&&nt-ot>=F||D&&rt-ct>=D||C&&s-it>=C?(ot=nt,
460
- ct=rt,it=s,[4,Y(1)]):[3,2];case 1:
461
- v.sent(),v.label=2;case 2:
462
- if(null==J?void 0:J.aborted)return[2,"continue"]
463
- ;if(lt&&!Z.aborted)return[3,10];v.label=3;case 3:
464
- return v.trys.push([3,6,,9]),g(a=t(n,e,Z))?[4,a]:[3,5]
465
- ;case 4:a=v.sent(),v.label=5;case 5:
466
- return a?(u=a.iterationsAsync,h=a.iterationsSync,
467
- rt+=u,nt+=h+u,[3,9]):(et=!0,H.abort(),
456
+ var e,n,s,i,a,u,h,d,v;return l(this,function(_){
457
+ switch(_.label){case 0:return e=K,n=o(o({},H),{
458
+ seed:L
459
+ }),s=(R||V)&&Date.now(),R&&s-ot>=R&&(i="",$?(i+="cycle: ".concat(q,", variant: ").concat(K),
460
+ q>0&&null!=(a=w())&&(null!=W&&W<a&&(a=W),
461
+ i+="/".concat(a))):i+="variant: ".concat(K),
462
+ i+=", total: ".concat(st),console.log(i),
463
+ ot=s),D&&st-lt>=D||C&&it-at>=C||V&&s-ct>=V?(lt=st,
464
+ at=it,ct=s,[4,Y(1)]):[3,2];case 1:
465
+ _.sent(),_.label=2;case 2:
466
+ if(null==N?void 0:N.aborted)return[2,"continue"]
467
+ ;if(ut&&!et.aborted)return[3,10];_.label=3;case 3:
468
+ return _.trys.push([3,6,,9]),g(u=t(n,e,et))?[4,u]:[3,5]
469
+ ;case 4:u=_.sent(),_.label=5;case 5:
470
+ return u?(h=u.iterationsAsync,d=u.iterationsSync,
471
+ it+=h,st+=d+h,[3,9]):(rt=!0,tt.abort(),
468
472
  [2,"continue"]);case 6:
469
- return d=v.sent(),E?[4,f(n,E,j.argsToJson)]:[3,8]
470
- ;case 7:v.sent(),v.label=8;case 8:if(!N)throw d
471
- ;return B={error:d,args:n,index:e},et=!1,[3,9]
473
+ return v=_.sent(),P?[4,f(n,P,S.argsToJson)]:[3,8]
474
+ ;case 7:_.sent(),_.label=8;case 8:if(!$)throw v
475
+ ;return Q={error:v,args:n,index:e},rt=!1,[3,9]
472
476
  ;case 9:return[3,13];case 10:
473
- return lt.hold(1)?[3,12]:[4,lt.holdWait(1)]
474
- ;case 11:v.sent(),v.label=12;case 12:
477
+ return ut.hold(1)?[3,12]:[4,ut.holdWait(1)]
478
+ ;case 11:_.sent(),_.label=12;case 12:
475
479
  c(r,void 0,void 0,function(){var r,s,i,o
476
480
  ;return l(this,function(c){switch(c.label){case 0:
477
481
  return c.trys.push([0,3,6,7]),
478
- (null==Z?void 0:Z.aborted)?[2]:g(r=t(n,e,Z))?[4,r]:[3,2]
482
+ (null==et?void 0:et.aborted)?[2]:g(r=t(n,e,et))?[4,r]:[3,2]
479
483
  ;case 1:r=c.sent(),c.label=2;case 2:
480
484
  return r?(s=r.iterationsAsync,i=r.iterationsSync,
481
- rt+=s,nt+=i+s,[3,7]):(et=!0,H.abort(),[2]);case 3:
482
- return o=c.sent(),E?[4,f(n,E,j.argsToJson)]:[3,5]
483
- ;case 4:c.sent(),c.label=5;case 5:if(!N)throw o
484
- ;return B={error:o,args:n,index:e},et=!1,[3,7]
485
- ;case 6:return lt.release(1),[7];case 7:return[2]}
486
- })}),v.label=13;case 13:return[2]}})},s.label=1
485
+ it+=s,st+=i+s,[3,7]):(rt=!0,tt.abort(),[2])
486
+ ;case 3:
487
+ return o=c.sent(),P?[4,f(n,P,S.argsToJson)]:[3,5]
488
+ ;case 4:c.sent(),c.label=5;case 5:if(!$)throw o
489
+ ;return Q={error:o,args:n,index:e},rt=!1,[3,7]
490
+ ;case 6:return ut.release(1),[7];case 7:return[2]}
491
+ })}),_.label=13;case 13:return[2]}})},s.label=1
487
492
  ;case 1:
488
- return(null==J?void 0:J.aborted)||!et&&!function(){
493
+ return(null==N?void 0:N.aborted)||!rt&&!function(){
489
494
  for(;;){
490
- if(N&&L>=0&&(null==B||L<B.index)&&++W<N.repeatsPerVariant)return q=N.getSeed({
491
- variantIndex:L,cycleIndex:U,repeatIndex:W,
492
- totalIndex:U*N.repeatsPerVariant+W}),!0
493
- ;if(W=0,L++,N&&U>=N.cycles)return!1
494
- ;if((null==G||L<G)&&(null==B||L<B.index)){
495
- var t=K.next()
496
- ;if(!t.done)return Q=t.value,N&&(q=N.getSeed({
497
- variantIndex:L,cycleIndex:U,repeatIndex:W,
498
- totalIndex:U*N.repeatsPerVariant+W})),!0}
499
- if(!N)return!1;if(++U>=N.cycles)return!1
500
- ;L=-1,K=e[Symbol.iterator]()}}()?[3,3]:[5,n()]
495
+ if($&&K>=0&&(null==Q||K<Q.index)&&++B<$.repeatsPerVariant)return L=$.getSeed({
496
+ variantIndex:K,cycleIndex:q,repeatIndex:B,
497
+ totalIndex:q*$.repeatsPerVariant+B}),!0
498
+ ;if(B=0,K++,$&&q>=$.cycles)return!1;var t=w()
499
+ ;if(null==t||K<t){var n=Z.next()
500
+ ;if(!n.done)return H=n.value,$&&(L=$.getSeed({
501
+ variantIndex:K,cycleIndex:q,repeatIndex:B,
502
+ totalIndex:q*$.repeatsPerVariant+B})),!0}
503
+ if(!$)return!1;if(W=K,++q>=$.cycles)return!1
504
+ ;K=-1,Z=e[Symbol.iterator]()}}()?[3,3]:[5,n()]
501
505
  ;case 2:return s.sent(),[3,1];case 3:
502
- return lt?[4,lt.holdWait($)]:[3,5];case 4:
503
- s.sent(),lt.release($),s.label=5;case 5:
504
- if(null==tt?void 0:tt.aborted)throw tt.reason
505
- ;return R&&console.log("[test-variants] variants: ".concat(L,", iterations: ").concat(nt,", async: ").concat(rt)),
506
- [4,Y(1)];case 6:return s.sent(),[2,nt]}})})}
507
- var j,S,x,E,P,A,k,T,z,O,M,F,D,C,V,R,J,N,$,G,U,W,q,B,L,Q,K,H,Z,tt,et,nt,rt,st,it,ot,ct,lt,at,ut
506
+ return ut?[4,ut.holdWait(G)]:[3,5];case 4:
507
+ s.sent(),ut.release(G),s.label=5;case 5:
508
+ if(null==nt?void 0:nt.aborted)throw nt.reason
509
+ ;return J&&console.log("[test-variants] variants: ".concat(K,", iterations: ").concat(st,", async: ").concat(it)),
510
+ [4,Y(1)];case 6:return s.sent(),[2,st]}})})}
511
+ var S,x,E,P,A,k,T,z,O,M,F,D,C,V,R,J,N,$,G,U,W,q,B,L,Q,K,H,Z,tt,et,nt,rt,st,it,ot,ct,lt,at,ut,ht,ft
508
512
  ;return l(this,function(o){switch(o.label){case 0:
509
- return j=n.saveErrorVariants,S=null!==(r=null==j?void 0:j.retriesPerVariant)&&void 0!==r?r:1,
510
- x=new Date,
511
- E=j?i.resolve(j.dir,null!==(d=null===(s=j.getFilePath)||void 0===s?void 0:s.call(j,{
512
- sessionDate:x}))&&void 0!==d?d:h({sessionDate:x
513
- })):null,j?[4,a(j.dir)]:[3,12];case 1:
514
- P=o.sent(),o.label=2;case 2:
515
- o.trys.push([2,10,11,12]),A=function(t){
513
+ return S=n.saveErrorVariants,x=null!==(r=null==S?void 0:S.retriesPerVariant)&&void 0!==r?r:1,
514
+ E=new Date,
515
+ P=S?i.resolve(S.dir,null!==(d=null===(s=S.getFilePath)||void 0===s?void 0:s.call(S,{
516
+ sessionDate:E}))&&void 0!==d?d:h({sessionDate:E
517
+ })):null,S?[4,a(S.dir)]:[3,12];case 1:
518
+ A=o.sent(),o.label=2;case 2:
519
+ o.trys.push([2,10,11,12]),k=function(t){
516
520
  var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0
517
521
  ;if(n)return n.call(t)
518
522
  ;if(t&&"number"==typeof t.length)return{
@@ -520,33 +524,33 @@ next:function(){
520
524
  return t&&r>=t.length&&(t=void 0),{
521
525
  value:t&&t[r++],done:!t}}}
522
526
  ;throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")
523
- }(P),k=A.next(),o.label=3;case 3:
524
- return k.done?[3,9]:[4,u(k.value,j.jsonToArgs)]
525
- ;case 4:T=o.sent(),z=0,o.label=5;case 5:
526
- return z<S?g(O=t(T,-1,null))?[4,O]:[3,7]:[3,8]
527
- ;case 6:o.sent(),o.label=7;case 7:return z++,[3,5]
528
- ;case 8:return k=A.next(),[3,3];case 9:
529
- return[3,12];case 10:return M=o.sent(),at={error:M
527
+ }(A),T=k.next(),o.label=3;case 3:
528
+ return T.done?[3,9]:[4,u(T.value,S.jsonToArgs)]
529
+ ;case 4:z=o.sent(),O=0,o.label=5;case 5:
530
+ return O<x?g(M=t(z,-1,null))?[4,M]:[3,7]:[3,8]
531
+ ;case 6:o.sent(),o.label=7;case 7:return O++,[3,5]
532
+ ;case 8:return T=k.next(),[3,3];case 9:
533
+ return[3,12];case 10:return F=o.sent(),ht={error:F
530
534
  },[3,12];case 11:try{
531
- k&&!k.done&&(ut=A.return)&&ut.call(A)}finally{
532
- if(at)throw at.error}return[7];case 12:
533
- return F=null!==(v=n.GC_Iterations)&&void 0!==v?v:1e6,
534
- D=null!==(_=n.GC_IterationsAsync)&&void 0!==_?_:1e4,
535
- C=null!==(y=n.GC_Interval)&&void 0!==y?y:1e3,
536
- V=null!==(b=n.logInterval)&&void 0!==b?b:5e3,
537
- R=null===(p=n.logCompleted)||void 0===p||p,
538
- J=n.abortSignal,N=n.findBestError,$=!0===n.parallel?Math.pow(2,31):!n.parallel||n.parallel<=0?1:n.parallel,
539
- G=null!==(m=n.limitVariantsCount)&&void 0!==m?m:null,
540
- U=0,W=0,q=void 0,B=null,L=-1,
541
- Q={},K=e[Symbol.iterator](),H=new I,Z=function(...t){
535
+ T&&!T.done&&(ft=k.return)&&ft.call(k)}finally{
536
+ if(ht)throw ht.error}return[7];case 12:
537
+ return D=null!==(v=n.GC_Iterations)&&void 0!==v?v:1e6,
538
+ C=null!==(_=n.GC_IterationsAsync)&&void 0!==_?_:1e4,
539
+ V=null!==(y=n.GC_Interval)&&void 0!==y?y:1e3,
540
+ R=null!==(b=n.logInterval)&&void 0!==b?b:5e3,
541
+ J=null===(p=n.logCompleted)||void 0===p||p,
542
+ N=n.abortSignal,$=n.findBestError,G=!0===n.parallel?Math.pow(2,31):!n.parallel||n.parallel<=0?1:n.parallel,
543
+ U=null!==(m=n.limitVariantsCount)&&void 0!==m?m:null,
544
+ W=null,q=0,B=0,L=void 0,Q=null,
545
+ K=-1,H={},Z=e[Symbol.iterator](),tt=new I,et=function(...t){
542
546
  let e,n;function r(t){e.abort(t)}
543
547
  for(let s=0;s<t.length;s++){const i=t[s];if(i){
544
548
  if(i.aborted)return i
545
549
  ;n?(e||(e=new I,n.subscribe(r)),i.subscribe(r)):n=i
546
550
  }}return e?e.signal:n||(new I).signal
547
- }(J,H.signal),tt=Z,et=!1,nt=0,rt=0,st=Date.now(),
548
- it=st,ot=nt,ct=rt,lt=$<=1?null:new X($),[4,w()]
549
- ;case 13:return[2,{iterations:o.sent(),bestError:B
551
+ }(N,tt.signal),nt=et,rt=!1,st=0,it=0,ot=Date.now(),
552
+ ct=ot,lt=st,at=it,ut=G<=1?null:new X(G),[4,j()]
553
+ ;case 13:return[2,{iterations:o.sent(),bestError:Q
550
554
  }]}})})}t.createTestVariants=function(t){
551
555
  return function(e){return function(n){
552
556
  return c(this,void 0,void 0,function(){var r,s
@@ -66,6 +66,7 @@ function testVariantsRun(testRun, variants, options = {}) {
66
66
  ? 1
67
67
  : options.parallel;
68
68
  const limitVariantsCount = (_j = options.limitVariantsCount) !== null && _j !== void 0 ? _j : null;
69
+ let prevCycleVariantsCount = null;
69
70
  let cycleIndex = 0;
70
71
  let repeatIndex = 0;
71
72
  let seed = void 0;
@@ -73,6 +74,18 @@ function testVariantsRun(testRun, variants, options = {}) {
73
74
  let index = -1;
74
75
  let args = {};
75
76
  let variantsIterator = variants[Symbol.iterator]();
77
+ function getLimitVariantsCount() {
78
+ if (limitVariantsCount != null && bestError != null) {
79
+ return Math.min(limitVariantsCount, bestError.index);
80
+ }
81
+ if (limitVariantsCount != null) {
82
+ return limitVariantsCount;
83
+ }
84
+ if (bestError != null) {
85
+ return bestError.index;
86
+ }
87
+ return null;
88
+ }
76
89
  function nextVariant() {
77
90
  while (true) {
78
91
  // Try next repeat for current variant
@@ -93,8 +106,8 @@ function testVariantsRun(testRun, variants, options = {}) {
93
106
  if (findBestError && cycleIndex >= findBestError.cycles) {
94
107
  return false;
95
108
  }
96
- if ((limitVariantsCount == null || index < limitVariantsCount)
97
- && (bestError == null || index < bestError.index)) {
109
+ const _limitVariantsCount = getLimitVariantsCount();
110
+ if (_limitVariantsCount == null || index < _limitVariantsCount) {
98
111
  const result = variantsIterator.next();
99
112
  if (!result.done) {
100
113
  args = result.value;
@@ -112,6 +125,7 @@ function testVariantsRun(testRun, variants, options = {}) {
112
125
  if (!findBestError) {
113
126
  return false;
114
127
  }
128
+ prevCycleVariantsCount = index;
115
129
  cycleIndex++;
116
130
  if (cycleIndex >= findBestError.cycles) {
117
131
  return false;
@@ -148,7 +162,16 @@ function testVariantsRun(testRun, variants, options = {}) {
148
162
  // the log is required to prevent the karma browserNoActivityTimeout
149
163
  let log = '';
150
164
  if (findBestError) {
151
- log += `cycle: ${cycleIndex}, variant: ${index}/${limitVariantsCount}`;
165
+ log += `cycle: ${cycleIndex}, variant: ${index}`;
166
+ if (cycleIndex > 0) {
167
+ let max = getLimitVariantsCount();
168
+ if (max != null) {
169
+ if (prevCycleVariantsCount != null && prevCycleVariantsCount < max) {
170
+ max = prevCycleVariantsCount;
171
+ }
172
+ log += `/${max}`;
173
+ }
174
+ }
152
175
  }
153
176
  else {
154
177
  log += `variant: ${index}`;
@@ -42,6 +42,7 @@ function testVariantsRun(testRun, variants, options = {}) {
42
42
  ? 1
43
43
  : options.parallel;
44
44
  const limitVariantsCount = (_j = options.limitVariantsCount) !== null && _j !== void 0 ? _j : null;
45
+ let prevCycleVariantsCount = null;
45
46
  let cycleIndex = 0;
46
47
  let repeatIndex = 0;
47
48
  let seed = void 0;
@@ -49,6 +50,18 @@ function testVariantsRun(testRun, variants, options = {}) {
49
50
  let index = -1;
50
51
  let args = {};
51
52
  let variantsIterator = variants[Symbol.iterator]();
53
+ function getLimitVariantsCount() {
54
+ if (limitVariantsCount != null && bestError != null) {
55
+ return Math.min(limitVariantsCount, bestError.index);
56
+ }
57
+ if (limitVariantsCount != null) {
58
+ return limitVariantsCount;
59
+ }
60
+ if (bestError != null) {
61
+ return bestError.index;
62
+ }
63
+ return null;
64
+ }
52
65
  function nextVariant() {
53
66
  while (true) {
54
67
  // Try next repeat for current variant
@@ -69,8 +82,8 @@ function testVariantsRun(testRun, variants, options = {}) {
69
82
  if (findBestError && cycleIndex >= findBestError.cycles) {
70
83
  return false;
71
84
  }
72
- if ((limitVariantsCount == null || index < limitVariantsCount)
73
- && (bestError == null || index < bestError.index)) {
85
+ const _limitVariantsCount = getLimitVariantsCount();
86
+ if (_limitVariantsCount == null || index < _limitVariantsCount) {
74
87
  const result = variantsIterator.next();
75
88
  if (!result.done) {
76
89
  args = result.value;
@@ -88,6 +101,7 @@ function testVariantsRun(testRun, variants, options = {}) {
88
101
  if (!findBestError) {
89
102
  return false;
90
103
  }
104
+ prevCycleVariantsCount = index;
91
105
  cycleIndex++;
92
106
  if (cycleIndex >= findBestError.cycles) {
93
107
  return false;
@@ -124,7 +138,16 @@ function testVariantsRun(testRun, variants, options = {}) {
124
138
  // the log is required to prevent the karma browserNoActivityTimeout
125
139
  let log = '';
126
140
  if (findBestError) {
127
- log += `cycle: ${cycleIndex}, variant: ${index}/${limitVariantsCount}`;
141
+ log += `cycle: ${cycleIndex}, variant: ${index}`;
142
+ if (cycleIndex > 0) {
143
+ let max = getLimitVariantsCount();
144
+ if (max != null) {
145
+ if (prevCycleVariantsCount != null && prevCycleVariantsCount < max) {
146
+ max = prevCycleVariantsCount;
147
+ }
148
+ log += `/${max}`;
149
+ }
150
+ }
128
151
  }
129
152
  else {
130
153
  log += `variant: ${index}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemist/test-variants",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",