Skip to content
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
5 changes: 5 additions & 0 deletions .github/workflows/ci_vscode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- "pnpm-lock.yaml"
- "crates/oxc_language_server/**"
- "apps/oxlint/src/lsp.rs"
- "apps/oxfmt/src/lsp/**"
- "editors/vscode/**"
- ".github/workflows/ci_vscode.yml"

Expand Down Expand Up @@ -50,6 +51,10 @@ jobs:
working-directory: editors/vscode
run: pnpm run oxlint:build:debug

- name: Build oxfmt (with napi)
working-directory: editors/vscode
run: pnpm run oxfmt:build:debug

- name: Compile VSCode
working-directory: editors/vscode
run: pnpm run compile
Expand Down
17 changes: 17 additions & 0 deletions editors/vscode/.vscode-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,22 @@ export default defineConfig({
timeout: 10_000,
},
},
// Oxfmt --lsp tests
{
files: 'out/**/*.spec.js',
workspaceFolder: './test_workspace',
launchArgs: [
// This disables all extensions except the one being tested
'--disable-extensions',
],
env: {
SINGLE_FOLDER_WORKSPACE: 'true',
SERVER_PATH_DEV: path.resolve(import.meta.dirname, `../../apps/oxfmt/dist/cli.js`),
SKIP_LINTER_TEST: 'true',
},
mocha: {
timeout: 10_000,
},
},
],
});
2 changes: 2 additions & 0 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
"install-extension": "code --install-extension oxc_language_server.vsix --force",
"oxlint:build:debug": "pnpm -C ../../apps/oxlint build-napi-test && pnpm -C ../../apps/oxlint build-js",
"oxlint:build:release": "pnpm -C ../../apps/oxlint build-napi && pnpm -C ../../apps/oxlint build-js",
"oxfmt:build:debug": "pnpm -C ../../apps/oxfmt build-napi-test && pnpm -C ../../apps/oxfmt build-js",
"oxfmt:build:release": "pnpm -C ../../apps/oxfmt build-napi && pnpm -C ../../apps/oxfmt build-js",
"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",
"test": "cross-env TEST=true pnpm run compile && vscode-test",
Expand Down
5 changes: 5 additions & 0 deletions editors/vscode/tests/code_actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ teardown(async () => {
});

suite('code actions', () => {
// Skip tests if linter tests are disabled
if (process.env.SKIP_LINTER_TEST === 'true') {
return;
}

// flaky test for multi workspace mode
testSingleFolderMode('listed code actions', async () => {
await loadFixture('debugger');
Expand Down
12 changes: 10 additions & 2 deletions editors/vscode/tests/commands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ suite('commands', () => {
testSingleFolderMode('listed commands', async () => {
const oxcCommands = (await commands.getCommands(true)).filter(x => x.startsWith('oxc.'));

const extraCommands = process.env.SKIP_LINTER_TEST === 'true' ? [] : [
'oxc.fixAll',
];

deepStrictEqual([
'oxc.restartServer',
'oxc.showOutputChannel',
'oxc.toggleEnable',
'oxc.applyAllFixesFile',
'oxc.fixAll',
'oxc.applyAllFixesFile', // TODO: only if linter tests are enabled
...extraCommands,
], oxcCommands);
});

Expand Down Expand Up @@ -67,6 +71,10 @@ suite('commands', () => {
});

test('oxc.fixAll', async () => {
// Skip tests if linter tests are disabled
if (process.env.SKIP_LINTER_TEST === 'true') {
return;
}
const edit = new WorkspaceEdit();
edit.createFile(fileUri, {
contents: Buffer.from('/* 😊 */debugger;'),
Expand Down
10 changes: 7 additions & 3 deletions editors/vscode/tests/e2e_server_formatter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {

suiteSetup(async () => {
await activateExtension();
await workspace.getConfiguration('oxc').update('fmt.experimental', true);
await workspace.getConfiguration('editor').update('defaultFormatter', 'oxc.oxc-vscode');
await workspace.saveAll();
});

teardown(async () => {
Expand All @@ -32,6 +35,7 @@ suite('E2E Server Formatter', () => {
test('formats code with `oxc.fmt.experimental`', async () => {
await workspace.getConfiguration('oxc').update('fmt.experimental', true);
await workspace.getConfiguration('editor').update('defaultFormatter', 'oxc.oxc-vscode');
await workspace.saveAll();
await loadFixture('formatting');

await sleep(500);
Expand All @@ -49,16 +53,16 @@ suite('E2E Server Formatter', () => {

test('formats code with `oxc.fmt.configPath`', async () => {
await loadFixture('formatting_with_config');

await workspace.getConfiguration('oxc').update('fmt.experimental', true);
await workspace.getConfiguration('oxc').update('fmt.configPath', './fixtures/formatter.json');
await workspace.getConfiguration('editor').update('defaultFormatter', 'oxc.oxc-vscode');
await workspace.getConfiguration('oxc').update('fmt.configPath', './fixtures/formatter.json');
await workspace.saveAll();

await sleep(500); // wait for the server to pick up the new config
const fileUri = Uri.joinPath(fixturesWorkspaceUri(), 'fixtures', 'formatting.ts');

const document = await workspace.openTextDocument(fileUri);
await window.showTextDocument(document);
await sleep(500); // wait for the server to pick up the new config
await commands.executeCommand('editor.action.formatDocument');
await workspace.saveAll();
const content = await workspace.fs.readFile(fileUri);
Expand Down
5 changes: 5 additions & 0 deletions editors/vscode/tests/e2e_server_linter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ teardown(async () => {


suite('E2E Server Linter', () => {
// Skip tests if linter tests are disabled
if (process.env.SKIP_LINTER_TEST === 'true') {
return;
}

test('simple debugger statement', async () => {
await loadFixture('debugger');
const diagnostics = await getDiagnostics('debugger.js');
Expand Down
Loading