Skip to content

Commit

Permalink
Add end to end extension to language server testing (#1739)
Browse files Browse the repository at this point in the history
This commit adds end to end extension testing by migrating to vscode-cli and addin new test files to cover completion, go to definition, references, symbols, hover and code actions.

* Update @types/node to 18.x
* Migrate to vscode-test cli
* Move test fixture files
* End to end testing for completion, references and definitions
* bump terraform version
* Add snippets to completion on 1.82
* recommend vscode test runner for in IDE testing

This adds the following tests:

- Completions
  - Root document completion
  - Completion for a local module sources (prefix ./)
  - Completion for inputs of a local module
  - Completion of the variable name inside the tfvars file
- Go to Definition
  - Go-to-definition on a local module source
  - Go-to-definition on a module input
  - Go-to-definition on a var.something reference
  - Go-to-definition on the variable name inside tfvars
- References
  - Find module references
  - Find references on the variable block
- Symbols
  - Basic symbol return
- Hover
  - core schema provides docs
- Code actions
  - formats the document

Note: We now have two test folders: src/test and test/specs, along with two fixtures folders: test/fixtures and testFixtures. This does not address combining them or moving them because the wdio tsconfig/npm packaging conflicts with the vscode ones.
  • Loading branch information
jpogran authored Apr 12, 2024
1 parent a0a77a9 commit 2494e5d
Show file tree
Hide file tree
Showing 21 changed files with 796 additions and 247 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
terraform_version: '~1.6'
terraform_version: '~1.7'
- name: Terraform version
run: terraform version
- name: Clean Install Dependencies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ npm-debug.log
lsp/
testFixture/.terraform.lock.hcl
testFixture/.vscode
test/fixtures/.vscode
.terraform/
.vscode-test-web
.wdio-vscode-service
21 changes: 21 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { defineConfig } from '@vscode/test-cli';

const config = defineConfig({
version: process.env['VSCODE_VERSION'] ?? 'stable',
workspaceFolder: process.env['VSCODE_WORKSPACE_FOLDER'] ?? './test/fixtures',
launchArgs: ['--disable-extensions', '--disable-workspace-trust'],
files: 'out/test/**/*.test.js',
mocha: {
ui: 'tdd',
color: true,
timeout: 100000,
require: ['./out/test/mockSetup.js'],
},
});

export default config;
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"redhat.vscode-yaml",
"amodio.tsl-problem-matcher"
"amodio.tsl-problem-matcher",
"ms-vscode.extension-test-runner"
]
}
3 changes: 2 additions & 1 deletion build/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ const lsTarget = process.env.ls_target;
if (lsTarget !== undefined) {
const tgt = lsTarget.split('_');
os = tgt[0];
arch = tgt[1];

arch = tgt[1] as NodeJS.Architecture;
}

run(os, arch);
Loading

0 comments on commit 2494e5d

Please sign in to comment.