Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f11215a
Abort type-check when dependencies have parse errors.
toinehartman Oct 20, 2025
c0f5351
Take screenshot before IDE tests as well.
toinehartman Oct 28, 2025
1e24b8c
Wait longer for type-checks in UI tests.
toinehartman Oct 28, 2025
d4e18ae
Make screenshot on failure.
toinehartman Oct 29, 2025
a3c0e72
Fix test title.
toinehartman Oct 29, 2025
0e59912
Fix failure handler (again).
toinehartman Oct 29, 2025
d1a8234
Take some extra screenshots around type-checks.
toinehartman Oct 29, 2025
cdffe7d
Check modification.
toinehartman Oct 30, 2025
3b2ec68
Increase the chance of hitting a failing test.
toinehartman Oct 30, 2025
61c46d0
Revert "Increase the chance of hitting a failing test."
toinehartman Oct 30, 2025
99d98bf
More screenshots to track editor state.
toinehartman Oct 31, 2025
988164e
Shoot more screens.
toinehartman Oct 31, 2025
80916ef
Fix log messages.
toinehartman Nov 3, 2025
5ad8918
Merge remote-tracking branch 'origin/main' into fix/flaky-ui-test
toinehartman Nov 3, 2025
c544a28
Always upload screenshots.
toinehartman Nov 3, 2025
f281d74
Improve exception handling.
toinehartman Oct 20, 2025
90065d4
Improve error messages in case of parse errors.
toinehartman Oct 23, 2025
e5e3054
Fail when Lib.tpl is missing.
toinehartman Nov 3, 2025
3bf9ca5
Screenshot after goto-def.
toinehartman Nov 3, 2025
b5f6ff0
Work around getNumberOfLines bug.
toinehartman Nov 4, 2025
a958de7
Remove workaround for cross-project imports.
toinehartman Nov 4, 2025
ff887cf
Revert "Wait longer for type-checks in UI tests."
toinehartman Nov 4, 2025
f6b4c2f
Clean up screenshots.
toinehartman Nov 4, 2025
745a90f
Revert "Always upload screenshots."
toinehartman Nov 4, 2025
0ed2e4b
Clean up more unnecessary changes.
toinehartman Nov 4, 2025
971a621
Revert "Fix failure handler (again)."
toinehartman Nov 4, 2025
c63235b
Revert "Fix test title."
toinehartman Nov 4, 2025
c4638d0
Revert "Make screenshot on failure."
toinehartman Nov 4, 2025
9c89b3d
Guard against failure.
toinehartman Nov 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.function.Function;
Expand Down Expand Up @@ -166,12 +167,15 @@ IFunction makeParseTreeGetter(Evaluator e) {
return e.getFunctionValueFactory().function(getParseTreeType, (t, u) -> {
ISourceLocation resolvedLocation = Locations.toClientLocation((ISourceLocation) t[0]);
try {
var tree = rascalTextDocumentService.getFile(resolvedLocation).getLastTreeWithoutErrors();
var tree = rascalTextDocumentService.getFile(resolvedLocation).getCurrentTreeAsync(false).get();
if (tree != null) {
return tree.get();
}
} catch (ResponseErrorException e1) {
// File is not open in the IDE
} catch (ResponseErrorException | ExecutionException e1) {
// File is not open in the IDE | Parse threw an exception
// In either case, fall through and try a direct parse
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
// Parse the source file
try (var reader = URIResolverRegistry.getInstance().getCharacterReader(resolvedLocation)) {
Expand Down
6 changes: 4 additions & 2 deletions rascal-vscode-extension/src/test/vscode-suite/dsl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ parameterizedDescribe(function (errorRecovery: boolean) {

this.timeout(Delays.extremelySlow * 2);

printRascalOutputOnFailure('Language Parametric Rascal');

async function loadPico() {
const repl = new RascalREPL(bench, driver);
await repl.start();
Expand Down Expand Up @@ -103,6 +101,10 @@ parameterizedDescribe(function (errorRecovery: boolean) {
await fs.writeFile(TestWorkspace.picoFile, picoFileBackup);
});

afterEach("print output in case of test failure",
async function () { await printRascalOutputOnFailure(this, ide, "Language Parametric Rascal"); }
);

it("have highlighting and parse errors", async function () {
await ignoreFails(new Workbench().getEditorView().closeAllEditors());
const editor = await ide.openModule(TestWorkspace.picoFile);
Expand Down
15 changes: 7 additions & 8 deletions rascal-vscode-extension/src/test/vscode-suite/ide.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ describe('IDE', function () {

this.timeout(Delays.extremelySlow * 2);

printRascalOutputOnFailure('Rascal MPL');

before(async () => {
browser = VSBrowser.instance;
driver = browser.driver;
Expand All @@ -58,7 +56,10 @@ describe('IDE', function () {
await makeSureRascalModulesAreLoaded();
});

beforeEach(async () => {
beforeEach(async function () {
if (this.test?.title) {
await ide.screenshot("IDE-" + this.test?.title);
}
});

afterEach(async function () {
Expand All @@ -71,6 +72,9 @@ describe('IDE', function () {
}
});

afterEach("print output in case of test failure",
async function () { await printRascalOutputOnFailure(this, ide, "Rascal MPL"); }
);

async function makeSureRascalModulesAreLoaded(delay = Delays.verySlow) {
try {
Expand Down Expand Up @@ -157,11 +161,6 @@ describe('IDE', function () {
});

it("go to definition works across projects", async () => {
// due to a current bug, we have to make sure that the lib in the other project is correctly resolved
const libEditor = await ide.openModule(TestWorkspace.libFile);
await triggerTypeChecker(libEditor, "", true);
await bench.getEditorView().closeAllEditors();

const editor = await ide.openModule(TestWorkspace.libCallFile);
await triggerTypeChecker(editor, TestWorkspace.libCallFileTpl, true);
await editor.selectText("fib");
Expand Down
6 changes: 4 additions & 2 deletions rascal-vscode-extension/src/test/vscode-suite/repl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ describe('REPL', function () {

this.timeout(2 * Delays.extremelySlow);

printRascalOutputOnFailure('Rascal MPL');

before(async () => {
browser = VSBrowser.instance;
driver = browser.driver;
Expand All @@ -57,6 +55,10 @@ describe('REPL', function () {
await ide.cleanup();
});

afterEach("print output in case of test failure",
async function () { await printRascalOutputOnFailure(this, ide, "Rascal MPL"); }
);

it("should open without a project", async () => {
await new RascalREPL(bench, driver).start();
}).retries(2);
Expand Down
90 changes: 47 additions & 43 deletions rascal-vscode-extension/src/test/vscode-suite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import { assert } from "chai";
import { assert, expect } from "chai";
import { stat, unlink } from "fs/promises";
import path = require("path");
import * as os from 'os';
import { env } from "process";
import { BottomBarPanel, By, CodeLens, EditorView, Key, Locator, TerminalView, TextEditor, VSBrowser, WebDriver, WebElement, WebElementCondition, Workbench, until } from "vscode-extension-tester";
import * as os from 'os';
import { expect } from 'chai';
import path = require("path");

export async function sleep(ms: number) {
return new Promise(r => setTimeout(r, ms));
Expand Down Expand Up @@ -278,8 +277,9 @@ export class IDEOperations {
try {
await new Workbench().executeCommand("workbench.action.revertAndCloseActiveEditor");
} catch (ex) {
this.screenshot("revert failed " + tryCount);
console.log("Revert failed, but we ignore it", ex);
const title = await new TextEditor().getTitle();
this.screenshot(`revert of ${title} failed ` + tryCount);
console.log(`Revert of ${title} failed, but we ignore it`, ex);
}
try {
let anyEditor = true;
Expand All @@ -295,7 +295,7 @@ export class IDEOperations {
}
catch (ignored) {
this.screenshot("open editor check failed " + tryCount);
console.log("Open editor dirtry check failed: ", ignored);
console.log("Open editor dirty check failed: ", ignored);
return false;

}
Expand All @@ -313,12 +313,18 @@ export class IDEOperations {
}, Delays.normal, "Could not open file") as Promise<TextEditor>;
}

async appendSpace(editor: TextEditor, line = 1) {
const prompt = await new Workbench().openCommandPrompt();
await prompt.setText(`:${line},10000`);
await prompt.confirm();
await editor.typeText(' ');
}

async triggerTypeChecker(editor: TextEditor, { checkName = "Rascal check", waitForFinish = false, timeout = Delays.verySlow, tplFile = "" } = {}) {
const lastLine = await editor.getNumberOfLines();
if (tplFile) {
await ignoreFails(unlink(tplFile));
}
await editor.setTextAtLine(lastLine, await editor.getTextAtLine(lastLine) + " ");
await this.appendSpace(editor);
await sleep(50);
await editor.save();
if (waitForFinish) {
Expand Down Expand Up @@ -464,42 +470,40 @@ async function assureDebugLevelLoggingIsEnabled() {
await prompt.confirm();
}

export function printRascalOutputOnFailure(channel: 'Language Parametric Rascal' | 'Rascal MPL') {

export async function printRascalOutputOnFailure(context: Mocha.Context, ide: IDEOperations, channel: 'Language Parametric Rascal' | 'Rascal MPL') {
const ZOOM_OUT_FACTOR = 5;
afterEach("print output in case of failure", async function () {
if (!this.currentTest || this.currentTest.state !== "failed") { return; }
try {
for (let z = 0; z < ZOOM_OUT_FACTOR; z++) {
await new Workbench().executeCommand('workbench.action.zoomOut');
}
const bbp = new BottomBarPanel();
await bbp.maximize();
console.log('**********************************************');
console.log('***** Rascal MPL output for the failed tests: ');
let textLines: WebElement[] = [];
let tries = 0;
while (textLines.length === 0 && tries < 3) {
await showRascalOutput(bbp, channel);
textLines = await ignoreFails(bbp.findElements(By.className('view-line'))) ?? [];
tries++;
}
if (textLines.length === 0) {
console.log("We could not capture the output lines");
}
if (!context.currentTest || context.currentTest.state !== "failed") { return; }
await ide.screenshot(`failure - ${context.currentTest.fullTitle()}`);
try {
for (let z = 0; z < ZOOM_OUT_FACTOR; z++) {
await new Workbench().executeCommand('workbench.action.zoomOut');
}
const bbp = new BottomBarPanel();
await bbp.maximize();
console.log('**********************************************');
console.log('***** Rascal MPL output for the failed tests: ');
let textLines: WebElement[] = [];
let tries = 0;
while (textLines.length === 0 && tries < 3) {
await showRascalOutput(bbp, channel);
textLines = await ignoreFails(bbp.findElements(By.className('view-line'))) ?? [];
tries++;
}
if (textLines.length === 0) {
console.log("We could not capture the output lines");
}

for (const l of textLines) {
console.log(await l.getText());
}
await bbp.closePanel();
} catch (e) {
console.log('Error capturing output: ', e);
for (const l of textLines) {
console.log(await l.getText());
}
finally {
console.log('*******End output*****************************');
for (let z = 0; z < ZOOM_OUT_FACTOR; z++) {
await new Workbench().executeCommand('workbench.action.zoomIn');
}
await bbp.closePanel();
} catch (e) {
console.log('Error capturing output: ', e);
}
finally {
console.log('*******End output*****************************');
for (let z = 0; z < ZOOM_OUT_FACTOR; z++) {
await new Workbench().executeCommand('workbench.action.zoomIn');
}
});
}
}
Loading