-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from Code-Inspect/12-add-tests-for-all-existin…
…g-actions Add tests for all existing actions
- Loading branch information
Showing
14 changed files
with
135 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import { defineConfig } from '@vscode/test-cli'; | ||
|
||
export default defineConfig({ | ||
version: '1.60.0', | ||
files: 'out/test/**/*.test.js', | ||
workspaceFolder: './test-workspace', | ||
extensionDevelopmentPath: './', | ||
mocha: { | ||
timeout: 300000, | ||
slow: 1100 | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as vscode from 'vscode' | ||
import * as assert from 'assert' | ||
|
||
import { activateExtension, openTestFile } from './test-util' | ||
|
||
suite('diagram', () => { | ||
suiteSetup(async() => { | ||
await activateExtension() | ||
}) | ||
|
||
test('dataflow', async() => { | ||
await openTestFile('simple-example.R') | ||
const result: {webview: vscode.WebviewPanel, mermaid: string} | undefined = | ||
await vscode.commands.executeCommand('vscode-flowr.dataflow') | ||
assert.ok(result) | ||
assert.equal(result.webview.title, 'Dataflow Graph') | ||
assert.ok(result.mermaid.startsWith('flowchart TD')) | ||
}) | ||
}) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as vscode from 'vscode' | ||
import * as assert from 'assert' | ||
import { activateExtension, openTestFile } from './test-util' | ||
|
||
suite('slice', () => { | ||
suiteSetup(async() => { | ||
await activateExtension() | ||
}) | ||
|
||
test('slice cursor', async() => { | ||
await openTestFile('example.R', new vscode.Selection(7, 6, 7, 6)) | ||
const slice: string | undefined = await vscode.commands.executeCommand('vscode-flowr.slice.cursor') | ||
assert.ok(slice) | ||
assert.equal(slice, ` | ||
product <- 1 | ||
n <- 10 | ||
for(i in 1:(n - 1)) product <- product * i | ||
`.trim()) | ||
}) | ||
|
||
test('reconstruct cursor', async() => { | ||
await openTestFile('example.R', new vscode.Selection(7, 6, 7, 6)) | ||
const newEditor: vscode.TextEditor | undefined = await vscode.commands.executeCommand('vscode-flowr.slice.show.in.editor') | ||
assert.ok(newEditor) | ||
assert.equal(vscode.window.activeTextEditor, newEditor) | ||
assert.ok(newEditor.document.fileName.endsWith('Selection Slice')) | ||
assert.equal(newEditor.document.getText(), ` | ||
product <- 1 | ||
n <- 10 | ||
for(i in 1:(n - 1)) product <- product * i | ||
`.trim()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// also see https://github.com/microsoft/vscode-extension-samples/blob/main/lsp-sample/client/src/test/helper.ts for various test helper samples | ||
|
||
import * as vscode from 'vscode' | ||
import * as assert from 'assert' | ||
import * as path from 'path' | ||
import type { FlowrInternalSession } from '../flowr/internal-session' | ||
|
||
export async function activateExtension(): Promise<void> { | ||
const ext = vscode.extensions.getExtension('code-Inspect.vscode-flowr') | ||
|
||
assert.notEqual(ext, undefined, 'extension not found') | ||
|
||
await assert.doesNotReject(async() => { | ||
await ext?.activate() | ||
}, 'extension activation failed') | ||
|
||
// force start a local shell and wait, since there seem to be some async issues with commands | ||
const session: FlowrInternalSession = await vscode.commands.executeCommand('vscode-flowr.session.internal') | ||
assert.equal(session.state, 'active') | ||
} | ||
|
||
export async function openTestFile(name: string, selection?: vscode.Selection): Promise<vscode.TextEditor> { | ||
const file = path.resolve(__dirname, '..', '..', 'test-workspace', name) | ||
const doc = await vscode.workspace.openTextDocument(file) | ||
const editor = await vscode.window.showTextDocument(doc) | ||
if(selection) { | ||
editor.selection = selection | ||
} | ||
return editor | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"vscode-flowr.verboseLog": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sum <- 0 | ||
product <- 1 | ||
w <- 7 | ||
n <- 10 | ||
|
||
for (i in 1:(n - 1)) { | ||
sum <- sum + i + w | ||
product <- product * i | ||
} | ||
|
||
cat("Sum:", sum, "\n") | ||
cat("Product:", product, "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
X <- 2 | ||
Y <- X + 1 |