@flemist/test-variants 0.0.12 → 0.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/dist/bundle/browser.js +76 -31
- package/dist/lib/garbage-collect/garbageCollect.cjs +30 -0
- package/dist/lib/garbage-collect/garbageCollect.d.ts +2 -0
- package/dist/lib/garbage-collect/garbageCollect.mjs +26 -0
- package/dist/lib/index.cjs +2 -0
- package/dist/lib/index.mjs +2 -0
- package/dist/lib/test-variants/createTestVariants.cjs +66 -47
- package/dist/lib/test-variants/createTestVariants.d.ts +14 -6
- package/dist/lib/test-variants/createTestVariants.mjs +66 -47
- package/dist/lib/test-variants/createTestVariants.perf.cjs +2 -0
- package/dist/lib/test-variants/createTestVariants.perf.mjs +2 -0
- package/package.json +5 -5
package/dist/bundle/browser.js
CHANGED
|
@@ -1,33 +1,78 @@
|
|
|
1
|
-
!function(e){"use strict"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
;
|
|
20
|
-
|
|
21
|
-
;
|
|
22
|
-
|
|
23
|
-
;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
!function(e){"use strict";function n(e,n,t,r){
|
|
2
|
+
return new(t||(t=Promise))((function(o,a){
|
|
3
|
+
function i(e){try{c(r.next(e))}catch(e){a(e)}}
|
|
4
|
+
function u(e){try{c(r.throw(e))}catch(e){a(e)}}
|
|
5
|
+
function c(e){var n
|
|
6
|
+
;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){
|
|
7
|
+
e(n)}))).then(i,u)}c((r=r.apply(e,n||[])).next())
|
|
8
|
+
}))}function t(e,n){var t,r,o,a,i={label:0,
|
|
9
|
+
sent:function(){if(1&o[0])throw o[1];return o[1]},
|
|
10
|
+
trys:[],ops:[]};return a={next:u(0),throw:u(1),
|
|
11
|
+
return:u(2)
|
|
12
|
+
},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){
|
|
13
|
+
return this}),a;function u(a){return function(u){
|
|
14
|
+
return function(a){
|
|
15
|
+
if(t)throw new TypeError("Generator is already executing.")
|
|
16
|
+
;for(;i;)try{
|
|
17
|
+
if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),
|
|
18
|
+
0):r.next)&&!(o=o.call(r,a[1])).done)return o
|
|
19
|
+
;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:
|
|
20
|
+
case 1:o=a;break;case 4:return i.label++,{
|
|
21
|
+
value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0]
|
|
22
|
+
;continue;case 7:a=i.ops.pop(),i.trys.pop()
|
|
23
|
+
;continue;default:
|
|
24
|
+
if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){
|
|
25
|
+
i=0;continue}
|
|
26
|
+
if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){
|
|
27
|
+
i.label=a[1];break}if(6===a[0]&&i.label<o[1]){
|
|
28
|
+
i.label=o[1],o=a;break}if(o&&i.label<o[2]){
|
|
29
|
+
i.label=o[2],i.ops.push(a);break}
|
|
30
|
+
o[2]&&i.ops.pop(),i.trys.pop();continue}
|
|
31
|
+
a=n.call(e,i)}catch(e){a=[6,e],r=0}finally{t=o=0}
|
|
32
|
+
if(5&a[0])throw a[1];return{
|
|
33
|
+
value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}
|
|
34
|
+
function r(e){
|
|
35
|
+
if(null==e||e<=0)throw new Error("Iterations = ".concat(e))
|
|
36
|
+
;e--;var n=new Promise((function(n){
|
|
37
|
+
setTimeout((function(){n(e)}),1)}))
|
|
38
|
+
;return e<=0?n:n.then(r)}
|
|
39
|
+
e.createTestVariants=function(e){
|
|
40
|
+
return function(o){return function(a){
|
|
41
|
+
var i=void 0===a?{}:a,u=i.GC_Iterations,c=void 0===u?1e6:u,l=i.GC_IterationsAsync,s=void 0===l?1e4:l,f=i.GC_Interval,v=void 0===f?1e3:f,h=i.logInterval,b=void 0===h?5e3:h,p=i.logCompleted,y=void 0===p||p,d=i.onError,w=void 0===d?null:d,g=Object.keys(o),m=Object.values(o),I=g.length,k={}
|
|
42
|
+
;function x(e){var n=m[e]
|
|
43
|
+
;return"function"==typeof n&&(n=n(k)),n}
|
|
44
|
+
for(var D=[],E=[],G=0;G<I;G++)D[G]=-1,E[G]=[]
|
|
45
|
+
;E[0]=x(0);var O=0,T=0,_=!1,j=0;function C(e){
|
|
46
|
+
return n(this,void 0,void 0,(function(){var n
|
|
47
|
+
;return t(this,(function(t){switch(t.label){
|
|
48
|
+
case 0:
|
|
49
|
+
return console.error("error variant: ".concat(O,"\r\n").concat(JSON.stringify(k,null,2))),
|
|
50
|
+
console.error(e),
|
|
51
|
+
n=Date.now(),Date.now()-n>50&&j<5?(console.log("DEBUG ITERATION: "+j),
|
|
52
|
+
_=!0,[4,B()]):[3,2];case 1:t.sent(),j++,t.label=2
|
|
53
|
+
;case 2:throw w&&w({iteration:O,variant:k,error:e
|
|
54
|
+
}),e}}))}))}var P=Date.now(),S=P,A=O,N=T
|
|
55
|
+
;function B(){
|
|
56
|
+
return n(this,void 0,void 0,(function(){
|
|
57
|
+
var n,o,a,i;return t(this,(function(t){
|
|
58
|
+
switch(t.label){case 0:
|
|
59
|
+
t.trys.push([0,7,,9]),t.label=1;case 1:
|
|
60
|
+
return _||function(){for(var e=I-1;e>=0;e--){
|
|
61
|
+
var n=D[e]+1;if(n<E[e].length){
|
|
62
|
+
for(D[e]=n,k[g[e]]=E[e][n],e++;e<I;e++){var t=x(e)
|
|
63
|
+
;if(0===t.length)break;D[e]=0,E[e]=t,k[g[e]]=t[0]}
|
|
64
|
+
if(e>=I)return!0}}return!1
|
|
65
|
+
}()?(n=(b||v)&&Date.now(),b&&n-P>=b&&(console.log(O),P=n),
|
|
66
|
+
c&&O-A>=c||s&&T-N>=s||v&&n-S>=v?(A=O,
|
|
67
|
+
N=T,S=n,[4,r(1)]):[3,3]):[3,6];case 2:
|
|
68
|
+
return t.sent(),[3,1];case 3:
|
|
69
|
+
return"object"==typeof(o=e(k))&&o&&"function"==typeof o.then?[4,o]:[3,5]
|
|
70
|
+
;case 4:
|
|
71
|
+
return a=t.sent(),T+=i="number"==typeof a?a:1,O+=i,[3,1]
|
|
72
|
+
;case 5:return O+="number"==typeof o?o:1,[3,1]
|
|
73
|
+
;case 6:return[3,9];case 7:return[4,C(t.sent())]
|
|
74
|
+
;case 8:return t.sent(),[3,9];case 9:
|
|
75
|
+
return y&&console.log("variants: "+O),[4,r(1)]
|
|
76
|
+
;case 10:return t.sent(),[2,O]}}))}))}return B()}}
|
|
32
77
|
},Object.defineProperty(e,"__esModule",{value:!0})
|
|
33
78
|
}({});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/** Wait for garbage collection and return 0. It may be required for very long calculations. */
|
|
6
|
+
function garbageCollect(iterations) {
|
|
7
|
+
if (iterations == null || iterations <= 0) {
|
|
8
|
+
throw new Error(`Iterations = ${iterations}`);
|
|
9
|
+
}
|
|
10
|
+
iterations--;
|
|
11
|
+
// const time0 = Date.now()
|
|
12
|
+
const promise = new Promise(resolve => {
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
resolve(iterations);
|
|
15
|
+
}, 1);
|
|
16
|
+
});
|
|
17
|
+
return iterations <= 0
|
|
18
|
+
? promise
|
|
19
|
+
: promise.then(garbageCollect);
|
|
20
|
+
// : promise.then(o => {
|
|
21
|
+
// const gcTime = Date.now() - time0
|
|
22
|
+
// if (gcTime > 50) {
|
|
23
|
+
// console.log('GC time: ' + gcTime)
|
|
24
|
+
// o++
|
|
25
|
+
// }
|
|
26
|
+
// return garbageCollect(o)
|
|
27
|
+
// })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.garbageCollect = garbageCollect;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Wait for garbage collection and return 0. It may be required for very long calculations. */
|
|
2
|
+
function garbageCollect(iterations) {
|
|
3
|
+
if (iterations == null || iterations <= 0) {
|
|
4
|
+
throw new Error(`Iterations = ${iterations}`);
|
|
5
|
+
}
|
|
6
|
+
iterations--;
|
|
7
|
+
// const time0 = Date.now()
|
|
8
|
+
const promise = new Promise(resolve => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
resolve(iterations);
|
|
11
|
+
}, 1);
|
|
12
|
+
});
|
|
13
|
+
return iterations <= 0
|
|
14
|
+
? promise
|
|
15
|
+
: promise.then(garbageCollect);
|
|
16
|
+
// : promise.then(o => {
|
|
17
|
+
// const gcTime = Date.now() - time0
|
|
18
|
+
// if (gcTime > 50) {
|
|
19
|
+
// console.log('GC time: ' + gcTime)
|
|
20
|
+
// o++
|
|
21
|
+
// }
|
|
22
|
+
// return garbageCollect(o)
|
|
23
|
+
// })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { garbageCollect };
|
package/dist/lib/index.cjs
CHANGED
package/dist/lib/index.mjs
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var garbageCollect_garbageCollect = require('../garbage-collect/garbageCollect.cjs');
|
|
7
|
+
|
|
5
8
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
6
9
|
function createTestVariants(test) {
|
|
7
10
|
return function testVariantsArgs(args) {
|
|
8
|
-
return function testVariantsCall({
|
|
11
|
+
return function testVariantsCall({ GC_Iterations = 1000000, GC_IterationsAsync = 10000, GC_Interval = 1000, logInterval = 5000, logCompleted = true, onError: onErrorCallback = null, } = {}) {
|
|
9
12
|
const argsKeys = Object.keys(args);
|
|
10
13
|
const argsValues = Object.values(args);
|
|
11
14
|
const argsLength = argsKeys.length;
|
|
@@ -47,21 +50,32 @@ function createTestVariants(test) {
|
|
|
47
50
|
return false;
|
|
48
51
|
}
|
|
49
52
|
let iterations = 0;
|
|
53
|
+
let iterationsAsync = 0;
|
|
50
54
|
let debug = false;
|
|
51
55
|
let debugIteration = 0;
|
|
52
|
-
function onError(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
function onError(error) {
|
|
57
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
console.error(`error variant: ${iterations}\r\n${JSON.stringify(variantArgs, null, 2)}`);
|
|
59
|
+
console.error(error);
|
|
60
|
+
// rerun failed variant 5 times for debug
|
|
61
|
+
const time0 = Date.now();
|
|
62
|
+
// eslint-disable-next-line no-debugger
|
|
63
|
+
debugger;
|
|
64
|
+
if (Date.now() - time0 > 50 && debugIteration < 5) {
|
|
65
|
+
console.log('DEBUG ITERATION: ' + debugIteration);
|
|
66
|
+
debug = true;
|
|
67
|
+
yield next();
|
|
68
|
+
debugIteration++;
|
|
69
|
+
}
|
|
70
|
+
if (onErrorCallback) {
|
|
71
|
+
onErrorCallback({
|
|
72
|
+
iteration: iterations,
|
|
73
|
+
variant: variantArgs,
|
|
74
|
+
error,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
});
|
|
65
79
|
}
|
|
66
80
|
function onCompleted() {
|
|
67
81
|
if (logCompleted) {
|
|
@@ -69,45 +83,50 @@ function createTestVariants(test) {
|
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
let prevLogTime = Date.now();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.log(iterations);
|
|
78
|
-
prevLogTime = now;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
iterations += typeof value === 'number' ? value : 1;
|
|
82
|
-
const syncCallStartTime = pauseInterval && now;
|
|
83
|
-
while (debug || nextVariant()) {
|
|
86
|
+
let prevGC_Time = prevLogTime;
|
|
87
|
+
let prevGC_Iterations = iterations;
|
|
88
|
+
let prevGC_IterationsAsync = iterationsAsync;
|
|
89
|
+
function next() {
|
|
90
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
84
91
|
try {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
&&
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
while (debug || nextVariant()) {
|
|
93
|
+
const now = (logInterval || GC_Interval) && Date.now();
|
|
94
|
+
if (logInterval && now - prevLogTime >= logInterval) {
|
|
95
|
+
// the log is required to prevent the karma browserNoActivityTimeout
|
|
96
|
+
console.log(iterations);
|
|
97
|
+
prevLogTime = now;
|
|
98
|
+
}
|
|
99
|
+
if (GC_Iterations && iterations - prevGC_Iterations >= GC_Iterations
|
|
100
|
+
|| GC_IterationsAsync && iterationsAsync - prevGC_IterationsAsync >= GC_IterationsAsync
|
|
101
|
+
|| GC_Interval && now - prevGC_Time >= GC_Interval) {
|
|
102
|
+
prevGC_Iterations = iterations;
|
|
103
|
+
prevGC_IterationsAsync = iterationsAsync;
|
|
104
|
+
prevGC_Time = now;
|
|
105
|
+
yield garbageCollect_garbageCollect.garbageCollect(1);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const promiseOrIterations = test(variantArgs);
|
|
109
|
+
if (typeof promiseOrIterations === 'object'
|
|
110
|
+
&& promiseOrIterations
|
|
111
|
+
&& typeof promiseOrIterations.then === 'function') {
|
|
112
|
+
const value = yield promiseOrIterations;
|
|
113
|
+
const newIterations = typeof value === 'number' ? value : 1;
|
|
114
|
+
iterationsAsync += newIterations;
|
|
115
|
+
iterations += newIterations;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
iterations += typeof promiseOrIterations === 'number' ? promiseOrIterations : 1;
|
|
100
119
|
}
|
|
101
|
-
iterations += typeof promiseOrIterations === 'number' ? promiseOrIterations : 1;
|
|
102
120
|
}
|
|
103
121
|
catch (err) {
|
|
104
|
-
onError(err);
|
|
122
|
+
yield onError(err);
|
|
105
123
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
onCompleted();
|
|
125
|
+
yield garbageCollect_garbageCollect.garbageCollect(1);
|
|
126
|
+
return iterations;
|
|
127
|
+
});
|
|
109
128
|
}
|
|
110
|
-
return next(
|
|
129
|
+
return next();
|
|
111
130
|
};
|
|
112
131
|
};
|
|
113
132
|
}
|
|
@@ -2,18 +2,26 @@ declare type VariantsArgs<TArgs> = {
|
|
|
2
2
|
[key in keyof TArgs]: TArgs[key][] | ((args: TArgs) => TArgs[key][]);
|
|
3
3
|
};
|
|
4
4
|
declare type PromiseOrValue<T> = Promise<T> | T;
|
|
5
|
-
declare type TestVariantsCall = (callParams?: TestVariantsCallParams) => PromiseOrValue<number>;
|
|
5
|
+
declare type TestVariantsCall<TArgs> = (callParams?: TestVariantsCallParams<TArgs>) => PromiseOrValue<number>;
|
|
6
6
|
declare type TestVariantsSetArgs<TArgs> = <TAdditionalArgs>(args: VariantsArgs<{
|
|
7
7
|
[key in (keyof TAdditionalArgs | keyof TArgs)]: key extends keyof TArgs ? TArgs[key] : key extends keyof TAdditionalArgs ? TAdditionalArgs[key] : never;
|
|
8
|
-
}>) => TestVariantsCall
|
|
9
|
-
export declare type TestVariantsCallParams = {
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
}>) => TestVariantsCall<TArgs>;
|
|
9
|
+
export declare type TestVariantsCallParams<TArgs> = {
|
|
10
|
+
/** Wait for garbage collection after iterations */
|
|
11
|
+
GC_Iterations?: number;
|
|
12
|
+
/** Same as GC_Iterations but only for async test variants, required for 10000 and more of Promise rejections */
|
|
13
|
+
GC_IterationsAsync?: number;
|
|
14
|
+
/** Wait for garbage collection after time interval, required to prevent the karma browserDisconnectTimeout */
|
|
15
|
+
GC_Interval?: number;
|
|
13
16
|
/** console log current iterations, required to prevent the karma browserNoActivityTimeout */
|
|
14
17
|
logInterval?: number;
|
|
15
18
|
/** console log iterations on test completed */
|
|
16
19
|
logCompleted?: boolean;
|
|
20
|
+
onError?: (event: {
|
|
21
|
+
iteration: number;
|
|
22
|
+
variant: TArgs;
|
|
23
|
+
error: any;
|
|
24
|
+
}) => void;
|
|
17
25
|
};
|
|
18
26
|
export declare function createTestVariants<TArgs extends object>(test: (args: TArgs) => Promise<number | void> | number | void): TestVariantsSetArgs<TArgs>;
|
|
19
27
|
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { garbageCollect } from '../garbage-collect/garbageCollect.mjs';
|
|
3
|
+
|
|
1
4
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
2
5
|
function createTestVariants(test) {
|
|
3
6
|
return function testVariantsArgs(args) {
|
|
4
|
-
return function testVariantsCall({
|
|
7
|
+
return function testVariantsCall({ GC_Iterations = 1000000, GC_IterationsAsync = 10000, GC_Interval = 1000, logInterval = 5000, logCompleted = true, onError: onErrorCallback = null, } = {}) {
|
|
5
8
|
const argsKeys = Object.keys(args);
|
|
6
9
|
const argsValues = Object.values(args);
|
|
7
10
|
const argsLength = argsKeys.length;
|
|
@@ -43,21 +46,32 @@ function createTestVariants(test) {
|
|
|
43
46
|
return false;
|
|
44
47
|
}
|
|
45
48
|
let iterations = 0;
|
|
49
|
+
let iterationsAsync = 0;
|
|
46
50
|
let debug = false;
|
|
47
51
|
let debugIteration = 0;
|
|
48
|
-
function onError(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
function onError(error) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
console.error(`error variant: ${iterations}\r\n${JSON.stringify(variantArgs, null, 2)}`);
|
|
55
|
+
console.error(error);
|
|
56
|
+
// rerun failed variant 5 times for debug
|
|
57
|
+
const time0 = Date.now();
|
|
58
|
+
// eslint-disable-next-line no-debugger
|
|
59
|
+
debugger;
|
|
60
|
+
if (Date.now() - time0 > 50 && debugIteration < 5) {
|
|
61
|
+
console.log('DEBUG ITERATION: ' + debugIteration);
|
|
62
|
+
debug = true;
|
|
63
|
+
yield next();
|
|
64
|
+
debugIteration++;
|
|
65
|
+
}
|
|
66
|
+
if (onErrorCallback) {
|
|
67
|
+
onErrorCallback({
|
|
68
|
+
iteration: iterations,
|
|
69
|
+
variant: variantArgs,
|
|
70
|
+
error,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
throw error;
|
|
74
|
+
});
|
|
61
75
|
}
|
|
62
76
|
function onCompleted() {
|
|
63
77
|
if (logCompleted) {
|
|
@@ -65,45 +79,50 @@ function createTestVariants(test) {
|
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
let prevLogTime = Date.now();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.log(iterations);
|
|
74
|
-
prevLogTime = now;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
iterations += typeof value === 'number' ? value : 1;
|
|
78
|
-
const syncCallStartTime = pauseInterval && now;
|
|
79
|
-
while (debug || nextVariant()) {
|
|
82
|
+
let prevGC_Time = prevLogTime;
|
|
83
|
+
let prevGC_Iterations = iterations;
|
|
84
|
+
let prevGC_IterationsAsync = iterationsAsync;
|
|
85
|
+
function next() {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
87
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
&&
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
while (debug || nextVariant()) {
|
|
89
|
+
const now = (logInterval || GC_Interval) && Date.now();
|
|
90
|
+
if (logInterval && now - prevLogTime >= logInterval) {
|
|
91
|
+
// the log is required to prevent the karma browserNoActivityTimeout
|
|
92
|
+
console.log(iterations);
|
|
93
|
+
prevLogTime = now;
|
|
94
|
+
}
|
|
95
|
+
if (GC_Iterations && iterations - prevGC_Iterations >= GC_Iterations
|
|
96
|
+
|| GC_IterationsAsync && iterationsAsync - prevGC_IterationsAsync >= GC_IterationsAsync
|
|
97
|
+
|| GC_Interval && now - prevGC_Time >= GC_Interval) {
|
|
98
|
+
prevGC_Iterations = iterations;
|
|
99
|
+
prevGC_IterationsAsync = iterationsAsync;
|
|
100
|
+
prevGC_Time = now;
|
|
101
|
+
yield garbageCollect(1);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const promiseOrIterations = test(variantArgs);
|
|
105
|
+
if (typeof promiseOrIterations === 'object'
|
|
106
|
+
&& promiseOrIterations
|
|
107
|
+
&& typeof promiseOrIterations.then === 'function') {
|
|
108
|
+
const value = yield promiseOrIterations;
|
|
109
|
+
const newIterations = typeof value === 'number' ? value : 1;
|
|
110
|
+
iterationsAsync += newIterations;
|
|
111
|
+
iterations += newIterations;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
iterations += typeof promiseOrIterations === 'number' ? promiseOrIterations : 1;
|
|
96
115
|
}
|
|
97
|
-
iterations += typeof promiseOrIterations === 'number' ? promiseOrIterations : 1;
|
|
98
116
|
}
|
|
99
117
|
catch (err) {
|
|
100
|
-
onError(err);
|
|
118
|
+
yield onError(err);
|
|
101
119
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
onCompleted();
|
|
121
|
+
yield garbageCollect(1);
|
|
122
|
+
return iterations;
|
|
123
|
+
});
|
|
105
124
|
}
|
|
106
|
-
return next(
|
|
125
|
+
return next();
|
|
107
126
|
};
|
|
108
127
|
};
|
|
109
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemist/test-variants",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@babel/runtime-corejs3": "7.18.3",
|
|
42
42
|
"@flemist/copy-glob-flat": "0.0.5",
|
|
43
43
|
"@flemist/karma-custom-launcher": "0.0.0",
|
|
44
|
-
"@flemist/test-utils": "0.0.
|
|
44
|
+
"@flemist/test-utils": "0.0.7",
|
|
45
45
|
"@rollup/plugin-alias": "3.1.9",
|
|
46
46
|
"@rollup/plugin-babel": "5.3.1",
|
|
47
47
|
"@rollup/plugin-commonjs": "=21.1.0",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"@types/fs-extra": "9.0.13",
|
|
56
56
|
"@types/mocha": "9.1.1",
|
|
57
57
|
"@types/node": "18.0.0",
|
|
58
|
-
"
|
|
58
|
+
"@zerollup/ts-transform-paths": "1.7.18",
|
|
59
|
+
"cpy-cli": "=3.1.1",
|
|
59
60
|
"eslint": "8.18.0",
|
|
60
61
|
"eslint-config-pro": "3.0.14",
|
|
61
62
|
"fs-extra": "10.1.0",
|
|
@@ -90,8 +91,7 @@
|
|
|
90
91
|
"lint:fix": "eslint --fix ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
91
92
|
"lint:wizard": "eslint-nibble --cache --multi ./**/*.{js,cjs,mjs,ts,tsx}",
|
|
92
93
|
"build:js": "rimraf dist/lib && cpy \"**/assets/**\" \"../dist/lib/\" --parents --cwd=src && rollup -c",
|
|
93
|
-
"build
|
|
94
|
-
"build": "rimraf dist && pnpm run build:js && pnpm run build:types",
|
|
94
|
+
"build": "rimraf dist && pnpm run build:js",
|
|
95
95
|
"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/\"",
|
|
96
96
|
"coverage:check": "pnpm run coverage:merge && nyc check-coverage --report-dir tmp/coverage/all/lcov --lines 50 --functions 50 --branches 50 --statements 50",
|
|
97
97
|
"test:mocha": "mocha ./src/**/*.test.*",
|