Elffuss BraidHub

kikocis/continue public

rip out mocha
Changeset68c98749bfc3f8ff7a98d189cb83cdb01afcd99174bf45659f45891ad3b097cb
AuthorDallin Romney <dallinromney@gmail.com> · 2025-06-17 13:48 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-06-17 13:48 -07:00
Parentse4890227bbc5

Browse the files at this changeset

10 files changed

modified .vscode/launch.json +0 −26
@@ -73,32 +73,6 @@
7373 "sourceMaps": true
7474 // "preLaunchTask": "gui:dev"
7575 },
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- },
10276 {
10377 "name": "[Core] Jest Test Debugger, Current Open File",
10478 "type": "node",
modified .vscode/tasks.json +0 −33
@@ -106,39 +106,6 @@
106106 "cwd": "${workspaceFolder}/extensions/vscode"
107107 }
108108 },
109- //
110- // Compile and bundle tests
111- {
112- "label": "vscode-extension:tests:build",
113- "dependsOn": [
114- // Build the extension
115- "vscode-extension:build",
116- // To detect compile errors - this type checks both the extension and the tests
117- "tsc:watch",
118- "vscode-extension:tests:esbuild"
119- ]
120- },
121- {
122- "label": "vscode-extension:tests:esbuild",
123- "type": "npm",
124- "script": "build-test",
125- "path": "extensions/vscode",
126- "problemMatcher": [
127- {
128- "pattern": [
129- {
130- "regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
131- "file": 1,
132- "line": 2,
133- "column": 3,
134- "severity": 4,
135- "message": 5
136- }
137- ]
138- }
139- ]
140- },
141- //
142109 // Install or update all dependencies for all projects in the monrepo
143110 {
144111 "label": "install-all-dependencies",
modified extensions/vscode/.vscodeignore +0 −1
@@ -18,7 +18,6 @@
1818
1919 manual-testing-sandbox
2020 esbuild.js
21-esbuild.test.mjs
2221 importMetaUrl.js
2322 scripts
2423 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 +1 −8
@@ -622,10 +622,8 @@
622622 "rebuild": "electron-rebuild -v 19.1.8 node-pty",
623623 "lint": "eslint src --ext ts",
624624 "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",
627626 "vitest": "vitest run",
628- "quick-test": "npm run build-test && node ./out/runTestOnVSCodeHost.js",
629627 "write-build-timestamp": "node scripts/write-build-timestamp.js",
630628 "prepackage": "node scripts/prepackage.js",
631629 "package": "node scripts/package.js",
@@ -661,8 +659,6 @@
661659 "@types/cors": "^2.8.17",
662660 "@types/express": "^4.17.21",
663661 "@types/follow-redirects": "^1.14.4",
664- "@types/glob": "^8.0.0",
665- "@types/mocha": "^10.0.6",
666662 "@types/node": "16.x",
667663 "@types/react-dom": "^18.2.4",
668664 "@types/request": "^2.48.8",
@@ -675,9 +671,7 @@
675671 "esbuild": "0.17.19",
676672 "esbuild-visualizer": "^0.6.0",
677673 "eslint": "^8.28.0",
678- "glob": "^8.0.3",
679674 "json-schema-to-typescript": "^12.0.0",
680- "mocha": "^10.4.0",
681675 "ovsx": "^0.8.3",
682676 "rimraf": "^5.0.5",
683677 "typescript": "^5.6.3",
@@ -692,7 +686,6 @@
692686 "@types/node-fetch": "^2.6.11",
693687 "@types/uuid": "^9.0.8",
694688 "@vscode/ripgrep": "^1.15.9",
695- "@vscode/test-electron": "^2.3.9",
696689 "axios": "^1.2.5",
697690 "core": "file:../../core",
698691 "cors": "^2.8.5",
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-});
modified extensions/vscode/tsconfig.json +1 −3
@@ -9,11 +9,9 @@
99 "strict": true,
1010 "esModuleInterop": true,
1111 "resolveJsonModule": true,
12- "skipLibCheck": true,
13- "types": ["mocha"] // This solves conflict between jest and mocha: https://github.com/cypress-io/cypress/issues/7435#issuecomment-631695007
12+ "skipLibCheck": true
1413 },
1514 "include": ["src/**/*", "../../core/**/*.ts", "../../core/**/*.d.ts"],
16- // core/test uses @types/jest, which conflicts with @types/mocha
1715 "exclude": [
1816 "../../core/dist/**/*",
1917 "../../core/**/*.test.ts",