Changesets · Branches · Tags · Compare
| Changeset | 68e8a01e26c282d0a89b44ecd920c765953ab3bcb9ef2610d3716f6b4bc21422 |
|---|---|
| Author | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-06-29 19:55 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-06-29 19:55 -07:00 |
| Parents | 2b414e1c0982, 38059280d80d |
9 files changed
modified .vscode/launch.json +0 −26
| @@ -73,32 +73,6 @@ | ||
| 73 | 73 | "sourceMaps": true |
| 74 | 74 | // "preLaunchTask": "gui:dev" |
| 75 | 75 | }, |
| 76 | - // Has to be run after starting the server (separately or using the compound configuration) | |
| 77 | - { | |
| 78 | - "name": "Run tests", | |
| 79 | - "type": "extensionHost", | |
| 80 | - "request": "launch", | |
| 81 | - "cwd": "${workspaceFolder}/extensions/vscode", | |
| 82 | - "runtimeExecutable": "${execPath}", | |
| 83 | - "args": [ | |
| 84 | - // Pass a directory to run tests in | |
| 85 | - "${workspaceFolder}/extensions/vscode/manual-testing-sandbox", | |
| 86 | - "--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode", | |
| 87 | - "--extensionTestsPath=${workspaceFolder}/extensions/vscode/out/test/runner/mochaRunner" | |
| 88 | - ], | |
| 89 | - "outFiles": [ | |
| 90 | - // Allows setting breakpoints in test suites across the /src folder | |
| 91 | - "${workspaceFolder}/extensions/vscode/out/test/test-suites/**/*.js", | |
| 92 | - // Allows setting breakpoints in mocha test runner file | |
| 93 | - "${workspaceFolder}/extensions/vscode/out/test/runner/**/*.js" | |
| 94 | - ], | |
| 95 | - "internalConsoleOptions": "openOnSessionStart", | |
| 96 | - "preLaunchTask": "vscode-extension:tests:build", | |
| 97 | - "env": { | |
| 98 | - // Avoid timing out when stopping on breakpoints during debugging in VSCode | |
| 99 | - "MOCHA_TIMEOUT": "0" | |
| 100 | - } | |
| 101 | - }, | |
| 102 | 76 | { |
| 103 | 77 | "name": "[Core] Jest Test Debugger, Current Open File", |
| 104 | 78 | "type": "node", |
modified .vscode/tasks.json +0 −33
| @@ -109,39 +109,6 @@ | ||
| 109 | 109 | "cwd": "${workspaceFolder}/extensions/vscode" |
| 110 | 110 | } |
| 111 | 111 | }, |
| 112 | - // | |
| 113 | - // Compile and bundle tests | |
| 114 | - { | |
| 115 | - "label": "vscode-extension:tests:build", | |
| 116 | - "dependsOn": [ | |
| 117 | - // Build the extension | |
| 118 | - "vscode-extension:build", | |
| 119 | - // To detect compile errors - this type checks both the extension and the tests | |
| 120 | - "tsc:watch", | |
| 121 | - "vscode-extension:tests:esbuild" | |
| 122 | - ] | |
| 123 | - }, | |
| 124 | - { | |
| 125 | - "label": "vscode-extension:tests:esbuild", | |
| 126 | - "type": "npm", | |
| 127 | - "script": "build-test", | |
| 128 | - "path": "extensions/vscode", | |
| 129 | - "problemMatcher": [ | |
| 130 | - { | |
| 131 | - "pattern": [ | |
| 132 | - { | |
| 133 | - "regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$", | |
| 134 | - "file": 1, | |
| 135 | - "line": 2, | |
| 136 | - "column": 3, | |
| 137 | - "severity": 4, | |
| 138 | - "message": 5 | |
| 139 | - } | |
| 140 | - ] | |
| 141 | - } | |
| 142 | - ] | |
| 143 | - }, | |
| 144 | - // | |
| 145 | 112 | // Install or update all dependencies for all projects in the monrepo |
| 146 | 113 | { |
| 147 | 114 | "label": "install-all-dependencies", |
modified extensions/vscode/.vscodeignore +0 −1
| @@ -18,7 +18,6 @@ | ||
| 18 | 18 | |
| 19 | 19 | manual-testing-sandbox |
| 20 | 20 | esbuild.js |
| 21 | -esbuild.test.mjs | |
| 22 | 21 | importMetaUrl.js |
| 23 | 22 | scripts |
| 24 | 23 | e2e |
deleted extensions/vscode/esbuild.test.mjs +0 −67
| @@ -1,67 +0,0 @@ | ||
| 1 | -import * as esbuild from "esbuild"; | |
| 2 | -import glob from "glob"; | |
| 3 | - | |
| 4 | -/** | |
| 5 | - * Bundles tests into multiple files, runTestOnVSCodeHost is then run using node runTestOnVSCodeHost.js | |
| 6 | - * It downloads vscode, starts it and passes test file to run - mochaRunner.js | |
| 7 | - * mochaRunner.js then runs tests using Mocha class | |
| 8 | - */ | |
| 9 | - | |
| 10 | -console.log("Bundling tests..."); | |
| 11 | - | |
| 12 | -// Bundles script to run tests on VSCode host + mocha runner that will be invoked from within VSCode host | |
| 13 | -await esbuild.build({ | |
| 14 | - entryPoints: [ | |
| 15 | - // Runs mocha runner on VSCode host using runTests from @vscode/test-electron | |
| 16 | - "src/test/runner/runTestOnVSCodeHost.ts", | |
| 17 | - | |
| 18 | - // Runs the bundled tests using Mocha class | |
| 19 | - "src/test/runner/mochaRunner.ts", | |
| 20 | - ], | |
| 21 | - bundle: true, | |
| 22 | - outdir: "out", | |
| 23 | - | |
| 24 | - external: [ | |
| 25 | - "vscode", | |
| 26 | - | |
| 27 | - // Its important to externalize mocha, otherwise mocha seems to be not initialized properly when running tests | |
| 28 | - // Example warning by esbuild when mocha is not externalized: | |
| 29 | - // [WARNING] "./reporters/parallel-buffered" should be marked as external for use with "require.resolve" [require-resolve-not-external] | |
| 30 | - "mocha", | |
| 31 | - ], | |
| 32 | - format: "cjs", | |
| 33 | - platform: "node", | |
| 34 | - sourcemap: true, | |
| 35 | - loader: { | |
| 36 | - // eslint-disable-next-line @typescript-eslint/naming-convention | |
| 37 | - ".node": "file", | |
| 38 | - }, | |
| 39 | -}); | |
| 40 | - | |
| 41 | -/** | |
| 42 | - * Note: Bundling is done to work around import issues, for example with fkill that does not provide cjs module. | |
| 43 | - * Rather than figuring out a combination of tsconfig.json that would work, I decided to bundle tests instead. | |
| 44 | - */ | |
| 45 | -await esbuild.build({ | |
| 46 | - // Tests can be added anywhere in src folder | |
| 47 | - entryPoints: glob.sync("src/**/*.test.ts"), | |
| 48 | - bundle: true, | |
| 49 | - outdir: "out", | |
| 50 | - external: [ | |
| 51 | - "vscode", | |
| 52 | - | |
| 53 | - // Its important to externalize mocha, otherwise mocha seems to be not initialized properly when running tests | |
| 54 | - "mocha", | |
| 55 | - ], | |
| 56 | - format: "cjs", | |
| 57 | - platform: "node", | |
| 58 | - sourcemap: true, | |
| 59 | - loader: { | |
| 60 | - // eslint-disable-next-line @typescript-eslint/naming-convention | |
| 61 | - ".node": "file", | |
| 62 | - }, | |
| 63 | - // To allow import.meta.path for transformers.js | |
| 64 | - // https://github.com/evanw/esbuild/issues/1492#issuecomment-893144483 | |
| 65 | - inject: ["./scripts/importMetaUrl.js"], | |
| 66 | - define: { "import.meta.url": "importMetaUrl" }, | |
| 67 | -}); |
modified extensions/vscode/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified extensions/vscode/package.json +5 −10
| @@ -622,10 +622,8 @@ | ||
| 622 | 622 | "rebuild": "electron-rebuild -v 19.1.8 node-pty", |
| 623 | 623 | "lint": "eslint src --ext ts", |
| 624 | 624 | "lint:fix": "eslint . --ext ts --fix", |
| 625 | - "build-test": "npm run esbuild && node esbuild.test.mjs", | |
| 626 | - "test": "npm run build-test && node ./out/runTestOnVSCodeHost.js", | |
| 625 | + "test": "vitest run", | |
| 627 | 626 | "vitest": "vitest run", |
| 628 | - "quick-test": "npm run build-test && node ./out/runTestOnVSCodeHost.js", | |
| 629 | 627 | "write-build-timestamp": "node scripts/write-build-timestamp.js", |
| 630 | 628 | "prepackage": "node scripts/prepackage.js", |
| 631 | 629 | "package": "node scripts/package.js", |
| @@ -661,11 +659,12 @@ | ||
| 661 | 659 | "@types/cors": "^2.8.17", |
| 662 | 660 | "@types/express": "^4.17.21", |
| 663 | 661 | "@types/follow-redirects": "^1.14.4", |
| 664 | - "@types/glob": "^8.0.0", | |
| 665 | - "@types/mocha": "^10.0.6", | |
| 662 | + "@types/mocha": "^10.0.10", | |
| 666 | 663 | "@types/node": "16.x", |
| 664 | + "@types/node-fetch": "^2.6.12", | |
| 667 | 665 | "@types/react-dom": "^18.2.4", |
| 668 | 666 | "@types/request": "^2.48.8", |
| 667 | + "@types/uuid": "^10.0.0", | |
| 669 | 668 | "@types/vscode": "1.70", |
| 670 | 669 | "@types/ws": "^8.5.4", |
| 671 | 670 | "@typescript-eslint/eslint-plugin": "^5.45.0", |
| @@ -675,9 +674,7 @@ | ||
| 675 | 674 | "esbuild": "0.17.19", |
| 676 | 675 | "esbuild-visualizer": "^0.6.0", |
| 677 | 676 | "eslint": "^8.28.0", |
| 678 | - "glob": "^8.0.3", | |
| 679 | 677 | "json-schema-to-typescript": "^12.0.0", |
| 680 | - "mocha": "^10.4.0", | |
| 681 | 678 | "ovsx": "^0.8.3", |
| 682 | 679 | "rimraf": "^5.0.5", |
| 683 | 680 | "typescript": "^5.6.3", |
| @@ -689,10 +686,7 @@ | ||
| 689 | 686 | "@continuedev/fetch": "^1.0.10", |
| 690 | 687 | "@electron/rebuild": "^3.2.10", |
| 691 | 688 | "@reduxjs/toolkit": "^1.9.3", |
| 692 | - "@types/node-fetch": "^2.6.11", | |
| 693 | - "@types/uuid": "^9.0.8", | |
| 694 | 689 | "@vscode/ripgrep": "^1.15.9", |
| 695 | - "@vscode/test-electron": "^2.3.9", | |
| 696 | 690 | "axios": "^1.2.5", |
| 697 | 691 | "core": "file:../../core", |
| 698 | 692 | "cors": "^2.8.5", |
| @@ -714,6 +708,7 @@ | ||
| 714 | 708 | "jsdom": "^24.0.0", |
| 715 | 709 | "lru-cache": "^11.0.2", |
| 716 | 710 | "minisearch": "^7.0.0", |
| 711 | + "mocha": "^11.7.1", | |
| 717 | 712 | "monaco-editor": "^0.45.0", |
| 718 | 713 | "monaco-vscode-textmate-theme-converter": "^0.1.7", |
| 719 | 714 | "ncp": "^2.0.0", |
deleted extensions/vscode/src/test/runner/mochaRunner.ts +0 −49
| @@ -1,49 +0,0 @@ | ||
| 1 | -import * as path from "node:path"; | |
| 2 | - | |
| 3 | -import * as glob from "glob"; | |
| 4 | -import Mocha from "mocha"; | |
| 5 | - | |
| 6 | -export function run() { | |
| 7 | - // Avoid timing out when stopping on breakpoints during debugging in VSCode | |
| 8 | - const timeoutOption = process.env.MOCHA_TIMEOUT | |
| 9 | - ? Number.parseInt(process.env.MOCHA_TIMEOUT) | |
| 10 | - : // : undefined; | |
| 11 | - 30_000; | |
| 12 | - | |
| 13 | - // Create the mocha test | |
| 14 | - const mocha = new Mocha({ | |
| 15 | - ui: "tdd", | |
| 16 | - color: true, | |
| 17 | - timeout: timeoutOption, | |
| 18 | - }); | |
| 19 | - | |
| 20 | - // See esbuild.test.mjs for more details | |
| 21 | - // Assumes this file is in out/test/runner/mochaRunner.js | |
| 22 | - const compiledTestSuitesDirectory = path.resolve(__dirname); | |
| 23 | - | |
| 24 | - glob | |
| 25 | - .sync("**/**.test.js", { cwd: compiledTestSuitesDirectory }) | |
| 26 | - .forEach((file) => { | |
| 27 | - mocha.addFile(path.resolve(compiledTestSuitesDirectory, file)); | |
| 28 | - }); | |
| 29 | - | |
| 30 | - console.log( | |
| 31 | - `Testing files in ${compiledTestSuitesDirectory}: ${mocha.files}`, | |
| 32 | - ); | |
| 33 | - | |
| 34 | - return new Promise<void>((resolve, reject) => { | |
| 35 | - try { | |
| 36 | - // Run the mocha test | |
| 37 | - mocha.run((failures) => { | |
| 38 | - if (failures > 0) { | |
| 39 | - reject(new Error(`${failures} tests failed.`)); | |
| 40 | - } else { | |
| 41 | - resolve(); | |
| 42 | - } | |
| 43 | - }); | |
| 44 | - } catch (err) { | |
| 45 | - console.error(err); | |
| 46 | - reject(err); | |
| 47 | - } | |
| 48 | - }); | |
| 49 | -} |
deleted extensions/vscode/src/test/runner/runTestOnVSCodeHost.ts +0 −127
| @@ -1,127 +0,0 @@ | ||
| 1 | -import fs from "node:fs"; | |
| 2 | -import * as path from "node:path"; | |
| 3 | - | |
| 4 | -import { runTests } from "@vscode/test-electron"; | |
| 5 | -import { defaultConfig } from "core/config/default"; | |
| 6 | - | |
| 7 | -export const testWorkspacePath = path.resolve( | |
| 8 | - __dirname, | |
| 9 | - "..", | |
| 10 | - "src", | |
| 11 | - "test", | |
| 12 | - "fixtures", | |
| 13 | - "test-workspace", | |
| 14 | -); | |
| 15 | - | |
| 16 | -const continueGlobalDir = path.resolve( | |
| 17 | - __dirname, | |
| 18 | - "..", | |
| 19 | - "src", | |
| 20 | - "test", | |
| 21 | - "fixtures", | |
| 22 | - ".continue", | |
| 23 | -); | |
| 24 | - | |
| 25 | -function setupTestWorkspace() { | |
| 26 | - if (fs.existsSync(testWorkspacePath)) { | |
| 27 | - fs.rmSync(testWorkspacePath, { recursive: true }); | |
| 28 | - } | |
| 29 | - fs.mkdirSync(testWorkspacePath, { | |
| 30 | - recursive: true, | |
| 31 | - }); | |
| 32 | - | |
| 33 | - fs.writeFileSync( | |
| 34 | - path.join(testWorkspacePath, "test.py"), | |
| 35 | - "print('Hello World!')", | |
| 36 | - ); | |
| 37 | - fs.writeFileSync( | |
| 38 | - path.join(testWorkspacePath, "index.js"), | |
| 39 | - "console.log('Hello World!')", | |
| 40 | - ); | |
| 41 | - fs.writeFileSync( | |
| 42 | - path.join(testWorkspacePath, "test.py"), | |
| 43 | - "print('Hello World!')", | |
| 44 | - ); | |
| 45 | - fs.mkdirSync(path.join(testWorkspacePath, "test-folder")); | |
| 46 | - fs.writeFileSync( | |
| 47 | - path.join(testWorkspacePath, "test-folder", "test.js"), | |
| 48 | - "console.log('Hello World!')", | |
| 49 | - ); | |
| 50 | -} | |
| 51 | - | |
| 52 | -function setupContinueGlobalDir() { | |
| 53 | - if (fs.existsSync(continueGlobalDir)) { | |
| 54 | - fs.rmSync(continueGlobalDir, { recursive: true }); | |
| 55 | - } | |
| 56 | - fs.mkdirSync(continueGlobalDir, { | |
| 57 | - recursive: true, | |
| 58 | - }); | |
| 59 | - fs.writeFileSync( | |
| 60 | - path.join(continueGlobalDir, "config.json"), | |
| 61 | - JSON.stringify({ | |
| 62 | - ...defaultConfig, | |
| 63 | - models: [ | |
| 64 | - { | |
| 65 | - title: "Test Model", | |
| 66 | - provider: "openai", | |
| 67 | - model: "gpt-3.5-turbo", | |
| 68 | - apiKey: "API_KEY", | |
| 69 | - }, | |
| 70 | - ], | |
| 71 | - }), | |
| 72 | - ); | |
| 73 | -} | |
| 74 | - | |
| 75 | -function cleanupTestWorkspace() { | |
| 76 | - if (fs.existsSync(testWorkspacePath)) { | |
| 77 | - fs.rmSync(testWorkspacePath, { recursive: true }); | |
| 78 | - } | |
| 79 | -} | |
| 80 | - | |
| 81 | -function cleanupContinueGlobalDir() { | |
| 82 | - if (fs.existsSync(continueGlobalDir)) { | |
| 83 | - fs.rmSync(continueGlobalDir, { recursive: true }); | |
| 84 | - } | |
| 85 | -} | |
| 86 | - | |
| 87 | -async function main() { | |
| 88 | - try { | |
| 89 | - // The folder containing the Extension Manifest package.json | |
| 90 | - // Passed to `--extensionDevelopmentPath` | |
| 91 | - | |
| 92 | - // Assumes this file is in out/runTestOnVSCodeHost.js | |
| 93 | - const extensionDevelopmentPath = path.resolve(__dirname, "../"); | |
| 94 | - console.log("extensionDevelopmentPath", extensionDevelopmentPath); | |
| 95 | - | |
| 96 | - // The path to test runner | |
| 97 | - // Passed to --extensionTestsPath | |
| 98 | - const extensionTestsPath = path.resolve( | |
| 99 | - extensionDevelopmentPath, | |
| 100 | - "out/mochaRunner", | |
| 101 | - ); | |
| 102 | - | |
| 103 | - const extensionTestsEnv = { | |
| 104 | - NODE_ENV: "test", | |
| 105 | - CONTINUE_GLOBAL_DIR: continueGlobalDir, | |
| 106 | - }; | |
| 107 | - | |
| 108 | - setupTestWorkspace(); | |
| 109 | - setupContinueGlobalDir(); | |
| 110 | - | |
| 111 | - // Download VS Code, unzip it and run the integration test | |
| 112 | - await runTests({ | |
| 113 | - extensionDevelopmentPath, | |
| 114 | - extensionTestsPath, | |
| 115 | - extensionTestsEnv, | |
| 116 | - launchArgs: [testWorkspacePath], | |
| 117 | - }); | |
| 118 | - } catch (err) { | |
| 119 | - console.error("Failed to run tests", err); | |
| 120 | - process.exit(1); | |
| 121 | - } finally { | |
| 122 | - cleanupTestWorkspace(); | |
| 123 | - cleanupContinueGlobalDir(); | |
| 124 | - } | |
| 125 | -} | |
| 126 | - | |
| 127 | -main(); |
deleted extensions/vscode/src/test/test-suites/ideUtils.test.ts +0 −89
| @@ -1,89 +0,0 @@ | ||
| 1 | -import assert from "node:assert"; | |
| 2 | -import path from "node:path"; | |
| 3 | - | |
| 4 | -import { describe, test } from "mocha"; | |
| 5 | -import * as vscode from "vscode"; | |
| 6 | - | |
| 7 | -import { VsCodeIdeUtils } from "../../util/ideUtils"; | |
| 8 | -import { testWorkspacePath } from "../runner/runTestOnVSCodeHost"; | |
| 9 | - | |
| 10 | -const util = require("node:util"); | |
| 11 | -const asyncExec = util.promisify(require("node:child_process").exec); | |
| 12 | - | |
| 13 | -/* | |
| 14 | - TODO check uri => path assumptions, will only work in some environments. | |
| 15 | -*/ | |
| 16 | -describe("IDE Utils", () => { | |
| 17 | - const utils = new VsCodeIdeUtils(); | |
| 18 | - const testPyPath = path.join(testWorkspacePath, "test.py"); | |
| 19 | - const testJsPath = path.join(testWorkspacePath, "test-folder", "test.js"); | |
| 20 | - | |
| 21 | - test("getWorkspaceDirectories", async () => { | |
| 22 | - const [dir] = utils.getWorkspaceDirectories(); | |
| 23 | - assert(dir.toString().endsWith("test-workspace")); | |
| 24 | - }); | |
| 25 | - | |
| 26 | - test("fileExists", async () => { | |
| 27 | - const exists2 = await utils.fileExists( | |
| 28 | - vscode.Uri.file(path.join(testWorkspacePath, "test.py")), | |
| 29 | - ); | |
| 30 | - assert(exists2); | |
| 31 | - }); | |
| 32 | - | |
| 33 | - test("getOpenFiles", async () => { | |
| 34 | - let openFiles = utils.getOpenFiles(); | |
| 35 | - assert(openFiles.length === 0); | |
| 36 | - // await utils.openFile(testPyPath); | |
| 37 | - let document = await vscode.workspace.openTextDocument(testPyPath); | |
| 38 | - await vscode.window.showTextDocument(document, { | |
| 39 | - preview: false, | |
| 40 | - }); | |
| 41 | - openFiles = utils.getOpenFiles(); | |
| 42 | - assert(openFiles.length === 1); | |
| 43 | - assert(openFiles[0].fsPath === testPyPath); | |
| 44 | - | |
| 45 | - document = await vscode.workspace.openTextDocument(testJsPath); | |
| 46 | - await vscode.window.showTextDocument(document, { | |
| 47 | - preview: false, | |
| 48 | - }); | |
| 49 | - openFiles = utils.getOpenFiles(); | |
| 50 | - assert(openFiles.length === 2); | |
| 51 | - assert(openFiles.find((f) => f.fsPath === testPyPath)); | |
| 52 | - assert(openFiles.find((f) => f.fsPath === testJsPath)); | |
| 53 | - }); | |
| 54 | - | |
| 55 | - test("getUniqueId", async () => { | |
| 56 | - const uniqueId = utils.getUniqueId(); | |
| 57 | - assert(uniqueId.length === 64); | |
| 58 | - const regex = /^[a-z0-9]+$/; | |
| 59 | - assert(regex.test(uniqueId)); | |
| 60 | - }); | |
| 61 | - | |
| 62 | - test.skip("getTerminalContents", async () => { | |
| 63 | - await new Promise((resolve) => setTimeout(resolve, 1000)); | |
| 64 | - const terminal = vscode.window.createTerminal(); | |
| 65 | - await new Promise((resolve) => setTimeout(resolve, 1000)); | |
| 66 | - terminal.show(); | |
| 67 | - await new Promise((resolve) => setTimeout(resolve, 1000)); | |
| 68 | - terminal.sendText("echo abcdefg", true); | |
| 69 | - const contents = await utils.getTerminalContents(1); | |
| 70 | - console.log("TERMINAL CONTENTS: ", contents); | |
| 71 | - assert(contents.includes("abcdefg")); | |
| 72 | - terminal.dispose(); | |
| 73 | - }); | |
| 74 | - | |
| 75 | - test("noDiff", async () => { | |
| 76 | - const noDiff = await utils.getDiff(false); | |
| 77 | - assert(noDiff.length === 0); | |
| 78 | - }); | |
| 79 | - | |
| 80 | - test.skip("getBranch", async () => { | |
| 81 | - const uri = vscode.Uri.file(testWorkspacePath); | |
| 82 | - const branch = await utils.getBranch(uri); | |
| 83 | - assert(typeof branch === "string"); | |
| 84 | - const { stdout } = await asyncExec("git rev-parse --abbrev-ref HEAD", { | |
| 85 | - cwd: __dirname, | |
| 86 | - }); | |
| 87 | - assert(branch === stdout?.trim()); | |
| 88 | - }); | |
| 89 | -}); |