diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index d1ee1c57..12ee9f19 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -2,7 +2,7 @@ name: Precommit on: push: - branches: [ "master" ] + branches: [ "master", "vscode-bundle-harper-ls" ] pull_request: branches: [ "master" ] diff --git a/justfile b/justfile index a32c17ae..c6e7ecc7 100644 --- a/justfile +++ b/justfile @@ -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 @@ -80,7 +99,7 @@ precommit: cargo bench just build-obsidian - just package-vscode + just test-vscode just build-web install: diff --git a/packages/vscode-plugin/src/tests/suite/integration.test.ts b/packages/vscode-plugin/src/tests/suite/integration.test.ts index ece63a78..b4c341b2 100644 --- a/packages/vscode-plugin/src/tests/suite/integration.test.ts +++ b/packages/vscode-plugin/src/tests/suite/integration.test.ts @@ -13,7 +13,7 @@ import { workspace } from 'vscode'; -describe('Integration tests', () => { +describe('Harper Extension', () => { let harper: Extension; let documentUri: Uri; @@ -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', @@ -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[] = [