Skip to content

Commit db4093e

Browse files
committed
Revert "Take failed test logs from file."
This reverts commit 49528ab.
1 parent 49528ab commit db4093e

1 file changed

Lines changed: 28 additions & 61 deletions

File tree

  • rascal-vscode-extension/src/test/vscode-suite

rascal-vscode-extension/src/test/vscode-suite/utils.ts

Lines changed: 28 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828
import { assert, expect } from "chai";
2929
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";
3231
import * as os from 'os';
3332
import path from "path/posix";
3433
import { env } from "process";
@@ -525,72 +524,40 @@ async function assureDebugLevelLoggingIsEnabled() {
525524
export function printRascalOutputOnFailure(channel: 'Language Parametric Rascal' | 'Rascal MPL') {
526525

527526
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-
535527
afterEach("print output in case of failure", async function () {
536528
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");
557546
}
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-
}
578547

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());
584550
}
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');
590558
}
559+
await bbp.closePanel();
591560
}
592-
593-
console.log('*******End output*****************************');
594561
});
595562
}
596563

0 commit comments

Comments
 (0)