|
27 | 27 |
|
28 | 28 | import { assert, expect } from "chai"; |
29 | 29 | import { createHash } from "crypto"; |
30 | | -import { existsSync } from "fs"; |
31 | | -import { readdir, readFile, stat, unlink, writeFile } from "fs/promises"; |
| 30 | +import { readFile, stat, unlink, writeFile } from "fs/promises"; |
32 | 31 | import * as os from 'os'; |
33 | 32 | import path from "path/posix"; |
34 | 33 | import { env } from "process"; |
@@ -525,72 +524,40 @@ async function assureDebugLevelLoggingIsEnabled() { |
525 | 524 | export function printRascalOutputOnFailure(channel: 'Language Parametric Rascal' | 'Rascal MPL') { |
526 | 525 |
|
527 | 526 | const ZOOM_OUT_FACTOR = 5; |
528 | | - const N_LOG_LINES = 250; |
529 | | - // We guess some locations where the logs can be, since we cannot easily retrieve those from VS Code. |
530 | | - const TEST_STORAGE_DIRS = [ |
531 | | - path.join(path.resolve(), "uitests"), // typical CI path |
532 | | - path.join(os.tmpdir(), "vscode-uitests") // typical local path |
533 | | - ]; |
534 | | - |
535 | 527 | afterEach("print output in case of failure", async function () { |
536 | 528 | if (!this.currentTest || this.currentTest.state !== "failed") { return; } |
537 | | - |
538 | | - console.log('**********************************************'); |
539 | | - console.log(`***** ${channel} output for the failed tests: `); |
540 | | - |
541 | | - let foundLogs = false; |
542 | | - for (const vsCodeDir of TEST_STORAGE_DIRS) { |
543 | | - try { |
544 | | - const logDir = path.join(vsCodeDir, "settings", "logs"); |
545 | | - if (existsSync(logDir)) { |
546 | | - for (const entry of await readdir(logDir, {recursive: true})) { |
547 | | - if (entry.includes("usethesource.rascalmpl") && entry.includes(channel)) { |
548 | | - console.log(`***** ${entry}`); |
549 | | - const contents = await readFile(path.join(logDir, entry), {encoding: "utf-8"}); |
550 | | - console.log(contents.split('\n').splice(-N_LOG_LINES).join('\n')); |
551 | | - foundLogs = true; |
552 | | - } |
553 | | - } |
554 | | - } |
555 | | - } catch (e) { |
556 | | - console.log(`Error capturing logs in ${vsCodeDir}: `, e); |
| 529 | + const bbp = new BottomBarPanel(); |
| 530 | + try { |
| 531 | + for (let z = 0; z < ZOOM_OUT_FACTOR; z++) { |
| 532 | + await new Workbench().executeCommand('workbench.action.zoomOut'); |
| 533 | + } |
| 534 | + await bbp.maximize(); |
| 535 | + console.log('**********************************************'); |
| 536 | + console.log('***** Rascal MPL output for the failed tests: '); |
| 537 | + let textLines: WebElement[] = []; |
| 538 | + let tries = 0; |
| 539 | + while (textLines.length === 0 && tries < 3) { |
| 540 | + await showRascalOutput(bbp, channel); |
| 541 | + textLines = await ignoreFails(bbp.findElements(By.className('view-line'))) ?? []; |
| 542 | + tries++; |
| 543 | + } |
| 544 | + if (textLines.length === 0) { |
| 545 | + console.log("We could not capture the output lines"); |
557 | 546 | } |
558 | | - } |
559 | | - |
560 | | - if (!foundLogs) { |
561 | | - // Fall back to legacy copy-from-VS Code approach if there were no log files. |
562 | | - const bbp = new BottomBarPanel(); |
563 | | - try { |
564 | | - for (let z = 0; z < ZOOM_OUT_FACTOR; z++) { |
565 | | - await new Workbench().executeCommand('workbench.action.zoomOut'); |
566 | | - } |
567 | | - await bbp.maximize(); |
568 | | - let textLines: WebElement[] = []; |
569 | | - let tries = 0; |
570 | | - while (textLines.length === 0 && tries < 3) { |
571 | | - await showRascalOutput(bbp, channel); |
572 | | - textLines = await ignoreFails(bbp.findElements(By.className('view-line'))) ?? []; |
573 | | - tries++; |
574 | | - } |
575 | | - if (textLines.length === 0) { |
576 | | - console.log("We could not capture the output lines"); |
577 | | - } |
578 | 547 |
|
579 | | - for (const l of textLines) { |
580 | | - console.log(await l.getText()); |
581 | | - } |
582 | | - } catch (e) { |
583 | | - console.log('Error capturing output: ', e); |
| 548 | + for (const l of textLines) { |
| 549 | + console.log(await l.getText()); |
584 | 550 | } |
585 | | - finally { |
586 | | - for (let z = 0; z < ZOOM_OUT_FACTOR; z++) { |
587 | | - await new Workbench().executeCommand('workbench.action.zoomIn'); |
588 | | - } |
589 | | - await bbp.closePanel(); |
| 551 | + } catch (e) { |
| 552 | + console.log('Error capturing output: ', e); |
| 553 | + } |
| 554 | + finally { |
| 555 | + console.log('*******End output*****************************'); |
| 556 | + for (let z = 0; z < ZOOM_OUT_FACTOR; z++) { |
| 557 | + await new Workbench().executeCommand('workbench.action.zoomIn'); |
590 | 558 | } |
| 559 | + await bbp.closePanel(); |
591 | 560 | } |
592 | | - |
593 | | - console.log('*******End output*****************************'); |
594 | 561 | }); |
595 | 562 | } |
596 | 563 |
|
|
0 commit comments