Skip to content

Commit

Permalink
feat(vscode-plugin): use test-vscode in precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
mcecode committed Sep 20, 2024
1 parent 4c1c506 commit b898b72
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Precommit

on:
push:
branches: [ "master" ]
branches: [ "master", "vscode-bundle-harper-ls" ]
pull_request:
branches: [ "master" ]

Expand Down
21 changes: 20 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ build-obsidian:

zip harper-obsidian-plugin.zip manifest.json main.js

# This assumes that `harper-ls` has been compiled and is located at `target/release`.
test-vscode:
#! /bin/bash
set -eo pipefail

ext_dir="{{justfile_directory()}}/packages/vscode-plugin"
bin_dir="${ext_dir}/bin"

mkdir "$bin_dir"
cp "{{justfile_directory()}}/target/release/harper-ls"* "$bin_dir"
cd "$ext_dir"

yarn install -f
if [[ "$GITHUB_ACTIONS" == "true" ]] && [[ "$RUNNER_OS" == "Linux" ]]; then
xvfb-run --auto-servernum yarn test
else
yarn test
fi

# This assumes that `harper-ls` or `harper-ls.exe` exists in `packages/vscode-plugin/bin`.
package-vscode target:
#! /bin/bash
Expand Down Expand Up @@ -80,7 +99,7 @@ precommit:
cargo bench

just build-obsidian
just package-vscode
just test-vscode
just build-web

install:
Expand Down
14 changes: 7 additions & 7 deletions packages/vscode-plugin/src/tests/suite/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
workspace
} from 'vscode';

describe('Integration tests', () => {
describe('Harper Extension', () => {
let harper: Extension<void>;
let documentUri: Uri;

Expand All @@ -26,21 +26,21 @@ describe('Integration tests', () => {
await window.showTextDocument(await workspace.openTextDocument(documentUri));

// Wait for `harper-ls` to start
await sleep(100);
await sleep(500);
});

it('Runs', () => {
it('runs', () => {
expect(harper.isActive).toBe(true);
});

it('Gives correct diagnostics', () => {
it('gives correct diagnostics', () => {
const actual = languages.getDiagnostics(documentUri);
const expected: Diagnostic[] = [
{
source: 'Harper',
message: 'Did you mean to repeat this word?',
severity: DiagnosticSeverity.Information,
range: new Range(new Position(2, 43), new Position(2, 48))
range: new Range(new Position(2, 39), new Position(2, 48))
},
{
source: 'Harper',
Expand All @@ -59,11 +59,11 @@ describe('Integration tests', () => {
}
});

it('Updates diagnostics on configuration change', async () => {
it('updates diagnostics on configuration change', async () => {
const config = workspace.getConfiguration('harper-ls.linters');
await config.update('repeated_words', false, ConfigurationTarget.Workspace);
// Wait for `harper-ls` to restart
await sleep(500);
await sleep(1000);

const actual = languages.getDiagnostics(documentUri);
const expected: Diagnostic[] = [
Expand Down

0 comments on commit b898b72

Please sign in to comment.