diff --git a/.github/workflows/ci_vscode.yml b/.github/workflows/ci_vscode.yml index 306be3350f97a..77f9311baf586 100644 --- a/.github/workflows/ci_vscode.yml +++ b/.github/workflows/ci_vscode.yml @@ -49,7 +49,7 @@ jobs: - name: Build Language Server working-directory: editors/vscode - run: pnpm run server:build:release + run: pnpm run server:build:debug - name: Compile VSCode working-directory: editors/vscode diff --git a/.vscode/launch.json b/.vscode/launch.json index 7c101313af8aa..7d5f4ff932913 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "sourceMaps": true, "outFiles": ["${workspaceFolder}/editors/vscode/dist/*.js"], "env": { - "SERVER_PATH_DEV": "${workspaceRoot}/target/debug/oxc_language_server", + "SERVER_PATH_DEV": "${workspaceRoot}/editors/vscode/target/debug/oxc_language_server", "RUST_LOG": "debug" } }, diff --git a/editors/vscode/.vscode-test.mjs b/editors/vscode/.vscode-test.mjs index 2ac3254339846..914f308809eaa 100644 --- a/editors/vscode/.vscode-test.mjs +++ b/editors/vscode/.vscode-test.mjs @@ -1,11 +1,23 @@ import { defineConfig } from '@vscode/test-cli'; import { existsSync, mkdirSync } from 'node:fs'; +import path from 'node:path'; if (!existsSync('./test_workspace')) { mkdirSync('./test_workspace'); } +const ext = process.platform === 'win32' ? '.exe' : ''; + export default defineConfig({ - files: 'out/**/*.spec.js', - workspaceFolder: './test_workspace', + tests: [{ + files: 'out/**/*.spec.js', + workspaceFolder: './test_workspace', + launchArgs: [ + // This disables all extensions except the one being testing + '--disable-extensions', + ], + env: { + SERVER_PATH_DEV: path.resolve(import.meta.dirname, `./target/debug/oxc_language_server${ext}`), + }, + }], }); diff --git a/editors/vscode/README.md b/editors/vscode/README.md index 021d3d4db02c5..a26bd79f8c49a 100644 --- a/editors/vscode/README.md +++ b/editors/vscode/README.md @@ -19,3 +19,8 @@ This is the linter for Oxc. The currently supported features are listed below. - Command to fix all auto-fixable content within the current text editor. - Support for `source.fixAll.oxc` as a code action provider. Configure this in your settings `editor.codeActionsOnSave` to automatically apply fixes when saving the file. + +## Testing + +Run `pnpm server:build:debug` to build the language server. +After that, you can test the vscode plugin + E2E Tests with `pnm test` diff --git a/editors/vscode/client/extension.spec.ts b/editors/vscode/client/extension.spec.ts index 26a2dc59b41b2..5be13f4352ec5 100644 --- a/editors/vscode/client/extension.spec.ts +++ b/editors/vscode/client/extension.spec.ts @@ -16,7 +16,9 @@ suite('commands', () => { suiteTeardown(async () => { const edit = new WorkspaceEdit(); - edit.deleteFile(fileUri); + edit.deleteFile(fileUri, { + ignoreIfNotExists: true, + }); await workspace.applyEdit(edit); }); diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 65817da17d1fc..1bc2452283164 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -143,7 +143,7 @@ "watch": "pnpm run compile --watch", "package": "vsce package --no-dependencies -o oxc_language_server.vsix", "install-extension": "code --install-extension oxc_language_server.vsix --force", - "server:build:debug": "cargo build -p oxc_language_server", + "server:build:debug": "cross-env CARGO_TARGET_DIR=./target cargo build -p oxc_language_server", "server:build:release": "cross-env CARGO_TARGET_DIR=./target cargo build -p oxc_language_server --release", "lint": "npx oxlint --config=oxlint.json --tsconfig=tsconfig.json", "test": "esbuild client/*.spec.ts --bundle --outdir=out --external:vscode --format=cjs --platform=node --target=node16 --minify --sourcemap && vscode-test",