Skip to content

Test on PR and push to master #172

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 1 commit into from
Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Tests
permissions: read-all
on:
push:
branches:
- master
pull_request:
branches: master
types: [opened, synchronize, reopened]

jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: yarn
- run: yarn install --frozen-lockfile
- run: xvfb-run -a yarn test
if: runner.os == 'Linux'
- run: yarn test
if: runner.os != 'Linux'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"test-compile": "tsc -p ./",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"pretest": "yarn run compile && yarn run lint && yarn run esbuild",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
Expand Down
21 changes: 18 additions & 3 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as path from "path";
import * as cp from "child_process";

import { runTests } from "vscode-test";
import {
runTests,
resolveCliPathFromVSCodeExecutablePath,
downloadAndUnzipVSCode,
} from "vscode-test";

async function main() {
try {
Expand All @@ -12,11 +17,21 @@ async function main() {
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "./suite/index");

// Download VS Code, unzip it and run the integration test
const vscodeExecutablePath = await downloadAndUnzipVSCode();
const cliPath =
resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);

// Install extension dependencies
cp.spawnSync(cliPath, ["--install-extension", "pokey.parse-tree"], {
encoding: "utf-8",
stdio: "inherit",
});

// Run the integration test
await runTests({
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: ["--disable-extensions"],
});
} catch (err) {
console.error("Failed to run tests");
Expand Down
3 changes: 2 additions & 1 deletion src/test/suite/recorded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ suite("recorded test cases", async function () {
__dirname,
"../../../src/test/suite/fixtures/recorded"
);
const files = await walkFilesSync(directory);
const files = walkFilesSync(directory);

teardown(() => {
sinon.restore();
Expand Down Expand Up @@ -82,6 +82,7 @@ suite("recorded test cases", async function () {

// Wait for cursorless to set up decorations
cursorlessApi.addDecorations();
await new Promise((resolve) => setTimeout(resolve, 100));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be necessary; let's figure out how to remove it in a follow-up


// Assert that recorded decorations are present
Object.entries(fixture.marks).forEach(([key, token]) => {
Expand Down