-
Notifications
You must be signed in to change notification settings - Fork 41
Add infrastructure for VS Code extension tests #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
80ad154
First draft of simple extension test
juliasilge 1d6d2e9
Update dependencies
juliasilge d8a09cf
Oops didn't use yarn
juliasilge 6c79915
Iterate on tests
juliasilge f248b3e
Update build scripts to hopefully run and compile tests
juliasilge d59b40a
I keep accidentally using npm
juliasilge 3f19991
Make a simpler test and simpler `yarn test` setup
juliasilge 39ad547
Add some help for working from the root
juliasilge fa3e13b
First go at GH actions
juliasilge 979b1a8
Try using xvfb-run
juliasilge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or 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,31 @@ | ||
|
||
name: Test VS Code Extension | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-extension: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
|
||
- name: Update build environment and install XVFB | ||
run: | | ||
sudo apt-get -y update | ||
sudo apt-get -y install --fix-missing xvfb | ||
|
||
- name: Compile and run tests | ||
run: | | ||
yarn install --immutable --immutable-cache --check-cache | ||
xvfb-run yarn test-vscode |
This file contains hidden or 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 |
---|---|---|
|
@@ -15,3 +15,5 @@ public/dist | |
.luarc.json | ||
.ipynb_checkpoints | ||
/.luarc.json | ||
.vscode-test | ||
*.vsix |
This file contains hidden or 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,2 +1,3 @@ | ||
out/ | ||
*.vsix | ||
test-out/ |
This file contains hidden or 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,8 @@ | ||
import { defineConfig } from '@vscode/test-cli'; | ||
|
||
export default defineConfig([ | ||
{ | ||
files: 'test-out/*.test.js', | ||
workspaceFolder: 'src/test/examples', | ||
}, | ||
]); |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -14,14 +14,25 @@ | |
*/ | ||
|
||
import { runBuild } from "build"; | ||
import * as glob from "glob"; | ||
|
||
const args = process.argv; | ||
const dev = args[2] === "dev"; | ||
const test = args[2] === "test"; | ||
const testFiles = glob.sync("src/test/*.ts"); | ||
|
||
runBuild({ | ||
const testBuildOptions = { | ||
entryPoints: testFiles, | ||
juliasilge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
outdir: 'test-out', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This creates the test |
||
external: ['vscode'], | ||
}; | ||
|
||
const defaultBuildOptions = { | ||
entryPoints: ['./src/main.ts'], | ||
outfile: './out/main.js', | ||
external: ['vscode'], | ||
minify: !dev, | ||
dev | ||
}); | ||
}; | ||
|
||
runBuild(test ? testBuildOptions : defaultBuildOptions); |
This file contains hidden or 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 hidden or 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,10 @@ | ||
--- | ||
title: "Hello, Quarto" | ||
format: html | ||
--- | ||
|
||
## Header | ||
|
||
```{python} | ||
1 + 1 | ||
``` |
This file contains hidden or 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,13 @@ | ||
import * as vscode from "vscode"; | ||
import * as assert from "assert"; | ||
import { exampleWorkspacePath } from "./test-utils"; | ||
import { isQuartoDoc } from "../core/doc"; | ||
|
||
suite("Quarto basics", () => { | ||
test("Can open a Quarto document", async () => { | ||
const doc = await vscode.workspace.openTextDocument(exampleWorkspacePath("hello.qmd")); | ||
const editor = await vscode.window.showTextDocument(doc); | ||
assert.strictEqual(editor?.document.languageId, "quarto"); | ||
assert.strictEqual(isQuartoDoc(editor?.document), true); | ||
}); | ||
}); |
This file contains hidden or 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,18 @@ | ||
import * as path from "path"; | ||
|
||
|
||
/** | ||
* Path to the root directory of the extension: | ||
* https://github.com/microsoft/vscode-python-tools-extension-template/blob/main/src/common/constants.ts | ||
*/ | ||
export const EXTENSION_ROOT_DIR = | ||
path.basename(__dirname) === "common" | ||
? path.dirname(path.dirname(__dirname)) | ||
: path.dirname(__dirname); | ||
|
||
export const TEST_PATH = path.join(EXTENSION_ROOT_DIR, "src", "test"); | ||
export const WORKSPACE_PATH = path.join(TEST_PATH, "examples"); | ||
|
||
export function exampleWorkspacePath(file: string): string { | ||
return path.join(WORKSPACE_PATH, file); | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we tell the
vscode-test
cli where to find the files.