Skip to content

Commit eee3004

Browse files
committed
Add new UI test for syntax highlighting in documents without extension
1 parent 1c6a4fb commit eee3004

File tree

1 file changed

+38
-8
lines changed
  • rascal-vscode-extension/src/test/vscode-suite

1 file changed

+38
-8
lines changed

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

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* POSSIBILITY OF SUCH DAMAGE.
2626
*/
2727

28-
import { SideBarView, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
28+
import { InputBox, TextEditor, SideBarView, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
2929
import { Delays, IDEOperations, ignoreFails, printRascalOutputOnFailure, RascalREPL, sleep, TestWorkspace } from './utils';
3030

3131
import { expect } from 'chai';
@@ -75,6 +75,13 @@ parameterizedDescribe(function (errorRecovery: boolean) {
7575
await repl.terminate();
7676
}
7777

78+
async function waitForPico() {
79+
const isPicoLoading = ide.statusContains("Pico");
80+
// we might miss this event, but we wait for it to show up
81+
await ignoreFails(driver.wait(isPicoLoading, Delays.normal, "Pico parser generator should have started"));
82+
// now wait for the Pico parser generator to disappear
83+
await driver.wait(async () => !(await isPicoLoading()), Delays.verySlow, "Pico parser generator should have finished", 100);
84+
}
7885

7986
before(async () => {
8087
browser = VSBrowser.instance;
@@ -103,14 +110,10 @@ parameterizedDescribe(function (errorRecovery: boolean) {
103110
await fs.writeFile(TestWorkspace.picoFile, picoFileBackup);
104111
});
105112

106-
it("have highlighting and parse errors", async function () {
113+
it("has highlighting and parse errors", async function () {
107114
await ignoreFails(new Workbench().getEditorView().closeAllEditors());
108115
const editor = await ide.openModule(TestWorkspace.picoFile);
109-
const isPicoLoading = ide.statusContains("Pico");
110-
// we might miss this event, but we wait for it to show up
111-
await ignoreFails(driver.wait(isPicoLoading, Delays.normal, "Pico parser generator should have started"));
112-
// now wait for the Pico parser generator to disappear
113-
await driver.wait(async () => !(await isPicoLoading()), Delays.verySlow, "Pico parser generator should have finished", 100);
116+
await waitForPico();
114117
await ide.hasSyntaxHighlighting(editor, Delays.slow);
115118
console.log("We got syntax highlighting");
116119
try {
@@ -126,7 +129,7 @@ parameterizedDescribe(function (errorRecovery: boolean) {
126129
}
127130
}).retries(2);
128131

129-
it("have highlighting and parse errors for second extension", async function () {
132+
it("has highlighting and parse errors for second extension", async function () {
130133
const editor = await ide.openModule(TestWorkspace.picoNewFile);
131134
await ide.hasSyntaxHighlighting(editor);
132135
try {
@@ -137,6 +140,33 @@ parameterizedDescribe(function (errorRecovery: boolean) {
137140
}
138141
});
139142

143+
it("has syntax highlighting in documents without extension", async function () {
144+
await bench.executeCommand("workbench.action.files.newUntitledFile");
145+
await bench.executeCommand("workbench.action.editor.changeLanguageMode");
146+
147+
const inputBox = new InputBox();
148+
await inputBox.setText("parametric-rascalmpl");
149+
await inputBox.confirm();
150+
151+
const file = "Untitled-1";
152+
const editor = await driver.wait(async () => {
153+
const result = await ignoreFails(new Workbench().getEditorView().openEditor(file)) as TextEditor;
154+
if (result && await ignoreFails(result.getTitle()) === file) {
155+
return result;
156+
}
157+
return undefined;
158+
}, Delays.normal, "Could not open file");
159+
expect(editor).to.not.be.undefined;
160+
161+
await editor!.setText(`begin
162+
declare
163+
a : natural;
164+
a := 2;
165+
end
166+
`, true);
167+
await ide.hasSyntaxHighlighting(editor!, Delays.slow);
168+
}).retries(2);
169+
140170
it("error recovery works", async function () {
141171
if (!errorRecovery) { this.skip(); }
142172
const editor = await ide.openModule(TestWorkspace.picoNewFile);

0 commit comments

Comments
 (0)