datagrok-tools 4.13.76 → 4.13.78
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 +4 -2
- package/bin/utils/test-utils.js +142 -24
- package/package.json +2 -2
package/bin/commands/test.js
CHANGED
|
@@ -74,6 +74,7 @@ async function runTesting(args) {
|
|
|
74
74
|
const parsed = (0, _orderFunctions.setAlphabeticalOrder)(testsObj, 1, 1);
|
|
75
75
|
if (parsed.length == 0) return {
|
|
76
76
|
failed: true,
|
|
77
|
+
error: '',
|
|
77
78
|
verbosePassed: 'Package not found',
|
|
78
79
|
verboseSkipped: 'Package not found',
|
|
79
80
|
verboseFailed: 'Package not found',
|
|
@@ -145,8 +146,9 @@ async function runTesting(args) {
|
|
|
145
146
|
testsResults.push(r);
|
|
146
147
|
organized = testsLeft;
|
|
147
148
|
browserId++;
|
|
148
|
-
if (r.
|
|
149
|
-
|
|
149
|
+
if (r.error) {
|
|
150
|
+
console.log(`\nexecution error:`);
|
|
151
|
+
console.log(r.error);
|
|
150
152
|
break;
|
|
151
153
|
}
|
|
152
154
|
} while (r.failed);
|
package/bin/utils/test-utils.js
CHANGED
|
@@ -320,7 +320,104 @@ function saveCsvResults(stringToSave, csvReportDir) {
|
|
|
320
320
|
_fs.default.writeFileSync(csvReportDir, modifiedStrings.join('\n'), 'utf8');
|
|
321
321
|
color.info('Saved `test-report.csv`\n');
|
|
322
322
|
}
|
|
323
|
+
async function runTests(testsParams, stopOnFail) {
|
|
324
|
+
let failed = false;
|
|
325
|
+
let verbosePassed = "";
|
|
326
|
+
let verboseSkipped = "";
|
|
327
|
+
let verboseFailed = "";
|
|
328
|
+
let error = "";
|
|
329
|
+
let countPassed = 0;
|
|
330
|
+
let countSkipped = 0;
|
|
331
|
+
let countFailed = 0;
|
|
332
|
+
let resultDF = undefined;
|
|
333
|
+
let lastTest = null;
|
|
334
|
+
let res = '';
|
|
335
|
+
try {
|
|
336
|
+
for (let testParam of testsParams) {
|
|
337
|
+
lastTest = testParam;
|
|
338
|
+
let df = await window.grok.functions.call(testParam.package + ':test', testParam.params);
|
|
339
|
+
let flakingCol = window.DG.Column.fromType(window.DG.COLUMN_TYPE.BOOL, 'flaking', df.rowCount);
|
|
340
|
+
df.columns.add(flakingCol);
|
|
341
|
+
let packageNameCol = window.DG.Column.fromList(window.DG.COLUMN_TYPE.STRING, 'package', Array(df.rowCount).fill(testParam.package));
|
|
342
|
+
df.columns.add(packageNameCol);
|
|
343
|
+
if (df.rowCount === 0) {
|
|
344
|
+
verboseFailed += `Test result : Invocation Fail : ${testParam.params.category}: ${testParam.params.test}\n`;
|
|
345
|
+
countFailed += 1;
|
|
346
|
+
failed = true;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
let row = df.rows.get(0);
|
|
350
|
+
if (df.rowCount > 1) {
|
|
351
|
+
let unhandledErrorRow = df.rows.get(1);
|
|
352
|
+
if (!unhandledErrorRow.get("success")) {
|
|
353
|
+
unhandledErrorRow["category"] = row.get("category");
|
|
354
|
+
unhandledErrorRow["name"] = row.get("name");
|
|
355
|
+
row = unhandledErrorRow;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const category = row.get("category");
|
|
359
|
+
const testName = row.get("name");
|
|
360
|
+
const time = row.get("ms");
|
|
361
|
+
const result = row.get("result");
|
|
362
|
+
const success = row.get("success");
|
|
363
|
+
const skipped = row.get("skipped");
|
|
364
|
+
row["flaking"] = success && window.DG.Test.isReproducing;
|
|
365
|
+
df.changeColumnType('result', window.DG.COLUMN_TYPE.STRING);
|
|
366
|
+
df.changeColumnType('logs', window.DG.COLUMN_TYPE.STRING);
|
|
367
|
+
// df.changeColumnType('memoryDelta', (<any>window).DG.COLUMN_TYPE.BIG_INT);
|
|
368
|
+
|
|
369
|
+
if (resultDF === undefined) resultDF = df;else resultDF = resultDF.append(df);
|
|
370
|
+
if (row["skipped"]) {
|
|
371
|
+
verboseSkipped += `Test result : Skipped : ${time} : ${category}: ${testName} : ${result}\n`;
|
|
372
|
+
countSkipped += 1;
|
|
373
|
+
} else if (row["success"]) {
|
|
374
|
+
verbosePassed += `Test result : Success : ${time} : ${category}: ${testName} : ${result}\n`;
|
|
375
|
+
countPassed += 1;
|
|
376
|
+
} else {
|
|
377
|
+
verboseFailed += `Test result : Failed : ${time} : ${category}: ${testName} : ${result}\n`;
|
|
378
|
+
countFailed += 1;
|
|
379
|
+
failed = true;
|
|
380
|
+
}
|
|
381
|
+
if (success !== true && skipped !== true && stopOnFail) break;
|
|
382
|
+
}
|
|
383
|
+
if (window.DG.Test.isInDebug) {
|
|
384
|
+
console.log('on browser closing debug point');
|
|
385
|
+
debugger;
|
|
386
|
+
}
|
|
387
|
+
res = '';
|
|
388
|
+
if (resultDF) {
|
|
389
|
+
const bs = window.DG.BitSet.create(resultDF.rowCount);
|
|
390
|
+
bs.setAll(true);
|
|
391
|
+
for (let i = 0; i < resultDF.rowCount; i++) {
|
|
392
|
+
if (resultDF.rows.get(i).get('category') === 'Unhandled exceptions') {
|
|
393
|
+
bs.set(i, false);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
resultDF = resultDF.clone(bs);
|
|
397
|
+
res = resultDF.toCsv();
|
|
398
|
+
}
|
|
399
|
+
} catch (e) {
|
|
400
|
+
failed = true;
|
|
401
|
+
error = lastTest ? `category: ${lastTest.params.category}, name: ${lastTest.params.test}, error: ${e}, ${await window.DG.Logger.translateStackTrace(e.stack)}` : `test: null, error: ${e}, ${await window.DG.Logger.translateStackTrace(e.stack)}`;
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
failed: failed,
|
|
405
|
+
verbosePassed: verbosePassed,
|
|
406
|
+
verboseSkipped: verboseSkipped,
|
|
407
|
+
verboseFailed: verboseFailed,
|
|
408
|
+
passedAmount: countPassed,
|
|
409
|
+
skippedAmount: countSkipped,
|
|
410
|
+
failedAmount: countFailed,
|
|
411
|
+
error: error,
|
|
412
|
+
csv: res
|
|
413
|
+
// df: resultDF?.toJson()
|
|
414
|
+
};
|
|
415
|
+
}
|
|
323
416
|
async function runBrowser(testExecutionData, browserOptions, browsersId, testInvocationTimeout = 3600000) {
|
|
417
|
+
let testsToRun = {
|
|
418
|
+
func: runTests.toString(),
|
|
419
|
+
tests: testExecutionData
|
|
420
|
+
};
|
|
324
421
|
return await timeout(async () => {
|
|
325
422
|
const params = Object.assign({
|
|
326
423
|
devtools: browserOptions.debug
|
|
@@ -347,29 +444,49 @@ async function runBrowser(testExecutionData, browserOptions, browsersId, testInv
|
|
|
347
444
|
addLogsToFile(logsDir, `CONSOLE LOG REQUEST: ${response.status()}, ${response.url()}\n`);
|
|
348
445
|
});
|
|
349
446
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
447
|
+
let testingResults = await page.evaluate((testData, options) => {
|
|
448
|
+
if (options.benchmark) window.DG.Test.isInBenchmark = true;
|
|
449
|
+
if (options.reproduce) window.DG.Test.isReproducing = true;
|
|
450
|
+
if (options.ciCd) window.DG.Test.isCiCd = true;
|
|
451
|
+
if (options.debug) window.DG.Test.isInDebug = true;
|
|
452
|
+
return new Promise((resolve, reject) => {
|
|
453
|
+
window.runTests = eval('(' + testData.func + ')');
|
|
454
|
+
window.runTests(testData.tests, options.stopOnTimeout).then(results => {
|
|
455
|
+
resolve(results);
|
|
456
|
+
}).catch(e => {
|
|
457
|
+
resolve({
|
|
458
|
+
failed: true,
|
|
459
|
+
verbosePassed: "",
|
|
460
|
+
verboseSkipped: "",
|
|
461
|
+
verboseFailed: "",
|
|
462
|
+
error: JSON.stringify(e),
|
|
463
|
+
passedAmount: 0,
|
|
464
|
+
skippedAmount: 0,
|
|
465
|
+
failedAmount: 1,
|
|
466
|
+
csv: "",
|
|
467
|
+
df: undefined
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// (<any>window).DG.Utils.executeTests(testData.tests, options.stopOnTimeout)
|
|
472
|
+
// .then((results: any) => {
|
|
473
|
+
// resolve(results);
|
|
474
|
+
// })
|
|
475
|
+
// .catch((e: any) => {
|
|
476
|
+
// resolve({
|
|
477
|
+
// failed: true,
|
|
478
|
+
// verbosePassed: "",
|
|
479
|
+
// verboseSkipped: "",
|
|
480
|
+
// verboseFailed: "Tests execution failed",
|
|
481
|
+
// passedAmount: 0,
|
|
482
|
+
// skippedAmount: 0,
|
|
483
|
+
// failedAmount: 1,
|
|
484
|
+
// csv: "",
|
|
485
|
+
// df: undefined
|
|
486
|
+
// })
|
|
487
|
+
// });
|
|
488
|
+
});
|
|
489
|
+
}, testsToRun, browserOptions);
|
|
373
490
|
if (browserOptions.record) {
|
|
374
491
|
await recorder.stop();
|
|
375
492
|
}
|
|
@@ -388,7 +505,8 @@ async function mergeBrowsersResults(browsersResults) {
|
|
|
388
505
|
passedAmount: browsersResults[0].passedAmount,
|
|
389
506
|
skippedAmount: browsersResults[0].skippedAmount,
|
|
390
507
|
failedAmount: browsersResults[0].failedAmount,
|
|
391
|
-
csv: browsersResults[0].csv
|
|
508
|
+
csv: browsersResults[0].csv,
|
|
509
|
+
error: ''
|
|
392
510
|
};
|
|
393
511
|
for (let browsersResult of browsersResults) {
|
|
394
512
|
if (mergedResult.csv === browsersResult.csv) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datagrok-tools",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.78",
|
|
4
4
|
"description": "Utility to upload and publish packages to Datagrok",
|
|
5
5
|
"homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
|
|
6
6
|
"dependencies": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"os": "^0.1.2",
|
|
20
20
|
"papaparse": "^5.4.1",
|
|
21
21
|
"path": "^0.12.7",
|
|
22
|
-
"puppeteer": "
|
|
22
|
+
"puppeteer": "22.10.0",
|
|
23
23
|
"puppeteer-screen-recorder": "3.0.3"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|