datagrok-tools 4.14.36 → 4.14.37
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/bin/commands/test.js +36 -40
- package/bin/utils/test-utils.js +18 -6
- package/package.json +1 -1
- package/plugins/func-gen-plugin.js +2 -2
package/bin/commands/test.js
CHANGED
|
@@ -36,8 +36,8 @@ async function test(args) {
|
|
|
36
36
|
if (!args.package) packageJsonData = JSON.parse(_fs.default.readFileSync(_path.default.join(curDir, 'package.json'), {
|
|
37
37
|
encoding: 'utf-8'
|
|
38
38
|
}));
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const packageName = args.package ? utils.kebabToCamelCase(args.package) : utils.kebabToCamelCase(utils.removeScope(packageJsonData.name));
|
|
40
|
+
const packagesDir = _path.default.basename(curDir) === 'packages' ? curDir : _path.default.dirname(curDir);
|
|
41
41
|
console.log('Environment variable `TARGET_PACKAGE` is set to', packageName);
|
|
42
42
|
if (args.platform && packageName !== 'ApiTests') color.warn('--platform flag can only be used in the ApiTests package');
|
|
43
43
|
// if (args.core && packageName !== 'DevTools')
|
|
@@ -47,7 +47,7 @@ async function test(args) {
|
|
|
47
47
|
await testUtils.loadPackages(packagesDir, packageName, args.host, args['skip-publish'], args['skip-build'], args.link);
|
|
48
48
|
}
|
|
49
49
|
process.env.TARGET_PACKAGE = packageName;
|
|
50
|
-
|
|
50
|
+
const res = await runTesting(args);
|
|
51
51
|
if (args.csv) (0, _testUtils.saveCsvResults)([res.csv], csvReportDir);
|
|
52
52
|
(0, _testUtils.printBrowsersResult)(res, args.verbose);
|
|
53
53
|
if (res.failed) {
|
|
@@ -66,23 +66,25 @@ async function runTesting(args) {
|
|
|
66
66
|
const loadedTests = await (0, _testUtils.loadTestsList)([process.env.TARGET_PACKAGE ?? ''], args.core);
|
|
67
67
|
let testsObj = [];
|
|
68
68
|
if (args['stress-test'] || args.benchmark) {
|
|
69
|
-
for (
|
|
69
|
+
for (const element of loadedTests) {
|
|
70
70
|
if (args.benchmark && !element.options.benchmark || args['stress-test'] && !element.options.stressTest) continue;
|
|
71
71
|
testsObj.push(element);
|
|
72
72
|
}
|
|
73
73
|
} else testsObj = loadedTests;
|
|
74
74
|
const parsed = (0, _orderFunctions.setAlphabeticalOrder)(testsObj, 1, 1);
|
|
75
|
-
if (parsed.length == 0)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
if (parsed.length == 0) {
|
|
76
|
+
return {
|
|
77
|
+
failed: true,
|
|
78
|
+
error: '',
|
|
79
|
+
verbosePassed: 'Package not found',
|
|
80
|
+
verboseSkipped: 'Package not found',
|
|
81
|
+
verboseFailed: 'Package not found',
|
|
82
|
+
passedAmount: 0,
|
|
83
|
+
skippedAmount: 0,
|
|
84
|
+
failedAmount: 0,
|
|
85
|
+
csv: ''
|
|
86
|
+
};
|
|
87
|
+
}
|
|
86
88
|
let organized = parsed[0].map(testObj => ({
|
|
87
89
|
package: testObj.packageName,
|
|
88
90
|
params: {
|
|
@@ -94,10 +96,10 @@ async function runTesting(args) {
|
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
}));
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
const filtered = [];
|
|
100
|
+
const categoryRegex = new RegExp(`${args.category?.replaceAll(' ', '')}.*`);
|
|
99
101
|
if (args.category) {
|
|
100
|
-
for (
|
|
102
|
+
for (const element of organized) {
|
|
101
103
|
if (categoryRegex.test(element.params.category.replaceAll(' ', ''))) {
|
|
102
104
|
if (element.params.test === args.test || !args.test) filtered.push(element);
|
|
103
105
|
}
|
|
@@ -109,7 +111,7 @@ async function runTesting(args) {
|
|
|
109
111
|
console.log(`Tests total: ${organized.length}`);
|
|
110
112
|
}
|
|
111
113
|
color.info('Starting tests...');
|
|
112
|
-
|
|
114
|
+
const testsResults = [];
|
|
113
115
|
let r;
|
|
114
116
|
let browserId = 1;
|
|
115
117
|
await (0, _testUtils.timeout)(async () => {
|
|
@@ -126,23 +128,21 @@ async function runTesting(args) {
|
|
|
126
128
|
stopOnTimeout: true,
|
|
127
129
|
debug: args['debug'] ?? false
|
|
128
130
|
}, browserId, testInvocationTimeout);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (
|
|
131
|
+
const testsLeft = [];
|
|
132
|
+
const testsToReproduce = [];
|
|
133
|
+
for (const testData of organized) {
|
|
132
134
|
if (!r.verbosePassed.includes(`${testData.params.category}: ${testData.params.test}`) && !r.verboseSkipped.includes(`${testData.params.category}: ${testData.params.test}`) && !r.verboseFailed.includes(`${testData.params.category}: ${testData.params.test}`) && !new RegExp(`${testUtils.escapeRegex(testData.params.category.trim())}[^\n]*: *?(before|after)(\\(\\))?`).test(r.verboseFailed)) testsLeft.push(testData);
|
|
133
|
-
if (r.verboseFailed.includes(`${testData.params.category}: ${testData.params.test} : Error:`))
|
|
134
|
-
testsToReproduce.push(testData);
|
|
135
|
-
}
|
|
135
|
+
if (r.verboseFailed.includes(`${testData.params.category}: ${testData.params.test} : Error:`)) testsToReproduce.push(testData);
|
|
136
136
|
}
|
|
137
137
|
if (testsToReproduce.length > 0) {
|
|
138
|
-
|
|
139
|
-
for (
|
|
140
|
-
|
|
138
|
+
const reproduced = await reproducedTest(args, testsToReproduce);
|
|
139
|
+
for (const test of testsToReproduce) {
|
|
140
|
+
const reproducedTest = reproduced.get(test);
|
|
141
141
|
if (reproducedTest && !reproducedTest.failed) r = await updateResultsByReproduced(r, reproducedTest, test);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
r.csv = await (0, _testUtils.addColumnToCsv)(r.csv,
|
|
145
|
-
r.csv = await (0, _testUtils.addColumnToCsv)(r.csv,
|
|
144
|
+
r.csv = await (0, _testUtils.addColumnToCsv)(r.csv, 'stress_test', args['stress-test'] ?? false);
|
|
145
|
+
r.csv = await (0, _testUtils.addColumnToCsv)(r.csv, 'benchmark', args.benchmark ?? false);
|
|
146
146
|
testsResults.push(r);
|
|
147
147
|
organized = testsLeft;
|
|
148
148
|
browserId++;
|
|
@@ -157,8 +157,8 @@ async function runTesting(args) {
|
|
|
157
157
|
}
|
|
158
158
|
async function reproducedTest(args, testsToReproduce) {
|
|
159
159
|
const res = new Map();
|
|
160
|
-
for (
|
|
161
|
-
|
|
160
|
+
for (const test of testsToReproduce) {
|
|
161
|
+
const r = await (0, _testUtils.runBrowser)([test], {
|
|
162
162
|
benchmark: args.benchmark ?? false,
|
|
163
163
|
catchUnhandled: false,
|
|
164
164
|
gui: false,
|
|
@@ -175,8 +175,8 @@ async function reproducedTest(args, testsToReproduce) {
|
|
|
175
175
|
}
|
|
176
176
|
async function updateResultsByReproduced(curentResult, reproducedResult, testsParams) {
|
|
177
177
|
const table2Dict = {};
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
const table1 = readCSVResultData(curentResult.csv);
|
|
179
|
+
const table2 = readCSVResultData(reproducedResult.csv);
|
|
180
180
|
const flakingMap = {};
|
|
181
181
|
table2.rows.forEach(row => {
|
|
182
182
|
const key = `${row['category']},${row['name']}`;
|
|
@@ -184,9 +184,7 @@ async function updateResultsByReproduced(curentResult, reproducedResult, testsPa
|
|
|
184
184
|
});
|
|
185
185
|
table1.rows.forEach(row => {
|
|
186
186
|
const key = `${row['category']},${row['name']}`;
|
|
187
|
-
if (key in flakingMap)
|
|
188
|
-
row['flaking'] = flakingMap[key];
|
|
189
|
-
}
|
|
187
|
+
if (key in flakingMap) row['flaking'] = flakingMap[key];
|
|
190
188
|
});
|
|
191
189
|
curentResult.csv = Papa.unparse(table1.rows, {
|
|
192
190
|
columns: table1.headers
|
|
@@ -200,9 +198,7 @@ function readCSVResultData(data) {
|
|
|
200
198
|
header: true,
|
|
201
199
|
skipEmptyLines: true
|
|
202
200
|
});
|
|
203
|
-
if (parsed.errors.length > 0) {
|
|
204
|
-
throw new Error(`Error parsing CSV file: ${parsed.errors[0].message}`);
|
|
205
|
-
}
|
|
201
|
+
if (parsed.errors.length > 0) throw new Error(`Error parsing CSV file: ${parsed.errors[0].message}`);
|
|
206
202
|
return {
|
|
207
203
|
headers: parsed.meta.fields || [],
|
|
208
204
|
rows: parsed.data
|
package/bin/utils/test-utils.js
CHANGED
|
@@ -329,16 +329,28 @@ async function runTests(testsParams, stopOnFail) {
|
|
|
329
329
|
let resultDF = undefined;
|
|
330
330
|
let lastTest = null;
|
|
331
331
|
let res = '';
|
|
332
|
+
|
|
333
|
+
// function addColumn(columnName: string, column: any, df : any) {
|
|
334
|
+
// if (!df.getCol(columnName))
|
|
335
|
+
// df.columns.add(column);
|
|
336
|
+
// }
|
|
337
|
+
|
|
332
338
|
try {
|
|
333
339
|
for (const testParam of testsParams) {
|
|
334
340
|
lastTest = testParam;
|
|
335
341
|
const df = await window.grok.functions.call(testParam.package + ':test', testParam.params);
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
+
df.columns.setOrder(['date', 'category', 'name', 'success', 'result', 'ms', 'skipped', 'logs', 'owner', 'package', 'widgetsDifference', 'flaking']);
|
|
343
|
+
// addColumn('flaking', (<any>window).DG.Column.fromType((<any>window).DG.COLUMN_TYPE.BOOL, 'flaking', df.rowCount), df);
|
|
344
|
+
// addColumn('package', (<any>window).DG.Column.fromType((<any>window).DG.COLUMN_TYPE.BOOL, 'flaking', df.rowCount), df);
|
|
345
|
+
// if (!df.getCol('flaking')) {
|
|
346
|
+
// const flakingCol = (<any>window).DG.Column.fromType((<any>window).DG.COLUMN_TYPE.BOOL, 'flaking', df.rowCount);
|
|
347
|
+
// df.columns.add(flakingCol);
|
|
348
|
+
// }
|
|
349
|
+
// if (!df.getCol('package')) {
|
|
350
|
+
// const packageNameCol =
|
|
351
|
+
// (<any>window).DG.Column.fromList((<any>window).DG.COLUMN_TYPE.STRING, 'package', Array(df.rowCount).fill(testParam.package));
|
|
352
|
+
// df.columns.add(packageNameCol);
|
|
353
|
+
// }
|
|
342
354
|
if (df.rowCount === 0) {
|
|
343
355
|
verboseFailed += `Test result : Invocation Fail : ${testParam.params.category}: ${testParam.params.test}\n`;
|
|
344
356
|
countFailed += 1;
|
package/package.json
CHANGED
|
@@ -351,8 +351,8 @@ class FuncGeneratorPlugin {
|
|
|
351
351
|
let isArray = false;
|
|
352
352
|
if (nodeAnnotation?.type === 'TSUnionType' &&
|
|
353
353
|
nodeAnnotation?.types?.length === 2 &&
|
|
354
|
-
nodeAnnotation?.types?.some((e)=> e?.type === 'TSNullKeyword'))
|
|
355
|
-
nodeAnnotation = nodeAnnotation.types.filter((e)=> e.type !== 'TSNullKeyword')[0];
|
|
354
|
+
nodeAnnotation?.types?.some((e)=> e?.type === 'TSNullKeyword' || e?.type === 'TSVoidKeyword'))
|
|
355
|
+
nodeAnnotation = nodeAnnotation.types.filter((e)=> e.type !== 'TSNullKeyword' || e?.type === 'TSVoidKeyword')[0];
|
|
356
356
|
|
|
357
357
|
|
|
358
358
|
if (
|