datagrok-tools 4.13.76 → 4.13.77

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.
@@ -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.verboseFailed === 'Tests execution failed') {
149
- if (r.error) console.log(r.error);
149
+ if (r.error) {
150
+ console.log(`\nexecution error:`);
151
+ console.log(r.error);
150
152
  break;
151
153
  }
152
154
  } while (r.failed);
@@ -90,22 +90,6 @@ async function getBrowserPage(puppeteer, params = defaultLaunchParameters) {
90
90
  url = await getWebUrl(url, token);
91
91
  console.log(`Using web root: ${url}`);
92
92
  const browser = await puppeteer.launch(params);
93
- if (params.debug) {
94
- const targets = await browser.targets();
95
- const devtoolsTarget = targets.find(t => {
96
- return t.type() === 'other' && t.url().startsWith('devtools://');
97
- });
98
- if (devtoolsTarget) {
99
- const client = await devtoolsTarget.createCDPSession();
100
- await client.send('Runtime.enable');
101
- await client.send('Runtime.evaluate', {
102
- expression: `
103
- window.UI.viewManager.showView('network');
104
- window.UI.dockController.setDockSide('bottom')
105
- `
106
- });
107
- }
108
- }
109
93
  const page = await browser.newPage();
110
94
  await page.setViewport({
111
95
  width: 1920,
@@ -320,7 +304,103 @@ function saveCsvResults(stringToSave, csvReportDir) {
320
304
  _fs.default.writeFileSync(csvReportDir, modifiedStrings.join('\n'), 'utf8');
321
305
  color.info('Saved `test-report.csv`\n');
322
306
  }
307
+ async function helloTests(testsParams, stopOnFail) {
308
+ let failed = false;
309
+ let verbosePassed = "";
310
+ let verboseSkipped = "";
311
+ let verboseFailed = "";
312
+ let error = "";
313
+ let countPassed = 0;
314
+ let countSkipped = 0;
315
+ let countFailed = 0;
316
+ let resultDF = undefined;
317
+ let lastTest = null;
318
+ let res = '';
319
+ try {
320
+ for (let testParam of testsParams) {
321
+ lastTest = testParam;
322
+ let df = await window.grok.functions.call(testParam.package + ':test', testParam.params);
323
+ let flakingCol = window.DG.Column.fromType(window.DG.COLUMN_TYPE.BOOL, 'flaking', df.rowCount);
324
+ df.columns.add(flakingCol);
325
+ let packageNameCol = window.DG.Column.fromList(window.DG.COLUMN_TYPE.STRING, 'package', Array(df.rowCount).fill(testParam.package));
326
+ df.columns.add(packageNameCol);
327
+ if (df.rowCount === 0) {
328
+ verboseFailed += `Test result : Invocation Fail : ${testParam.params.category}: ${testParam.params.test}\n`;
329
+ countFailed += 1;
330
+ failed = true;
331
+ continue;
332
+ }
333
+ let row = df.rows.get(0);
334
+ if (df.rowCount > 1) {
335
+ let unhandledErrorRow = df.rows.get(1);
336
+ if (!unhandledErrorRow.get("success")) {
337
+ unhandledErrorRow["category"] = row.get("category");
338
+ unhandledErrorRow["name"] = row.get("name");
339
+ row = unhandledErrorRow;
340
+ }
341
+ }
342
+ const category = row.get("category");
343
+ const testName = row.get("name");
344
+ const time = row.get("ms");
345
+ const result = row.get("result");
346
+ const success = row.get("success");
347
+ const skipped = row.get("skipped");
348
+ row["flaking"] = success && window.DG.Test.isReproducing;
349
+ df.changeColumnType('result', window.DG.COLUMN_TYPE.STRING);
350
+ df.changeColumnType('logs', window.DG.COLUMN_TYPE.STRING);
351
+ df.changeColumnType('memoryDelta', window.DG.COLUMN_TYPE.BIG_INT);
352
+ if (resultDF === undefined) resultDF = df;else resultDF = resultDF.append(df);
353
+ if (row["skipped"]) {
354
+ verboseSkipped += `Test result : Skipped : ${time} : ${category}: ${testName} : ${result}\n`;
355
+ countSkipped += 1;
356
+ } else if (row["success"]) {
357
+ verbosePassed += `Test result : Success : ${time} : ${category}: ${testName} : ${result}\n`;
358
+ countPassed += 1;
359
+ } else {
360
+ verboseFailed += `Test result : Failed : ${time} : ${category}: ${testName} : ${result}\n`;
361
+ countFailed += 1;
362
+ failed = true;
363
+ }
364
+ if (success !== true && skipped !== true && stopOnFail) break;
365
+ }
366
+ if (window.DG.Test.isInDebug) {
367
+ console.log('on browser closing debug point');
368
+ debugger;
369
+ }
370
+ res = '';
371
+ if (resultDF) {
372
+ const bs = window.DG.BitSet.create(resultDF.rowCount);
373
+ bs.setAll(true);
374
+ for (let i = 0; i < resultDF.rowCount; i++) {
375
+ if (resultDF.rows.get(i).get('category') === 'Unhandled exceptions') {
376
+ bs.set(i, false);
377
+ }
378
+ }
379
+ resultDF = resultDF.clone(bs);
380
+ res = resultDF.toCsv();
381
+ }
382
+ } catch (e) {
383
+ failed = true;
384
+ 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)}`;
385
+ }
386
+ return {
387
+ failed: failed,
388
+ verbosePassed: verbosePassed,
389
+ verboseSkipped: verboseSkipped,
390
+ verboseFailed: verboseFailed,
391
+ passedAmount: countPassed,
392
+ skippedAmount: countSkipped,
393
+ failedAmount: countFailed,
394
+ error: error,
395
+ csv: res
396
+ // df: resultDF?.toJson()
397
+ };
398
+ }
323
399
  async function runBrowser(testExecutionData, browserOptions, browsersId, testInvocationTimeout = 3600000) {
400
+ let testsToRun = {
401
+ func: helloTests.toString(),
402
+ tests: testExecutionData
403
+ };
324
404
  return await timeout(async () => {
325
405
  const params = Object.assign({
326
406
  devtools: browserOptions.debug
@@ -347,29 +427,49 @@ async function runBrowser(testExecutionData, browserOptions, browsersId, testInv
347
427
  addLogsToFile(logsDir, `CONSOLE LOG REQUEST: ${response.status()}, ${response.url()}\n`);
348
428
  });
349
429
  }
350
- const testingResults = await page.evaluate(async (testData, options) => {
351
- try {
352
- if (options.benchmark) window.DG.Test.isInBenchmark = true;
353
- if (options.reproduce) window.DG.Test.isReproducing = true;
354
- if (options.ciCd) window.DG.Test.isCiCd = true;
355
- if (options.debug) window.DG.Test.isInDebug = true;
356
- const results = await window.DG.Utils.executeTests(testData, options.stopOnTimeout);
357
- return results;
358
- } catch (e) {
359
- return {
360
- failed: true,
361
- verbosePassed: "",
362
- verboseSkipped: "",
363
- verboseFailed: "Tests execution failed",
364
- error: JSON.stringify(e),
365
- passedAmount: 0,
366
- skippedAmount: 0,
367
- failedAmount: 1,
368
- csv: "",
369
- df: undefined
370
- };
371
- }
372
- }, testExecutionData, browserOptions);
430
+ let testingResults = await page.evaluate((testData, options) => {
431
+ if (options.benchmark) window.DG.Test.isInBenchmark = true;
432
+ if (options.reproduce) window.DG.Test.isReproducing = true;
433
+ if (options.ciCd) window.DG.Test.isCiCd = true;
434
+ if (options.debug) window.DG.Test.isInDebug = true;
435
+ return new Promise((resolve, reject) => {
436
+ window.helloTests = eval('(' + testData.func + ')');
437
+ window.helloTests(testData.tests, options.stopOnTimeout).then(results => {
438
+ resolve(results);
439
+ }).catch(e => {
440
+ resolve({
441
+ failed: true,
442
+ verbosePassed: "",
443
+ verboseSkipped: "",
444
+ verboseFailed: "",
445
+ error: JSON.stringify(e),
446
+ passedAmount: 0,
447
+ skippedAmount: 0,
448
+ failedAmount: 1,
449
+ csv: "",
450
+ df: undefined
451
+ });
452
+ });
453
+
454
+ // (<any>window).DG.Utils.executeTests(testData.tests, options.stopOnTimeout)
455
+ // .then((results: any) => {
456
+ // resolve(results);
457
+ // })
458
+ // .catch((e: any) => {
459
+ // resolve({
460
+ // failed: true,
461
+ // verbosePassed: "",
462
+ // verboseSkipped: "",
463
+ // verboseFailed: "Tests execution failed",
464
+ // passedAmount: 0,
465
+ // skippedAmount: 0,
466
+ // failedAmount: 1,
467
+ // csv: "",
468
+ // df: undefined
469
+ // })
470
+ // });
471
+ });
472
+ }, testsToRun, browserOptions);
373
473
  if (browserOptions.record) {
374
474
  await recorder.stop();
375
475
  }
@@ -388,7 +488,8 @@ async function mergeBrowsersResults(browsersResults) {
388
488
  passedAmount: browsersResults[0].passedAmount,
389
489
  skippedAmount: browsersResults[0].skippedAmount,
390
490
  failedAmount: browsersResults[0].failedAmount,
391
- csv: browsersResults[0].csv
491
+ csv: browsersResults[0].csv,
492
+ error: ''
392
493
  };
393
494
  for (let browsersResult of browsersResults) {
394
495
  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.76",
3
+ "version": "4.13.77",
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": {