Skip to content

Commit

Permalink
Extend existing test
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardSergeev committed Apr 30, 2020
1 parent 0fdc04a commit f77b8ed
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 58 deletions.
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
Expand All @@ -11,7 +11,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
"preLaunchTask": "npm"
"preLaunchTask": "npm: compile"
},
{
"name": "Launch Tests",
Expand All @@ -25,7 +25,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
"preLaunchTask": "npm"
"preLaunchTask": "npm: compile"
}
]
}
46 changes: 17 additions & 29 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process

// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",

// we want to run npm
"command": "npm",

// the command is a shell script
"isShellCommand": true,

// show the output window only if unrecognized errors occur.
"showOutput": "silent",

// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],

// The tsc compiler is started in watching mode
"isBackground": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
4 changes: 3 additions & 1 deletion input/test1.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
main :: IO ()
main = do
putStrLn "Hello, tester!"
putStr "Hello"
putStr ", "
putStrLn "tester!"
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@
"src/test/*"
],
"reporter": [
"html",
"text",
"lcov"
"text-summary",
"lcov",
"html"
],
"report-dir": "out/coverage"
},
Expand Down
53 changes: 31 additions & 22 deletions src/test/integration/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import * as vscode from 'vscode';
import * as assert from 'assert';
import * as path from 'path';
import { Position } from 'vscode';
import { Position, Selection } from 'vscode';
import Console from '../../console';
import { OpenOutputCommandId, GhciLogMarker } from '../../extension';


suite("Integration", function () {
test("Debug with breakpoint", async () => {

test("Simple debug run", async () => {
const doc = await vscode.workspace.openTextDocument(
path.join(__dirname, '../../../input/test1.hs')
);
await vscode.window.showTextDocument(doc);

const breakPoint = new Position(2, 2);
vscode.debug.addBreakpoints([
new vscode.SourceBreakpoint(
new vscode.Location(
doc.uri,
breakPoint
)
)
new vscode.SourceBreakpoint(new vscode.Location(doc.uri, new Position(2, 0)))
]);

const started = await vscode.debug.startDebugging(null, {
Expand All @@ -44,22 +39,26 @@ suite("Integration", function () {
if (output.endsWith('\r\n')) {
resolve(output);
}
},
this
);
}, this);
});

await new Promise<void>((resolve, _) => {
vscode.window.onDidChangeTextEditorSelection(_ => {
resolve();
},
this
);
}
);

const editor = vscode.window.activeTextEditor;
assert.deepEqual(editor.selection.start, breakPoint);

await didChangeTextEditorSelection();
assert.deepEqual(editor.selection.start, new Position(2, 2));

await vscode.commands.executeCommand('workbench.panel.repl.view.focus');
await vscode.env.clipboard.writeText('2+2');
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
const result = await vscode.commands.executeCommand('repl.action.acceptInput');

await vscode.commands.executeCommand('workbench.action.debug.stepInto');
await didChangeTextEditorSelection();
assert.deepEqual(editor.selection.start, new Position(3, 2));

await vscode.commands.executeCommand('workbench.action.debug.stepOver');
await didChangeTextEditorSelection();
assert.deepEqual(editor.selection.start, new Position(4, 2));

await vscode.commands.executeCommand('workbench.action.debug.continue');

Expand All @@ -85,3 +84,13 @@ suite("Integration", function () {
}
});
});


function didChangeTextEditorSelection() {
return new Promise<Selection>((resolve, _) => {
const disposable = vscode.window.onDidChangeTextEditorSelection(event => {
disposable.dispose();
resolve(event.selections[0]);
});
});
}

0 comments on commit f77b8ed

Please sign in to comment.