diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6030cfa19..2630ab86b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore index c1e430d58..f134e7534 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ npm-debug.log lsp/ testFixture/.terraform.lock.hcl testFixture/.vscode +test/fixtures/.vscode .terraform/ .vscode-test-web .wdio-vscode-service diff --git a/.vscode-test.mjs b/.vscode-test.mjs new file mode 100644 index 000000000..a72637615 --- /dev/null +++ b/.vscode-test.mjs @@ -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; diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 99a12bf6e..2c8ee2cd2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -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" ] } diff --git a/build/downloader.ts b/build/downloader.ts index 9852f359a..c56bdca3c 100644 --- a/build/downloader.ts +++ b/build/downloader.ts @@ -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); diff --git a/package-lock.json b/package-lock.json index 4b0b6d7bf..7245ccf4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,13 +25,14 @@ "@types/chai": "^4.3.5", "@types/glob": "^8.1.0", "@types/mocha": "^10.0.1", - "@types/node": "^16.18.36", + "@types/node": "^18.x", "@types/vscode": "~1.82.0", "@types/webpack-env": "^1.18.0", "@types/which": "^3.0.0", "@typescript-eslint/eslint-plugin": "^5.59.5", "@typescript-eslint/parser": "^5.59.5", - "@vscode/test-electron": "^2.3.8", + "@vscode/test-cli": "^0.0.9", + "@vscode/test-electron": "^2.3.9", "@vscode/test-web": "^0.0.50", "@vscode/vsce": "^2.19.0", "assert": "^2.0.0", @@ -39,7 +40,6 @@ "eslint": "^8.40.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-prettier": "^4.2.1", - "glob": "^10.2.2", "mocha": "^10.2.0", "msw": "^1.2.2", "prettier": "^2.8.8", @@ -65,6 +65,12 @@ "node": ">=0.10.0" } }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -242,6 +248,15 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -535,6 +550,12 @@ "@types/node": "*" } }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true + }, "node_modules/@types/js-levenshtein": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@types/js-levenshtein/-/js-levenshtein-1.1.3.tgz", @@ -566,10 +587,13 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.18.61", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.61.tgz", - "integrity": "sha512-k0N7BqGhJoJzdh6MuQg1V1ragJiXTh8VUBAZTWjJ9cUq23SG0F0xavOwZbhiP4J3y20xd6jxKx+xNUhkMAi76Q==", - "dev": true + "version": "18.19.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", + "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/semver": { "version": "7.5.5", @@ -806,6 +830,65 @@ "vscode": "^1.60.0" } }, + "node_modules/@vscode/test-cli": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@vscode/test-cli/-/test-cli-0.0.9.tgz", + "integrity": "sha512-vsl5/ueE3Jf0f6XzB0ECHHMsd5A0Yu6StElb8a+XsubZW7kHNAOw4Y3TSSuDzKEpLnJ92nbMy1Zl+KLGCE6NaA==", + "dev": true, + "dependencies": { + "@types/mocha": "^10.0.2", + "c8": "^9.1.0", + "chokidar": "^3.5.3", + "enhanced-resolve": "^5.15.0", + "glob": "^10.3.10", + "minimatch": "^9.0.3", + "mocha": "^10.2.0", + "supports-color": "^9.4.0", + "yargs": "^17.7.2" + }, + "bin": { + "vscode-test": "out/bin.mjs" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@vscode/test-cli/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@vscode/test-cli/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@vscode/test-cli/node_modules/supports-color": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz", + "integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/@vscode/test-electron": { "version": "2.3.9", "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.9.tgz", @@ -1659,6 +1742,40 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, + "node_modules/c8": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-9.1.0.tgz", + "integrity": "sha512-mBWcT5iqNir1zIkzSPyI3NCR9EZCVI3WUD+AVO17MVWTSFNyUueXE82qTeampNtTr+ilN/5Ua3j24LgbCKjDVg==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@istanbuljs/schema": "^0.1.3", + "find-up": "^5.0.0", + "foreground-child": "^3.1.1", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.1.6", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.0.0", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1" + }, + "bin": { + "c8": "bin/c8.js" + }, + "engines": { + "node": ">=14.14.0" + } + }, + "node_modules/c8/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/cache-content-type": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-content-type/-/cache-content-type-1.0.1.tgz", @@ -2075,6 +2192,12 @@ "node": ">= 0.6" } }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, "node_modules/cookie": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", @@ -3446,6 +3569,12 @@ "node": ">=10" } }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, "node_modules/htmlparser2": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", @@ -4037,6 +4166,63 @@ "node": ">=0.10.0" } }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jackspeak": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", @@ -4565,6 +4751,21 @@ "node": ">=10" } }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -6808,6 +7009,40 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -7160,6 +7395,12 @@ "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==", "dev": true }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -7230,6 +7471,20 @@ "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, + "node_modules/v8-to-istanbul": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", + "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index 4845caf94..8e14ba54a 100644 --- a/package.json +++ b/package.json @@ -856,7 +856,7 @@ "download:artifacts": "ts-node ./build/downloader.ts", "vscode:prepublish": "npm run compile:prod", "package": "vsce package", - "test": "npm run compile:test && node ./out/test/runTest.js", + "test": "npm run compile:test && vscode-test", "test:unit:web": "npm run compile && vscode-test-web --headless --browser=chromium --extensionDevelopmentPath=. --extensionTestsPath=./out/web/test/integration/index.js", "lint": "eslint src --ext ts", "prettier": "prettier \"**/*.+(js|json|ts)\"", @@ -881,13 +881,14 @@ "@types/chai": "^4.3.5", "@types/glob": "^8.1.0", "@types/mocha": "^10.0.1", - "@types/node": "^16.18.36", + "@types/node": "^18.x", "@types/vscode": "~1.82.0", "@types/webpack-env": "^1.18.0", "@types/which": "^3.0.0", "@typescript-eslint/eslint-plugin": "^5.59.5", "@typescript-eslint/parser": "^5.59.5", - "@vscode/test-electron": "^2.3.8", + "@vscode/test-cli": "^0.0.9", + "@vscode/test-electron": "^2.3.9", "@vscode/test-web": "^0.0.50", "@vscode/vsce": "^2.19.0", "assert": "^2.0.0", @@ -895,7 +896,6 @@ "eslint": "^8.40.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-prettier": "^4.2.1", - "glob": "^10.2.2", "mocha": "^10.2.0", "msw": "^1.2.2", "prettier": "^2.8.8", diff --git a/src/test/helper.ts b/src/test/helper.ts index 6024209e9..e8837db1b 100644 --- a/src/test/helper.ts +++ b/src/test/helper.ts @@ -5,38 +5,124 @@ import * as vscode from 'vscode'; import * as path from 'path'; - -export let doc: vscode.TextDocument; -export let editor: vscode.TextEditor; -export let documentEol: string; -export let platformEol: string; +import * as assert from 'assert'; export async function open(docUri: vscode.Uri): Promise { try { - doc = await vscode.workspace.openTextDocument(docUri); - editor = await vscode.window.showTextDocument(doc); + const doc = await vscode.workspace.openTextDocument(docUri); + await vscode.window.showTextDocument(doc); } catch (e) { console.error(e); throw e; } } -export function getExtensionId(): string { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const pjson = require('../../package.json'); - return `${pjson.publisher}.${pjson.name}`; +export const getDocUri = (p: string): vscode.Uri => { + const documentPath = path.resolve(__dirname, '../../test/fixtures', p); + return vscode.Uri.file(documentPath); +}; + +export async function testCompletion( + docUri: vscode.Uri, + position: vscode.Position, + expectedCompletionList: vscode.CompletionList, +) { + const actualCompletionList = await vscode.commands.executeCommand( + 'vscode.executeCompletionItemProvider', + docUri, + position, + ); + + assert.deepStrictEqual(actualCompletionList.items.length, expectedCompletionList.items.length); + expectedCompletionList.items.forEach((expectedItem, i) => { + const actualItem = actualCompletionList.items[i]; + assert.deepStrictEqual(actualItem.label, expectedItem.label); + assert.deepStrictEqual(actualItem.kind, expectedItem.kind); + }); } -export const testFolderPath = path.resolve(__dirname, '..', '..', 'testFixture'); +export async function testHover(docUri: vscode.Uri, position: vscode.Position, expectedCompletionList: vscode.Hover[]) { + const actualhover = await vscode.commands.executeCommand( + 'vscode.executeHoverProvider', + docUri, + position, + ); -export const getDocPath = (p: string): string => { - return path.resolve(__dirname, '../../testFixture', p); -}; -export const getDocUri = (p: string): vscode.Uri => { - return vscode.Uri.file(getDocPath(p)); -}; + assert.equal(actualhover.length, expectedCompletionList.length); + expectedCompletionList.forEach((expectedItem, i) => { + const actualItem = actualhover[i]; + assert.deepStrictEqual(actualItem.contents, expectedItem.contents); + }); +} + +export async function testDefinitions( + docUri: vscode.Uri, + position: vscode.Position, + expectedDefinitions: vscode.Location[], +) { + const actualDefinitions = await vscode.commands.executeCommand( + 'vscode.executeDefinitionProvider', + docUri, + position, + ); + + assert.equal(actualDefinitions.length, expectedDefinitions.length); + expectedDefinitions.forEach((expectedItem, i) => { + const actualItem = actualDefinitions[i]; + if (actualItem instanceof vscode.Location) { + assert.deepStrictEqual(actualItem.uri.path, expectedItem.uri.path); + assert.deepStrictEqual(actualItem.range.start, expectedItem.range.start); + assert.deepStrictEqual(actualItem.range.end, expectedItem.range.end); + return; + } else { + // } else if (actualItem instanceof vscode.LocationLink) { + assert.deepStrictEqual(actualItem.targetUri.path, expectedItem.uri.path); + assert.deepStrictEqual(actualItem.targetRange.start, expectedItem.range.start); + assert.deepStrictEqual(actualItem.targetRange.end, expectedItem.range.end); + } + }); +} + +export async function testReferences( + docUri: vscode.Uri, + position: vscode.Position, + expectedDefinitions: vscode.Location[], +) { + const actualDefinitions = await vscode.commands.executeCommand( + 'vscode.executeReferenceProvider', + docUri, + position, + ); + + assert.equal(actualDefinitions.length, expectedDefinitions.length); + expectedDefinitions.forEach((expectedItem, i) => { + const actualItem = actualDefinitions[i]; + assert.deepStrictEqual(actualItem.uri.path, expectedItem.uri.path); + assert.deepStrictEqual(actualItem.range.start, expectedItem.range.start); + assert.deepStrictEqual(actualItem.range.end, expectedItem.range.end); + }); +} + +export async function testSymbols(docUri: vscode.Uri, symbolNames: string[]) { + const symbols = await vscode.commands.executeCommand( + 'vscode.executeDocumentSymbolProvider', + docUri, + ); + + assert.strictEqual(symbols.length, symbolNames.length); + symbols.forEach((symbol, i) => { + assert.strictEqual(symbol.name, symbolNames[i]); + }); +} + +export async function activateExtension() { + const ext = vscode.extensions.getExtension('hashicorp.terraform'); + if (!ext?.isActive) { + await ext?.activate(); + sleep(1000); + } +} -export async function setTestContent(content: string): Promise { - const all = new vscode.Range(doc.positionAt(0), doc.positionAt(doc.getText().length)); - return editor.edit((eb) => eb.replace(all, content)); +export async function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); } diff --git a/src/test/integration/codeAction.test.ts b/src/test/integration/codeAction.test.ts index 235e5d4f1..f507c4105 100644 --- a/src/test/integration/codeAction.test.ts +++ b/src/test/integration/codeAction.test.ts @@ -6,50 +6,61 @@ import * as vscode from 'vscode'; import * as assert from 'assert'; import { expect } from 'chai'; -import { getDocUri, open } from '../helper'; +import { activateExtension, getDocUri, open } from '../helper'; suite('code actions', () => { - teardown(async () => { - await vscode.commands.executeCommand('workbench.action.closeAllEditors'); - }); + suite('format all', function suite() { + const docUri = getDocUri('actions.tf'); - test('supported actions', async () => { - await vscode.workspace - .getConfiguration('terraform') - .update('languageServer.enable', true, vscode.ConfigurationTarget.Workspace); - await vscode.workspace - .getConfiguration('editor') - // eslint-disable-next-line @typescript-eslint/naming-convention - .update('codeActionsOnSave', { 'source.formatAll.terraform': true }, vscode.ConfigurationTarget.Workspace); + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); - const docUri = getDocUri('actions.tf'); - await open(docUri); - - const supported = [ - new vscode.CodeAction('Format Document', vscode.CodeActionKind.Source.append('formatAll').append('terraform')), - ]; - - // wait till the LS is ready to accept a code action request - await new Promise((r) => setTimeout(r, 1000)); - - for (let index = 0; index < supported.length; index++) { - const wanted = supported[index]; - const requested = wanted.kind?.value.toString(); - - const actions = await vscode.commands.executeCommand( - 'vscode.executeCodeActionProvider', - docUri, - new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), - requested, - ); - - assert.ok(actions); - expect(actions).not.to.be.undefined; - expect(wanted.kind?.value).not.to.be.undefined; - - assert.strictEqual(actions.length, 1); - assert.strictEqual(actions[0].title, wanted.title); - assert.strictEqual(actions[0].kind?.value, wanted.kind?.value); - } + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); + + test('formats the document', async () => { + await vscode.workspace + .getConfiguration('terraform') + .update('languageServer.enable', true, vscode.ConfigurationTarget.Workspace); + await vscode.workspace + .getConfiguration('editor') + // eslint-disable-next-line @typescript-eslint/naming-convention + .update('codeActionsOnSave', { 'source.formatAll.terraform': true }, vscode.ConfigurationTarget.Workspace); + + const supported = [ + new vscode.CodeAction('Format Document', vscode.CodeActionKind.Source.append('formatAll').append('terraform')), + ]; + + // wait till the LS is ready to accept a code action request + await new Promise((r) => setTimeout(r, 1000)); + + for (let index = 0; index < supported.length; index++) { + const wanted = supported[index]; + const requested = wanted.kind?.value.toString(); + + const actions = await vscode.commands.executeCommand( + 'vscode.executeCodeActionProvider', + docUri, + new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), + requested, + ); + + assert.ok(actions); + expect(actions).not.to.be.undefined; + expect(wanted.kind?.value).not.to.be.undefined; + + assert.strictEqual(actions.length, 1); + assert.strictEqual(actions[0].title, wanted.title); + assert.strictEqual(actions[0].kind?.value, wanted.kind?.value); + } + }); }); }); diff --git a/src/test/integration/completion.test.ts b/src/test/integration/completion.test.ts index 6d4bf9059..030c6f413 100644 --- a/src/test/integration/completion.test.ts +++ b/src/test/integration/completion.test.ts @@ -4,64 +4,141 @@ */ import * as vscode from 'vscode'; -import * as assert from 'assert'; -import { expect } from 'chai'; -import { getDocUri, open } from '../helper'; +import { assert } from 'chai'; +import { activateExtension, getDocUri, open, testCompletion } from '../helper'; + +const snippets = [ + new vscode.CompletionItem({ label: 'fore', description: 'For Each' }, vscode.CompletionItemKind.Snippet), + new vscode.CompletionItem({ label: 'module', description: 'Module' }, vscode.CompletionItemKind.Snippet), + new vscode.CompletionItem({ label: 'output', description: 'Output' }, vscode.CompletionItemKind.Snippet), + new vscode.CompletionItem({ label: 'provisioner', description: 'Provisioner' }, vscode.CompletionItemKind.Snippet), + new vscode.CompletionItem({ label: 'vare', description: 'Empty variable' }, vscode.CompletionItemKind.Snippet), + new vscode.CompletionItem({ label: 'varm', description: 'Map variable' }, vscode.CompletionItemKind.Snippet), +]; suite('completion', () => { - teardown(async () => { - await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + suite('root document completion', function suite() { + const docUri = getDocUri('empty.tf'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); + + test('simple completion', async () => { + const expected = [ + new vscode.CompletionItem('check', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('data', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('import', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('locals', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('module', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('moved', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('output', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('provider', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('removed', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('resource', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('terraform', vscode.CompletionItemKind.Class), + new vscode.CompletionItem('variable', vscode.CompletionItemKind.Class), + ]; + expected.push(...snippets); + await testCompletion(docUri, new vscode.Position(0, 0), { + items: expected, + }); + }); + }); + + suite('module completion', function suite() { + const docUri = getDocUri('main.tf'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); + + // Completion for inputs of a local module + test('inputs of a local module', async () => { + const expected = [ + new vscode.CompletionItem('count', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('depends_on', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('for_each', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('machine_type', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('providers', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('version', vscode.CompletionItemKind.Property), + ]; + expected.push(...snippets); + + await testCompletion(docUri, new vscode.Position(21, 0), { + items: expected, + }); + }); + + // Completion for a local module sources (prefix ./) + test('local module sources', async () => { + const expected = [ + new vscode.CompletionItem('"./ai"', vscode.CompletionItemKind.Text), + new vscode.CompletionItem('"./compute"', vscode.CompletionItemKind.Text), + ]; + + if (vscode.version <= '1.82.3') { + expected.push(...snippets); + } + + // module "compute" { + // source = "./compute" + // ^ + const location = new vscode.Position(18, 14); + + await testCompletion(docUri, location, { + items: expected, + }); + }); }); - test('simple completion', async () => { - const wanted = new vscode.CompletionList([ - new vscode.CompletionItem('check', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('data', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('import', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('locals', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('module', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('moved', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('output', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('provider', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('resource', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('terraform', vscode.CompletionItemKind.Class), - new vscode.CompletionItem('variable', vscode.CompletionItemKind.Class), - new vscode.CompletionItem({ label: 'fore', description: 'For Each' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'module', description: 'Module' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'output', description: 'Output' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem( - { label: 'provisioner', description: 'Provisioner' }, - vscode.CompletionItemKind.Snippet, - ), - new vscode.CompletionItem({ label: 'vare', description: 'Empty variable' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'varm', description: 'Map variable' }, vscode.CompletionItemKind.Snippet), - ]); - - const docUri = getDocUri('actions.tf'); - await open(docUri); - - const list = await vscode.commands.executeCommand( - 'vscode.executeCompletionItemProvider', - docUri, - new vscode.Position(0, 0), - ); - - assert.ok(list); - expect(list).not.to.be.undefined; - expect(list.items).not.to.be.undefined; - expect(list.items.length).to.be.greaterThanOrEqual(1); - - for (let index = 0; index < list.items.length; index++) { - const element: vscode.CompletionItem = list.items[index]; - assert.ok(element); - expect(element).not.to.be.undefined; - - const w = wanted.items[index]; - assert.ok(w); - expect(w).not.to.be.undefined; - assert.strictEqual(element.kind, w.kind); - // this can either be a string or a vscode.CompletionItemLabel, so use deep - assert.deepStrictEqual(element.label, w.label); - } + suite('tfvars completion', function suite() { + const docUri = getDocUri('terraform.tfvars'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform-vars', 'document language should be `terraform-vars`'); + }); + + test('simple variable completion', async () => { + const expected = [ + new vscode.CompletionItem('credentials_file', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('project', vscode.CompletionItemKind.Property), + new vscode.CompletionItem('region', vscode.CompletionItemKind.Property), + ]; + expected.push(...snippets); + await testCompletion(docUri, new vscode.Position(1, 0), { + items: expected, + }); + }); }); }); diff --git a/src/test/integration/definition.test.ts b/src/test/integration/definition.test.ts new file mode 100644 index 000000000..0702a3967 --- /dev/null +++ b/src/test/integration/definition.test.ts @@ -0,0 +1,94 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { activateExtension, getDocUri, open, testDefinitions } from '../helper'; + +suite('definitions', () => { + suite('go to module definition', function suite() { + const docUri = getDocUri('main.tf'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); + + test('returns definition for module source', async () => { + const location = new vscode.Location( + getDocUri('compute/main.tf'), + new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), + ); + + // module "compute" { + // source = "./compute" + await testDefinitions(docUri, new vscode.Position(18, 11), [location]); + }); + + test('returns definition for module attribute', async () => { + const location = new vscode.Location( + getDocUri('compute/variables.tf'), + new vscode.Range(new vscode.Position(0, 0), new vscode.Position(3, 1)), + ); + + // module "compute" { + // source = "./compute" + // instance_name = "terraform-machine" + await testDefinitions(docUri, new vscode.Position(20, 2), [location]); + }); + + test('returns definition for variable', async () => { + // provider "google" { + // credentials = file(var.credentials_file) + // project = var.project + // region = var.region + // zone = var.zone + const location = new vscode.Location( + getDocUri('variables.tf'), + new vscode.Range(new vscode.Position(4, 0), new vscode.Position(6, 1)), + ); + + await testDefinitions(docUri, new vscode.Position(10, 36), [location]); + }); + }); + + suite('go to variable definition', function suite() { + const docUri = getDocUri('terraform.tfvars'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform-vars', 'document language should be `terraform-vars`'); + }); + + test('returns definition for module source', async () => { + const location = new vscode.Location( + getDocUri('variables.tf'), + new vscode.Range(new vscode.Position(12, 0), new vscode.Position(14, 1)), + ); + + // module "compute" { + // source = "./compute" + await testDefinitions(docUri, new vscode.Position(0, 1), [location]); + }); + }); +}); diff --git a/src/test/integration/hover.test.ts b/src/test/integration/hover.test.ts new file mode 100644 index 000000000..36068c736 --- /dev/null +++ b/src/test/integration/hover.test.ts @@ -0,0 +1,39 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { activateExtension, getDocUri, open, testHover } from '../helper'; + +suite('hover', () => { + suite('core schema', function suite() { + const docUri = getDocUri('main.tf'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); + + test('returns docs for terraform block', async () => { + await testHover(docUri, new vscode.Position(0, 1), [ + new vscode.Hover( + new vscode.MarkdownString( + '**terraform** _Block_\n\nTerraform block used to configure some high-level behaviors of Terraform', + ), + new vscode.Range(new vscode.Position(14, 12), new vscode.Position(14, 20)), + ), + ]); + }); + }); +}); diff --git a/src/test/integration/index.ts b/src/test/integration/index.ts deleted file mode 100644 index 0a119870c..000000000 --- a/src/test/integration/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import * as path from 'path'; -import * as Mocha from 'mocha'; -import { glob } from 'glob'; -import { server } from './mocks/server'; -import { apiClient, tokenPluginId } from '../../terraformCloud'; - -export async function run(): Promise { - // Create the mocha test - const mocha = new Mocha({ - ui: 'tdd', - color: true, - }); - // integration tests require long activation time - mocha.timeout(100000); - // Establish API mocking before all tests. - mocha.globalSetup(() => { - apiClient.eject(tokenPluginId); - - server.listen(); - }); - // Clean up after the tests are finished. - mocha.globalTeardown(() => server.close()); - - // const testsRoot = path.resolve(__dirname, '..'); - const testsRoot = path.resolve(__dirname); - const testFiles = await glob('**/**.test.js', { cwd: testsRoot }); - - return new Promise((resolve, reject) => { - testFiles.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); - - try { - // Run the mocha test - mocha.run((failures) => { - if (failures > 0) { - reject(new Error(`${failures} tests failed.`)); - } else { - resolve(); - } - }); - } catch (err) { - console.error(err); - reject(err); - } - }); -} diff --git a/src/test/integration/references.test.ts b/src/test/integration/references.test.ts new file mode 100644 index 000000000..98c9d21b9 --- /dev/null +++ b/src/test/integration/references.test.ts @@ -0,0 +1,41 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import * as vscode from 'vscode'; +import * as assert from 'assert'; +import { activateExtension, getDocUri, open, testReferences } from '../helper'; + +suite('references', () => { + suite('module references', function suite() { + const docUri = getDocUri('variables.tf'); + + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); + + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); + + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); + + test('returns definition for module source', async () => { + await testReferences(docUri, new vscode.Position(12, 10), [ + new vscode.Location( + getDocUri('main.tf'), + new vscode.Range(new vscode.Position(14, 12), new vscode.Position(14, 20)), + ), + new vscode.Location( + getDocUri('terraform.tfvars'), + new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 4)), + ), + ]); + }); + }); +}); diff --git a/src/test/integration/symbols.test.ts b/src/test/integration/symbols.test.ts index ed5356ce2..795d27d19 100644 --- a/src/test/integration/symbols.test.ts +++ b/src/test/integration/symbols.test.ts @@ -5,34 +5,28 @@ import * as vscode from 'vscode'; import * as assert from 'assert'; -import { expect } from 'chai'; -import { getDocUri, open } from '../helper'; +import { activateExtension, getDocUri, open, testSymbols } from '../helper'; -suite('document symbols', () => { - teardown(async () => { - return await vscode.commands.executeCommand('workbench.action.closeActiveEditor'); - }); +suite('symbols', () => { + suite('basic language symbols', function suite() { + const docUri = getDocUri('sample.tf'); - const docUri = getDocUri('sample.tf'); + this.beforeAll(async () => { + await open(docUri); + await activateExtension(); + }); - test('returns symbols', async () => { - await testSymbols(docUri, ['provider "vault"', 'resource "vault_auth_backend" "b"', 'module "local"']); - }); -}); + teardown(async () => { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + }); -async function testSymbols(docUri: vscode.Uri, symbolNames: string[]) { - await open(docUri); - // Executing the command `vscode.executeDocumentSymbolProvider` to simulate requesting doc symbols - const symbols = (await vscode.commands.executeCommand( - 'vscode.executeDocumentSymbolProvider', - docUri, - )) as vscode.SymbolInformation[]; + test('language is registered', async () => { + const doc = await vscode.workspace.openTextDocument(docUri); + assert.equal(doc.languageId, 'terraform', 'document language should be `terraform`'); + }); - assert.ok(symbols); - expect(symbols).not.to.be.undefined; - - assert.strictEqual(symbols.length, symbolNames.length); - symbols.forEach((symbol, i) => { - assert.strictEqual(symbol.name, symbolNames[i]); + test('returns symbols', async () => { + await testSymbols(docUri, ['provider "vault"', 'resource "vault_auth_backend" "b"', 'module "local"']); + }); }); -} +}); diff --git a/src/test/mockSetup.ts b/src/test/mockSetup.ts new file mode 100644 index 000000000..4a1f31fe0 --- /dev/null +++ b/src/test/mockSetup.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import { apiClient, tokenPluginId } from '../terraformCloud'; +import { server } from './integration/mocks/server'; + +export async function mochaGlobalSetup() { + apiClient.eject(tokenPluginId); + + server.listen(); +} + +export async function mochaGlobalTeardown() { + server.close(); +} diff --git a/src/test/runTest.ts b/src/test/runTest.ts deleted file mode 100644 index 307bf4bf6..000000000 --- a/src/test/runTest.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import * as path from 'path'; -import { runTests } from '@vscode/test-electron'; -import { TestOptions } from '@vscode/test-electron/out/runTest'; - -async function main(): Promise { - // The folder containing the Extension Manifest package.json - // Passed to `--extensionDevelopmentPath` - // this is also the process working dir, even if vscode opens another folder - const extensionDevelopmentPath = path.resolve(__dirname, '../../'); - - // The path to the extension test runner script - // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './integration/index'); - - // common options for all runners - const options: TestOptions = { - version: process.env['VSCODE_VERSION'] ?? 'stable', - extensionDevelopmentPath, - extensionTestsPath, - launchArgs: ['testFixture', '--disable-extensions', '--disable-workspace-trust'], - }; - - try { - // Download VS Code, unzip it and run the integration test - // start in the fixtures folder to prevent the language server from walking all the - // project root folders, like node_modules - console.log(`_______________${options.version}_____________________`); - await runTests(options); - } catch (err) { - console.error(err); - console.error('Failed to run tests'); - process.exitCode = 1; - } -} - -main(); diff --git a/testFixture/actions.tf b/test/fixtures/actions.tf similarity index 100% rename from testFixture/actions.tf rename to test/fixtures/actions.tf diff --git a/test/fixtures/empty.tf b/test/fixtures/empty.tf new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/main.tf b/test/fixtures/main.tf index 34fcab64c..2ac3866ac 100644 --- a/test/fixtures/main.tf +++ b/test/fixtures/main.tf @@ -19,4 +19,6 @@ module "compute" { source = "./compute" instance_name = "terraform-machine" + } + diff --git a/testFixture/sample.tf b/test/fixtures/sample.tf similarity index 100% rename from testFixture/sample.tf rename to test/fixtures/sample.tf