From 8cea846a7139058c42e8544acf636f6a8296855a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 15:28:36 +0100 Subject: [PATCH 01/11] Replace all references to test harness with test runner --- .vscode/tasks.json | 4 +-- cursorless.nvim/lua/cursorless/init.lua | 4 +-- packages/app-neovim/scripts/populate-dist.sh | 16 ++++----- packages/app-vscode/src/createVscodeIde.ts | 2 +- packages/app-vscode/src/vscodeApi.ts | 4 +-- .../neovim-test-infrastructure.md | 22 ++++++------ .../src/docs/contributing/tests.md | 6 ++-- packages/test-runner/README.md | 4 +-- packages/test-runner/src/runAllTests.ts | 36 +++++++++---------- .../src/runners/extensionTestsNeovim.ts | 2 +- .../src/updatePackageJson.ts | 10 ++---- 11 files changed, 53 insertions(+), 57 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index faeccc0af8d..852c18cdb87 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -14,7 +14,7 @@ }, { "label": "Build extension and tests", - "dependsOn": ["Build extension", "Build test harness"], + "dependsOn": ["Build extension", "Build test runner"], "group": "build" }, { @@ -29,7 +29,7 @@ // Helper tasks { - "label": "Build test harness", + "label": "Build test runner", "type": "npm", "script": "build", "path": "packages/test-runner", diff --git a/cursorless.nvim/lua/cursorless/init.lua b/cursorless.nvim/lua/cursorless/init.lua index 6226399ed9b..a7fc1edd56b 100644 --- a/cursorless.nvim/lua/cursorless/init.lua +++ b/cursorless.nvim/lua/cursorless/init.lua @@ -39,7 +39,7 @@ local function register_functions() vim.fn["remote#host#RegisterPlugin"]("node", path .. "/node/test-runner/", { { type = "function", - name = "TestHarnessRun", + name = "TestRunnerRun", sync = false, opts = vim.empty_dict(), }, @@ -55,7 +55,7 @@ local function load_extensions() if os.getenv("CURSORLESS_MODE") == "test" then -- make sure cursorless is loaded before starting the tests vim.uv.sleep(1000) - vim.fn.TestHarnessRun() + vim.fn.TestRunnerRun() else vim.fn.CommandServerLoadExtension() end diff --git a/packages/app-neovim/scripts/populate-dist.sh b/packages/app-neovim/scripts/populate-dist.sh index cfa534483c6..29c9339dcfb 100755 --- a/packages/app-neovim/scripts/populate-dist.sh +++ b/packages/app-neovim/scripts/populate-dist.sh @@ -8,7 +8,7 @@ fi echo "CURSORLESS_REPO_ROOT: $CURSORLESS_REPO_ROOT" cursorless_nvim_dir="$CURSORLESS_REPO_ROOT/cursorless.nvim" cursorless_neovim_node_in_dir="$CURSORLESS_REPO_ROOT/packages/app-neovim" -test_harness_node_in_dir="$CURSORLESS_REPO_ROOT/packages/test-runner" +test_runner_node_in_dir="$CURSORLESS_REPO_ROOT/packages/test-runner" if [[ "${CI:-x}" == "true" ]]; then # If running in CI, only copy the necessary files for testing and release @@ -25,10 +25,10 @@ if [[ "${CI:-x}" == "true" ]]; then cp "$cursorless_neovim_node_in_dir/out/index.cjs" "$cursorless_neovim_node_out_dir/out" # Populate test-runner - test_harness_node_out_dir="$cursorless_nvim_dist_dir/node/test-runner" - mkdir -p "$test_harness_node_out_dir/out" - cp "$test_harness_node_in_dir/package.json" "$test_harness_node_out_dir" - cp "$test_harness_node_in_dir/out/extensionTestsNeovim.cjs" "$test_harness_node_out_dir/out" + test_runner_node_out_dir="$cursorless_nvim_dist_dir/node/test-runner" + mkdir -p "$test_runner_node_out_dir/out" + cp "$test_runner_node_in_dir/package.json" "$test_runner_node_out_dir" + cp "$test_runner_node_in_dir/out/extensionTestsNeovim.cjs" "$test_runner_node_out_dir/out" else # Symlink so we inherit the .map files as well, but only if uname doesn't # start with "MINGW" (Windows Git Bash) @@ -43,8 +43,8 @@ else rm -rf "$cursorless_neovim_node_out_dir" ln -s "$cursorless_neovim_node_in_dir" "$cursorless_neovim_node_out_dir" - test_harness_node_out_dir="$cursorless_nvim_dir/node/test-runner" - rm -rf "$test_harness_node_out_dir" - ln -s "$test_harness_node_in_dir" "$test_harness_node_out_dir" + test_runner_node_out_dir="$cursorless_nvim_dir/node/test-runner" + rm -rf "$test_runner_node_out_dir" + ln -s "$test_runner_node_in_dir" "$test_runner_node_out_dir" fi fi diff --git a/packages/app-vscode/src/createVscodeIde.ts b/packages/app-vscode/src/createVscodeIde.ts index 5870f532351..4bac4e9718f 100644 --- a/packages/app-vscode/src/createVscodeIde.ts +++ b/packages/app-vscode/src/createVscodeIde.ts @@ -23,7 +23,7 @@ export async function createVscodeIde(context: ExtensionContext) { await hats.init(); - // FIXME: Inject this from test harness. Would need to arrange to delay + // FIXME: Inject this from test runner. Would need to arrange to delay // extension initialization, probably by returning a function from extension // init that has parameters consisting of test configuration, and have that // function do the actual initialization. diff --git a/packages/app-vscode/src/vscodeApi.ts b/packages/app-vscode/src/vscodeApi.ts index 17163dfa77d..70ddc1abed2 100644 --- a/packages/app-vscode/src/vscodeApi.ts +++ b/packages/app-vscode/src/vscodeApi.ts @@ -3,9 +3,9 @@ import { commands, env, window, workspace } from "vscode"; /** * A very thin wrapper around the VSCode API that allows us to mock it for - * testing. This is necessary because the test harness gets bundled separately + * testing. This is necessary because the test runner gets bundled separately * from the extension code, so if we just import the VSCode API directly from - * the extension code, and from the test harness, we'll end up with two copies + * the extension code, and from the test runner, we'll end up with two copies * of the VSCode API, so the mocks won't work. */ export const vscodeApi: VscodeApi = { diff --git a/packages/app-web-docs/src/docs/contributing/architecture/neovim-test-infrastructure.md b/packages/app-web-docs/src/docs/contributing/architecture/neovim-test-infrastructure.md index 33f0f7a1073..777844a161c 100644 --- a/packages/app-web-docs/src/docs/contributing/architecture/neovim-test-infrastructure.md +++ b/packages/app-web-docs/src/docs/contributing/architecture/neovim-test-infrastructure.md @@ -11,7 +11,7 @@ launch.json -> .vscode/tasks.json -> nvim -u init.lua init.lua -> CursorlessLoadExtension() - -> TestHarnessRun() -> run() -> runAllTests() -> Mocha -> packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts + -> TestRunnerRun() -> run() -> runAllTests() -> Mocha -> packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts ``` And here is the call path when running Neovim tests on CI: @@ -26,7 +26,7 @@ launchNeovimAndRunTests.ts packages/test-runner/src/config/init.lua -> CursorlessLoadExtension() - -> TestHarnessRun() -> run() -> runAllTests() -> Mocha + packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts + -> TestRunnerRun() -> run() -> runAllTests() -> Mocha + packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts ``` ### Running Neovim tests locally @@ -56,7 +56,7 @@ This effectively runs a series of dependency tasks from `.vscode/tasks.json`: "Neovim: ESBuild", "Neovim: Populate dist", "TSBuild", - "Build test harness", + "Build test runner", "Neovim: Show logs" ], "group": "build" @@ -118,7 +118,7 @@ local function setup(user_config) load_extensions() ``` -First, it calls `register_functions()` to expose the node functions `CursorlessLoadExtension()` and `TestHarnessRun()` into the vim namespace. A side effect is that the `nvim` process loads the `node` process: +First, it calls `register_functions()` to expose the node functions `CursorlessLoadExtension()` and `TestRunnerRun()` into the vim namespace. A side effect is that the `nvim` process loads the `node` process: ```lua local function register_functions() @@ -138,14 +138,14 @@ local function register_functions() vim.fn["remote#host#RegisterPlugin"]("node", path .. "/node/test-runner/", { { type = "function", - name = "TestHarnessRun", + name = "TestRunnerRun", sync = false, opts = vim.empty_dict(), }, }) ``` -Then, it calls `load_extensions()`. This calls the vim functions in order to load the Cursorless neovim plugin (`CursorlessLoadExtension()`) and start the tests (`TestHarnessRun()`) which ends up calling the previously registered node functions. +Then, it calls `load_extensions()`. This calls the vim functions in order to load the Cursorless neovim plugin (`CursorlessLoadExtension()`) and start the tests (`TestRunnerRun()`) which ends up calling the previously registered node functions. ```lua local function load_extensions() @@ -154,20 +154,20 @@ local function load_extensions() if os.getenv("CURSORLESS_MODE") == "test" then -- make sure cursorless is loaded before starting the tests vim.uv.sleep(1000) - vim.fn.TestHarnessRun() + vim.fn.TestRunnerRun() ``` However, because `nvim` was started with `"NVIM_NODE_HOST_DEBUG": "1"`, when `node` is spawned, `node` will hang and wait for a debugger to attach (`--inspect-brk`). Consequently, `nvim` won't finish loading yet (i.e. it won't finish loading `init.lua`). This is handy because it allows VSCode to finish all the tasks required for building the Cursorless neovim package (`app-neovim`, exposed to Neovim under `node/cursorless-neovim`) and the test runner package (`test-runner`, exposed under `node/test-runner`), which will finally trigger VSCode to attach to the `node` process. -When VSCode attaches to the `node` process, `CursorlessLoadExtension()` is called to load the Cursorless neovim plugin and `TestHarnessRun()` is called to start the tests. +When VSCode attaches to the `node` process, `CursorlessLoadExtension()` is called to load the Cursorless neovim plugin and `TestRunnerRun()` is called to start the tests. -This ends up calling `TestHarnessRun()` from `packages/test-runner/src/index.ts` which calls `run()`: +This ends up calling `TestRunnerRun()` from `packages/test-runner/src/index.ts` which calls `run()`: ```ts export default function entry(plugin: NvimPlugin) { - plugin.registerFunction("TestHarnessRun", () => run(plugin), { + plugin.registerFunction("TestRunnerRun", () => run(plugin), { sync: false, }); } @@ -267,7 +267,7 @@ vim.opt.runtimepath:append(repo_root .. "/dist/cursorless.nvim") require("cursorless").setup() ``` -This ends up calling `setup()` from `dist/cursorless.nvim/lua/cursorless/init.lua`, which ends up triggering `TestHarnessRun()` and finally the recorded tests from `recorded.neovim.test.ts` using the Mocha API. +This ends up calling `setup()` from `dist/cursorless.nvim/lua/cursorless/init.lua`, which ends up triggering `TestRunnerRun()` and finally the recorded tests from `recorded.neovim.test.ts` using the Mocha API. NOTE: Because `NVIM_NODE_HOST_DEBUG` is not set on CI, `nvim` loads entirely right away and tests are executed. diff --git a/packages/app-web-docs/src/docs/contributing/tests.md b/packages/app-web-docs/src/docs/contributing/tests.md index d695dbbf52d..d9b48f3a2f0 100644 --- a/packages/app-web-docs/src/docs/contributing/tests.md +++ b/packages/app-web-docs/src/docs/contributing/tests.md @@ -22,6 +22,6 @@ You can get an overview of the various test contexts that exist locally by looki - `pnpm test` runs the default `test` script for each workspace package. In practice, this is the fast unit-oriented test pass. - `pnpm test:update` runs the test suite in fixture-update mode across the workspace. - `pnpm test:update:subset` runs fixture updates only for the tests selected in `packages/test-runner/testSubsetGrep.properties`. -- `pnpm -F @cursorless/test-runner test:vscode` runs the VSCode test harness. -- `pnpm -F @cursorless/test-runner test:neovim` runs the Neovim test harness. -- `pnpm -F @cursorless/test-runner test:talonJs` runs the Talon-JS test harness. +- `pnpm -F @cursorless/test-runner test:vscode` runs the VSCode test runner. +- `pnpm -F @cursorless/test-runner test:neovim` runs the Neovim test runner. +- `pnpm -F @cursorless/test-runner test:talonJs` runs the Talon-JS test runner. diff --git a/packages/test-runner/README.md b/packages/test-runner/README.md index 5ed7beb20fb..4c41a3ca2d5 100644 --- a/packages/test-runner/README.md +++ b/packages/test-runner/README.md @@ -1,7 +1,7 @@ -# Test harness +# Test runner This package contains the machinery used to test Cursorless, both in CI and locally, across various contexts (eg VSCode, Talon, Neovim, unit tests). Note that it does not actually contain any tests itself; those are either embedded in `.test.ts` files either next to the code they're testing or in standalone `*-e2e` packages. This package bundles tests into `.mjs` files and includes scripts used to run tests. -Note that we currently have a hack where the `package.json` here appears as if it is only used for Neovim. That is because none of our other test runners require a `package.json`, so they are happy to ignore fields such as `main` that are required for Neovim to be able to import the test harness. See [#2564](https://github.com/cursorless-dev/cursorless/issues/2564) to track progress on a more elegant solution. +Note that we currently have a hack where the `package.json` here appears as if it is only used for Neovim. That is because none of our other test runners require a `package.json`, so they are happy to ignore fields such as `main` that are required for Neovim to be able to import the test runner. See [#2564](https://github.com/cursorless-dev/cursorless/issues/2564) to track progress on a more elegant solution. diff --git a/packages/test-runner/src/runAllTests.ts b/packages/test-runner/src/runAllTests.ts index 4225119ee5b..02590e94d86 100644 --- a/packages/test-runner/src/runAllTests.ts +++ b/packages/test-runner/src/runAllTests.ts @@ -32,28 +32,28 @@ export enum TestType { export function runAllTests(type: TestType): Promise { parseArgumentsAndUpdateEnv(); - return runTestsInDir( - path.join(getCursorlessRepoRoot(), "packages"), - (files) => - files.filter((f) => { - if (f.endsWith("neovim.test.cjs")) { - return type === TestType.neovim; - } + const testRoot = path.join(getCursorlessRepoRoot(), "packages"); - if (f.endsWith("vscode.test.cjs")) { - return type === TestType.vscode; - } + return runTestsInDir(testRoot, (files) => + files.filter((f) => { + if (f.endsWith("neovim.test.cjs")) { + return type === TestType.neovim; + } - if (f.endsWith("talon.test.cjs")) { - return type === TestType.talon; - } + if (f.endsWith("vscode.test.cjs")) { + return type === TestType.vscode; + } - if (f.endsWith("talonjs.test.cjs")) { - return type === TestType.talonJs; - } + if (f.endsWith("talon.test.cjs")) { + return type === TestType.talon; + } + + if (f.endsWith("talonjs.test.cjs")) { + return type === TestType.talonJs; + } - return type === TestType.unit; - }), + return type === TestType.unit; + }), ); } diff --git a/packages/test-runner/src/runners/extensionTestsNeovim.ts b/packages/test-runner/src/runners/extensionTestsNeovim.ts index 58c95a56985..d8632163974 100644 --- a/packages/test-runner/src/runners/extensionTestsNeovim.ts +++ b/packages/test-runner/src/runners/extensionTestsNeovim.ts @@ -37,7 +37,7 @@ export async function run(plugin: NvimPlugin): Promise { * Note that these function need to start with a capital letter to be callable from Neovim. */ export default function entry(plugin: NvimPlugin) { - plugin.registerFunction("TestHarnessRun", () => run(plugin), { + plugin.registerFunction("TestRunnerRun", () => run(plugin), { sync: false, }); } diff --git a/packages/tool-meta-updater/src/updatePackageJson.ts b/packages/tool-meta-updater/src/updatePackageJson.ts index 1be2f4c6f99..e55be4d1201 100644 --- a/packages/tool-meta-updater/src/updatePackageJson.ts +++ b/packages/tool-meta-updater/src/updatePackageJson.ts @@ -33,7 +33,7 @@ export async function updatePackageJson( const isCursorlessVscode = input.name === "@cursorless/app-vscode"; const isCursorlessNeovim = input.name === "@cursorless/app-neovim"; const isCursorlessOrgDocs = input.name === "@cursorless/app-web-docs"; - const isCursorlessTestHarness = input.name === "@cursorless/test-runner"; + const isCursorlessTestRunner = input.name === "@cursorless/test-runner"; if (input.description == null || input.description === "") { throw new Error(`No description found in ${packageDir}/package.json`); @@ -57,13 +57,9 @@ export async function updatePackageJson( delete input.types; delete input.exports; // Extensions need a main field, but other non-lib packages shouldn't have - // one. The test harness is a special case since it's technically not a + // one. The test runner is a special case since it's technically not a // library but still requires main for the neovim tests. - if ( - !isCursorlessVscode && - !isCursorlessNeovim && - !isCursorlessTestHarness - ) { + if (!isCursorlessVscode && !isCursorlessNeovim && !isCursorlessTestRunner) { delete input.main; } } From 77832eeb7040a846209f1fcb1ce70525554922d6 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 16:50:08 +0100 Subject: [PATCH 02/11] Run unit test directly from typescript --- packages/lib-common/scripts/c-tsx.js | 61 ++----------------- .../lib-engine/src/testUtil/TestTreeSitter.ts | 8 +-- packages/test-runner/src/runAllTests.ts | 59 +++++++++--------- packages/test-runner/src/testSubset.ts | 13 ++-- 4 files changed, 45 insertions(+), 96 deletions(-) diff --git a/packages/lib-common/scripts/c-tsx.js b/packages/lib-common/scripts/c-tsx.js index 93783e56b13..bfe7f4615be 100755 --- a/packages/lib-common/scripts/c-tsx.js +++ b/packages/lib-common/scripts/c-tsx.js @@ -1,15 +1,12 @@ #!/usr/bin/env node /* global process, console */ -// This script runs a TypeScript file using Node.js by first bundling it with -// esbuild. +// This script runs a TypeScript file using tsx after setting repo-specific +// environment variables. import { spawn } from "cross-spawn"; -import { build } from "esbuild"; -import { existsSync, mkdirSync, rmSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { dirname, join } from "node:path"; -import { randomBytes } from "node:crypto"; /** * Run a command with arguments and return a child process @@ -27,33 +24,6 @@ function runCommand(command, args, extraEnv = {}) { }); } -/** - * Create a temporary directory and return its path - * @param {string} baseDir - */ -function createTempDirectory(baseDir) { - const tempDir = join( - baseDir, - "out", - "c-tsx-tmp", - randomBytes(16).toString("hex"), - ); - - mkdirSync(tempDir, { recursive: true }); - - return tempDir; -} - -/** - * Clean up the temporary directory - * @param {import("fs").PathLike} tempDir - */ -function cleanupTempDirectory(tempDir) { - if (existsSync(tempDir)) { - rmSync(tempDir, { recursive: true }); - } -} - // Main function to execute the script async function main() { const args = process.argv.slice(2); @@ -67,35 +37,12 @@ async function main() { const [fileToRun, ...childArgs] = args; - // Note that the temporary directory must be in the workspace root, otherwise - // VSCode will ignore the source maps, and breakpoints will not work. - const tempDir = createTempDirectory(process.cwd()); - const outFile = join(tempDir, "out.cjs"); - - // Set up cleanup for when the script exits - process.on("exit", () => cleanupTempDirectory(tempDir)); - process.on("SIGINT", () => cleanupTempDirectory(tempDir)); - process.on("SIGTERM", () => cleanupTempDirectory(tempDir)); - - // Run esbuild to bundle the TypeScript file - await build({ - entryPoints: [fileToRun], - sourcemap: true, - conditions: ["cursorless:bundler"], - logLevel: "warning", - platform: "node", - bundle: true, - format: "cjs", - outfile: outFile, - external: ["./reporters/parallel-buffered", "./worker.js"], - }); - const scriptDirectory = dirname(fileURLToPath(import.meta.url)); const repoRoot = join(scriptDirectory, "..", "..", ".."); const nodeProcess = runCommand( - process.execPath, - ["--enable-source-maps", outFile, ...childArgs], + "tsx", + ["--enable-source-maps", fileToRun, ...childArgs], { ["CURSORLESS_REPO_ROOT"]: repoRoot, }, diff --git a/packages/lib-engine/src/testUtil/TestTreeSitter.ts b/packages/lib-engine/src/testUtil/TestTreeSitter.ts index 3aacb04b0de..6d3058def88 100644 --- a/packages/lib-engine/src/testUtil/TestTreeSitter.ts +++ b/packages/lib-engine/src/testUtil/TestTreeSitter.ts @@ -1,6 +1,7 @@ import type { TextDocument, TreeSitter } from "@cursorless/lib-common"; import { createRequire } from "node:module"; import * as path from "node:path"; +import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; import type { Tree, Language as TreeSitterLanguage, @@ -83,11 +84,10 @@ export class TestTreeSitter implements TreeSitter { } function getWasmFilePath(parserName: string) { - const fileName = `${parserName}.wasm`; return path.join( - __dirname, - "../../../../node_modules/@cursorless/tree-sitter-wasms/out", - fileName, + getCursorlessRepoRoot(), + "packages/test-runner/node_modules/@cursorless/tree-sitter-wasms/out", + `${parserName}.wasm`, ); } diff --git a/packages/test-runner/src/runAllTests.ts b/packages/test-runner/src/runAllTests.ts index 02590e94d86..3f70b40389c 100644 --- a/packages/test-runner/src/runAllTests.ts +++ b/packages/test-runner/src/runAllTests.ts @@ -4,7 +4,6 @@ import Mocha from "mocha"; import * as path from "node:path"; import { logFailedTests, - runTestSubset, shouldLogFailedTests, testSubsetGrepString, } from "./testSubset"; @@ -14,19 +13,19 @@ import { */ export enum TestType { /** Unit tests can be run without VSCode or Talon or Neovim */ - unit, + unit = "test", /** VSCode tests must be run from VSCode context */ - vscode, + vscode = "vscode.test", /** Talon tests require a running Talon instance */ - talon, + talon = "talon.test", - /** Talon everywhere/JS tests can be run without VSCode or Talon */ - talonJs, + /** Talon-JS tests can be run without VSCode or Talon */ + talonJs = "talonjs.test", /** Neovim tests must be run from Neovim context */ - neovim, + neovim = "neovim.test", } export function runAllTests(type: TestType): Promise { @@ -34,41 +33,41 @@ export function runAllTests(type: TestType): Promise { const testRoot = path.join(getCursorlessRepoRoot(), "packages"); - return runTestsInDir(testRoot, (files) => - files.filter((f) => { - if (f.endsWith("neovim.test.cjs")) { - return type === TestType.neovim; - } - - if (f.endsWith("vscode.test.cjs")) { - return type === TestType.vscode; - } - - if (f.endsWith("talon.test.cjs")) { - return type === TestType.talon; - } - - if (f.endsWith("talonjs.test.cjs")) { - return type === TestType.talonJs; - } + let filePattern: string; + let ignore: string[] | undefined; + + if (type === TestType.unit) { + filePattern = "test.ts"; + ignore = [ + TestType.vscode, + TestType.talon, + TestType.talonJs, + TestType.neovim, + ].map((t) => `**/*.${t}.ts`); + } else { + filePattern = `${type}.cjs`; + ignore = undefined; + } - return type === TestType.unit; - }), - ); + return runTestsInDir(testRoot, filePattern, ignore); } async function runTestsInDir( testRoot: string, - filterFiles: (files: string[]) => string[], + filePattern: string, + ignore: string[] | undefined, ): Promise { // Create the mocha test const mocha = new Mocha({ ui: "tdd", color: true, - grep: runTestSubset() ? testSubsetGrepString() : undefined, // Only run a subset of tests + grep: testSubsetGrepString(), // Only run a subset of tests }); - const files = filterFiles(await glob("**/**.test.cjs", { cwd: testRoot })); + const files = await glob(`**/*.${filePattern}`, { + cwd: testRoot, + ignore, + }); if (files.length === 0) { throw new Error( diff --git a/packages/test-runner/src/testSubset.ts b/packages/test-runner/src/testSubset.ts index a7dad16e1e1..a48c53b9753 100644 --- a/packages/test-runner/src/testSubset.ts +++ b/packages/test-runner/src/testSubset.ts @@ -4,12 +4,15 @@ import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; /** * Returns the grep string to pass to Mocha when running a subset of tests. - * @returns the grep string to pass to Mocha: + * @returns the grep string to pass to Mocha when running a subset of tests, + * or `undefined` if we are not running a subset of tests. */ -export function testSubsetGrepString(): string { - const inFile = testSubsetFilePath(); +export function testSubsetGrepString(): string | undefined { + if (!runTestSubset()) { + return undefined; + } return fs - .readFileSync(inFile, "utf-8") + .readFileSync(testSubsetFilePath(), "utf-8") .split(/\r?\n/) .map((line) => line.trim()) .filter((line) => line.length > 0 && !line.startsWith("#")) @@ -48,7 +51,7 @@ export function logFailedTests(testNames: string[]) { * {@link TEST_SUBSET_GREP_STRING}. * @returns `true` if we are using the run test subset launch config */ -export function runTestSubset() { +function runTestSubset() { return process.env.CURSORLESS_RUN_TEST_SUBSET === "true"; } From 8d2d5baa155053eba594c66a45da040b32f31659 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 16:59:35 +0100 Subject: [PATCH 03/11] renamed Talon to Talonjs --- packages/{app-talon => app-talonjs}/package.json | 4 ++-- .../{app-talon => app-talonjs}/scripts/esbuild.sh | 0 packages/{app-talon => app-talonjs}/src/extension.ts | 2 +- .../src/mainDevelopment.ts | 0 .../{app-talon => app-talonjs}/src/mainProduction.ts | 0 .../{app-talon => app-talonjs}/src/types/talon.d.ts | 2 +- packages/{app-talon => app-talonjs}/tsconfig.json | 0 .../contributing/architecture/package-scripts.md | 2 +- .../package.json | 2 +- .../src/README.md | 0 .../src/constructTestHelpers.ts | 0 .../src/extension.ts | 0 .../src/ide/TalonJsCapabilities.ts | 0 .../src/ide/TalonJsClipboard.ts | 0 .../src/ide/TalonJsConfiguration.ts | 0 .../src/ide/TalonJsIDE.ts | 0 .../src/ide/TalonJsKeyValueStore.ts | 0 .../src/ide/TalonJsMessages.ts | 0 .../src/ide/TalonJsTestHats.ts | 0 .../src/ide/flashRanges.ts | 0 .../src/ide/toCharacterRangeOffsets.ts | 0 .../src/index.ts | 0 .../src/polyfill.ts | 0 .../src/registerCommands.ts | 0 .../src/types/talon.ts | 0 .../src/types/types.ts | 0 .../tsconfig.json | 0 packages/test-talon-e2e/package.json | 2 +- packages/test-talon-e2e/src/constructTestHelpers.ts | 2 +- packages/test-talon-e2e/src/endToEndTestSetUp.ts | 2 +- packages/test-talon-e2e/src/quickjsTest.ts | 2 +- packages/test-talon-e2e/src/recorded.talonjs.test.ts | 2 +- packages/test-talon-e2e/src/talonMock.ts | 2 +- packages/test-talon-e2e/src/types/cursorless.ts | 2 +- packages/test-talon-e2e/src/types/talon.ts | 2 +- pnpm-lock.yaml | 12 ++++++------ tsconfig.base.json | 2 +- tsconfig.json | 4 ++-- 38 files changed, 23 insertions(+), 23 deletions(-) rename packages/{app-talon => app-talonjs}/package.json (89%) rename packages/{app-talon => app-talonjs}/scripts/esbuild.sh (100%) mode change 100755 => 100644 rename packages/{app-talon => app-talonjs}/src/extension.ts (72%) rename packages/{app-talon => app-talonjs}/src/mainDevelopment.ts (100%) rename packages/{app-talon => app-talonjs}/src/mainProduction.ts (100%) rename packages/{app-talon => app-talonjs}/src/types/talon.d.ts (85%) rename packages/{app-talon => app-talonjs}/tsconfig.json (100%) rename packages/{lib-talon-core => lib-talonjs-core}/package.json (92%) rename packages/{lib-talon-core => lib-talonjs-core}/src/README.md (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/constructTestHelpers.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/extension.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsCapabilities.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsClipboard.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsConfiguration.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsIDE.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsKeyValueStore.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsMessages.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/TalonJsTestHats.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/flashRanges.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/ide/toCharacterRangeOffsets.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/index.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/polyfill.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/registerCommands.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/types/talon.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/src/types/types.ts (100%) rename packages/{lib-talon-core => lib-talonjs-core}/tsconfig.json (100%) diff --git a/packages/app-talon/package.json b/packages/app-talonjs/package.json similarity index 89% rename from packages/app-talon/package.json rename to packages/app-talonjs/package.json index 2abdd888974..f74047c76bc 100644 --- a/packages/app-talon/package.json +++ b/packages/app-talonjs/package.json @@ -1,5 +1,5 @@ { - "name": "@cursorless/app-talon", + "name": "@cursorless/app-talonjs", "version": "1.0.0", "description": "cursorless in talon js", "license": "MIT", @@ -18,6 +18,6 @@ }, "dependencies": { "@cursorless/lib-common": "workspace:*", - "@cursorless/lib-talon-core": "workspace:*" + "@cursorless/lib-talonjs-core": "workspace:*" } } diff --git a/packages/app-talon/scripts/esbuild.sh b/packages/app-talonjs/scripts/esbuild.sh old mode 100755 new mode 100644 similarity index 100% rename from packages/app-talon/scripts/esbuild.sh rename to packages/app-talonjs/scripts/esbuild.sh diff --git a/packages/app-talon/src/extension.ts b/packages/app-talonjs/src/extension.ts similarity index 72% rename from packages/app-talon/src/extension.ts rename to packages/app-talonjs/src/extension.ts index ecccd83e269..0ff6bc359ee 100644 --- a/packages/app-talon/src/extension.ts +++ b/packages/app-talonjs/src/extension.ts @@ -1,5 +1,5 @@ import type { RunMode } from "@cursorless/lib-common"; -import { activate as activateCore } from "@cursorless/lib-talon-core"; +import { activate as activateCore } from "@cursorless/lib-talonjs-core"; import * as talon from "talon"; export async function activate(runMode: RunMode): Promise { diff --git a/packages/app-talon/src/mainDevelopment.ts b/packages/app-talonjs/src/mainDevelopment.ts similarity index 100% rename from packages/app-talon/src/mainDevelopment.ts rename to packages/app-talonjs/src/mainDevelopment.ts diff --git a/packages/app-talon/src/mainProduction.ts b/packages/app-talonjs/src/mainProduction.ts similarity index 100% rename from packages/app-talon/src/mainProduction.ts rename to packages/app-talonjs/src/mainProduction.ts diff --git a/packages/app-talon/src/types/talon.d.ts b/packages/app-talonjs/src/types/talon.d.ts similarity index 85% rename from packages/app-talon/src/types/talon.d.ts rename to packages/app-talonjs/src/types/talon.d.ts index 2b53448f870..c4427ec646b 100644 --- a/packages/app-talon/src/types/talon.d.ts +++ b/packages/app-talonjs/src/types/talon.d.ts @@ -3,7 +3,7 @@ declare module "talon" { TalonActions, TalonContextConstructor, TalonSettings, - } from "@cursorless/lib-talon-core"; + } from "@cursorless/lib-talonjs-core"; export const actions: TalonActions; export const settings: TalonSettings; diff --git a/packages/app-talon/tsconfig.json b/packages/app-talonjs/tsconfig.json similarity index 100% rename from packages/app-talon/tsconfig.json rename to packages/app-talonjs/tsconfig.json diff --git a/packages/app-web-docs/src/docs/contributing/architecture/package-scripts.md b/packages/app-web-docs/src/docs/contributing/architecture/package-scripts.md index d0d9dc12137..379eb7bdcd8 100644 --- a/packages/app-web-docs/src/docs/contributing/architecture/package-scripts.md +++ b/packages/app-web-docs/src/docs/contributing/architecture/package-scripts.md @@ -63,7 +63,7 @@ Examples include: - `@cursorless/app-neovim` - `@cursorless/app-web` - `@cursorless/app-web-docs` -- `@cursorless/app-talon` +- `@cursorless/app-talonjs` ## Script meanings diff --git a/packages/lib-talon-core/package.json b/packages/lib-talonjs-core/package.json similarity index 92% rename from packages/lib-talon-core/package.json rename to packages/lib-talonjs-core/package.json index 36a5826225d..31ec4d14761 100644 --- a/packages/lib-talon-core/package.json +++ b/packages/lib-talonjs-core/package.json @@ -1,5 +1,5 @@ { - "name": "@cursorless/lib-talon-core", + "name": "@cursorless/lib-talonjs-core", "version": "1.0.0", "description": "cursorless in talon js core packagee", "license": "MIT", diff --git a/packages/lib-talon-core/src/README.md b/packages/lib-talonjs-core/src/README.md similarity index 100% rename from packages/lib-talon-core/src/README.md rename to packages/lib-talonjs-core/src/README.md diff --git a/packages/lib-talon-core/src/constructTestHelpers.ts b/packages/lib-talonjs-core/src/constructTestHelpers.ts similarity index 100% rename from packages/lib-talon-core/src/constructTestHelpers.ts rename to packages/lib-talonjs-core/src/constructTestHelpers.ts diff --git a/packages/lib-talon-core/src/extension.ts b/packages/lib-talonjs-core/src/extension.ts similarity index 100% rename from packages/lib-talon-core/src/extension.ts rename to packages/lib-talonjs-core/src/extension.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsCapabilities.ts b/packages/lib-talonjs-core/src/ide/TalonJsCapabilities.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsCapabilities.ts rename to packages/lib-talonjs-core/src/ide/TalonJsCapabilities.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsClipboard.ts b/packages/lib-talonjs-core/src/ide/TalonJsClipboard.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsClipboard.ts rename to packages/lib-talonjs-core/src/ide/TalonJsClipboard.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsConfiguration.ts b/packages/lib-talonjs-core/src/ide/TalonJsConfiguration.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsConfiguration.ts rename to packages/lib-talonjs-core/src/ide/TalonJsConfiguration.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsIDE.ts b/packages/lib-talonjs-core/src/ide/TalonJsIDE.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsIDE.ts rename to packages/lib-talonjs-core/src/ide/TalonJsIDE.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsKeyValueStore.ts b/packages/lib-talonjs-core/src/ide/TalonJsKeyValueStore.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsKeyValueStore.ts rename to packages/lib-talonjs-core/src/ide/TalonJsKeyValueStore.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsMessages.ts b/packages/lib-talonjs-core/src/ide/TalonJsMessages.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsMessages.ts rename to packages/lib-talonjs-core/src/ide/TalonJsMessages.ts diff --git a/packages/lib-talon-core/src/ide/TalonJsTestHats.ts b/packages/lib-talonjs-core/src/ide/TalonJsTestHats.ts similarity index 100% rename from packages/lib-talon-core/src/ide/TalonJsTestHats.ts rename to packages/lib-talonjs-core/src/ide/TalonJsTestHats.ts diff --git a/packages/lib-talon-core/src/ide/flashRanges.ts b/packages/lib-talonjs-core/src/ide/flashRanges.ts similarity index 100% rename from packages/lib-talon-core/src/ide/flashRanges.ts rename to packages/lib-talonjs-core/src/ide/flashRanges.ts diff --git a/packages/lib-talon-core/src/ide/toCharacterRangeOffsets.ts b/packages/lib-talonjs-core/src/ide/toCharacterRangeOffsets.ts similarity index 100% rename from packages/lib-talon-core/src/ide/toCharacterRangeOffsets.ts rename to packages/lib-talonjs-core/src/ide/toCharacterRangeOffsets.ts diff --git a/packages/lib-talon-core/src/index.ts b/packages/lib-talonjs-core/src/index.ts similarity index 100% rename from packages/lib-talon-core/src/index.ts rename to packages/lib-talonjs-core/src/index.ts diff --git a/packages/lib-talon-core/src/polyfill.ts b/packages/lib-talonjs-core/src/polyfill.ts similarity index 100% rename from packages/lib-talon-core/src/polyfill.ts rename to packages/lib-talonjs-core/src/polyfill.ts diff --git a/packages/lib-talon-core/src/registerCommands.ts b/packages/lib-talonjs-core/src/registerCommands.ts similarity index 100% rename from packages/lib-talon-core/src/registerCommands.ts rename to packages/lib-talonjs-core/src/registerCommands.ts diff --git a/packages/lib-talon-core/src/types/talon.ts b/packages/lib-talonjs-core/src/types/talon.ts similarity index 100% rename from packages/lib-talon-core/src/types/talon.ts rename to packages/lib-talonjs-core/src/types/talon.ts diff --git a/packages/lib-talon-core/src/types/types.ts b/packages/lib-talonjs-core/src/types/types.ts similarity index 100% rename from packages/lib-talon-core/src/types/types.ts rename to packages/lib-talonjs-core/src/types/types.ts diff --git a/packages/lib-talon-core/tsconfig.json b/packages/lib-talonjs-core/tsconfig.json similarity index 100% rename from packages/lib-talon-core/tsconfig.json rename to packages/lib-talonjs-core/tsconfig.json diff --git a/packages/test-talon-e2e/package.json b/packages/test-talon-e2e/package.json index 7bc48373403..d266bb320ab 100644 --- a/packages/test-talon-e2e/package.json +++ b/packages/test-talon-e2e/package.json @@ -13,7 +13,7 @@ "dependencies": { "@cursorless/lib-common": "workspace:*", "@cursorless/lib-node-common": "workspace:*", - "@cursorless/lib-talon-core": "workspace:*", + "@cursorless/lib-talonjs-core": "workspace:*", "@cursorless/lib-test-case-recorder": "workspace:*" }, "devDependencies": { diff --git a/packages/test-talon-e2e/src/constructTestHelpers.ts b/packages/test-talon-e2e/src/constructTestHelpers.ts index fc86ab343f9..5c0a17371da 100644 --- a/packages/test-talon-e2e/src/constructTestHelpers.ts +++ b/packages/test-talon-e2e/src/constructTestHelpers.ts @@ -7,7 +7,7 @@ import type { TestHelpers, TextEditor, } from "@cursorless/lib-common"; -import type { TalonJsTestHelpers } from "@cursorless/lib-talon-core"; +import type { TalonJsTestHelpers } from "@cursorless/lib-talonjs-core"; import { takeSnapshot } from "@cursorless/lib-test-case-recorder"; export function constructTestHelpers( diff --git a/packages/test-talon-e2e/src/endToEndTestSetUp.ts b/packages/test-talon-e2e/src/endToEndTestSetUp.ts index 4258063931e..a9037a53f4d 100644 --- a/packages/test-talon-e2e/src/endToEndTestSetUp.ts +++ b/packages/test-talon-e2e/src/endToEndTestSetUp.ts @@ -1,5 +1,5 @@ import { type IDE, SpyIDE } from "@cursorless/lib-common"; -import type { TalonJsTestHelpers } from "@cursorless/lib-talon-core"; +import type { TalonJsTestHelpers } from "@cursorless/lib-talonjs-core"; import type { Context } from "mocha"; interface EndToEndTestSetupOpts { diff --git a/packages/test-talon-e2e/src/quickjsTest.ts b/packages/test-talon-e2e/src/quickjsTest.ts index 98e2d6c3d74..8d18236a155 100644 --- a/packages/test-talon-e2e/src/quickjsTest.ts +++ b/packages/test-talon-e2e/src/quickjsTest.ts @@ -3,7 +3,7 @@ import { type ActionDescriptor, type CommandLatest, } from "@cursorless/lib-common"; -import { activate } from "@cursorless/lib-talon-core"; +import { activate } from "@cursorless/lib-talonjs-core"; import * as std from "std"; import { talonMock } from "./talonMock"; diff --git a/packages/test-talon-e2e/src/recorded.talonjs.test.ts b/packages/test-talon-e2e/src/recorded.talonjs.test.ts index 857b9568d39..4d1ce9701dd 100644 --- a/packages/test-talon-e2e/src/recorded.talonjs.test.ts +++ b/packages/test-talon-e2e/src/recorded.talonjs.test.ts @@ -7,7 +7,7 @@ import { activate, type EditorState, type TalonJsIDE, -} from "@cursorless/lib-talon-core"; +} from "@cursorless/lib-talonjs-core"; import { getRecordedTestPaths, loadFixture, diff --git a/packages/test-talon-e2e/src/talonMock.ts b/packages/test-talon-e2e/src/talonMock.ts index 6d4f60ca979..700f978e92d 100644 --- a/packages/test-talon-e2e/src/talonMock.ts +++ b/packages/test-talon-e2e/src/talonMock.ts @@ -7,7 +7,7 @@ import type { TalonContext, TalonContextActions, TalonSettings, -} from "@cursorless/lib-talon-core"; +} from "@cursorless/lib-talonjs-core"; import type { TalonTestHelpers } from "./types/talon"; let _contextActions: TalonContextActions | undefined; diff --git a/packages/test-talon-e2e/src/types/cursorless.ts b/packages/test-talon-e2e/src/types/cursorless.ts index 14a979880de..f50708fdff8 100644 --- a/packages/test-talon-e2e/src/types/cursorless.ts +++ b/packages/test-talon-e2e/src/types/cursorless.ts @@ -1,5 +1,5 @@ import type { RunMode } from "@cursorless/lib-common"; -import type { ActivateReturnValue, Talon } from "@cursorless/lib-talon-core"; +import type { ActivateReturnValue, Talon } from "@cursorless/lib-talonjs-core"; export interface Extension { activate(talon: Talon, runMode: RunMode): Promise; diff --git a/packages/test-talon-e2e/src/types/talon.ts b/packages/test-talon-e2e/src/types/talon.ts index 0ced2475f43..4efe06bd926 100644 --- a/packages/test-talon-e2e/src/types/talon.ts +++ b/packages/test-talon-e2e/src/types/talon.ts @@ -1,7 +1,7 @@ import type { EditorState, TalonContextActions, -} from "@cursorless/lib-talon-core"; +} from "@cursorless/lib-talonjs-core"; export interface TalonTestHelpers { contextActions: TalonContextActions; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54498ae9e26..ecd59f17393 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -124,14 +124,14 @@ importers: specifier: ^3.1.0 version: 3.1.0 - packages/app-talon: + packages/app-talonjs: dependencies: '@cursorless/lib-common': specifier: workspace:* version: link:../lib-common - '@cursorless/lib-talon-core': + '@cursorless/lib-talonjs-core': specifier: workspace:* - version: link:../lib-talon-core + version: link:../lib-talonjs-core packages/app-vscode: dependencies: @@ -616,7 +616,7 @@ importers: specifier: ^11.7.5 version: 11.7.5 - packages/lib-talon-core: + packages/lib-talonjs-core: dependencies: '@cursorless/lib-common': specifier: workspace:* @@ -811,9 +811,9 @@ importers: '@cursorless/lib-node-common': specifier: workspace:* version: link:../lib-node-common - '@cursorless/lib-talon-core': + '@cursorless/lib-talonjs-core': specifier: workspace:* - version: link:../lib-talon-core + version: link:../lib-talonjs-core '@cursorless/lib-test-case-recorder': specifier: workspace:* version: link:../lib-test-case-recorder diff --git a/tsconfig.base.json b/tsconfig.base.json index f8d7e54b8d2..c5963ed8a1d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -19,7 +19,7 @@ "@cursorless/lib-neovim-registry": ["./packages/lib-neovim-registry"], "@cursorless/lib-node-common": ["./packages/lib-node-common"], "@cursorless/lib-sentence-parser": ["./packages/lib-sentence-parser"], - "@cursorless/lib-talon-core": ["./packages/lib-talon-core"], + "@cursorless/lib-talonjs-core": ["./packages/lib-talonjs-core"], "@cursorless/lib-test-case-recorder": [ "./packages/lib-test-case-recorder" ], diff --git a/tsconfig.json b/tsconfig.json index ba377201342..c002ac6c4f8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "path": "./packages/app-neovim" }, { - "path": "./packages/app-talon" + "path": "./packages/app-talonjs" }, { "path": "./packages/app-vscode" @@ -42,7 +42,7 @@ "path": "./packages/lib-sentence-parser" }, { - "path": "./packages/lib-talon-core" + "path": "./packages/lib-talonjs-core" }, { "path": "./packages/lib-test-case-recorder" From 6aef40a86172bfdf74fbf70c65692dcd1feb4dcd Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 17:08:11 +0100 Subject: [PATCH 04/11] Clean up snippet test --- .../fixtures/communitySnippets.fixture.ts | 12 ++----- packages/test-runner/src/runAllTests.ts | 35 ++++++++++++------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/packages/lib-engine/src/test/fixtures/communitySnippets.fixture.ts b/packages/lib-engine/src/test/fixtures/communitySnippets.fixture.ts index 9e00d55945b..68a6912e9a0 100644 --- a/packages/lib-engine/src/test/fixtures/communitySnippets.fixture.ts +++ b/packages/lib-engine/src/test/fixtures/communitySnippets.fixture.ts @@ -17,18 +17,10 @@ const snippetAfterAction: ActionDescriptor = { }, snippetDescription: { type: "list", - // This will be the current active language - fallbackLanguage: "typescript", snippets: [ { type: "custom", - languages: [ - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - ], - body: 'import * as $0 from "$0";', + body: "```$0\n$1\n```", }, ], }, @@ -40,5 +32,5 @@ const snippetAfterAction: ActionDescriptor = { * Talon tests by relying on our recorded test fixtures alone. */ export const communitySnippetsSpokenFormsFixture = [ - spokenFormTest("snip import star after air", snippetAfterAction, undefined), + spokenFormTest("snip code after air", snippetAfterAction, undefined), ]; diff --git a/packages/test-runner/src/runAllTests.ts b/packages/test-runner/src/runAllTests.ts index 3f70b40389c..0d3fce74eb6 100644 --- a/packages/test-runner/src/runAllTests.ts +++ b/packages/test-runner/src/runAllTests.ts @@ -34,19 +34,28 @@ export function runAllTests(type: TestType): Promise { const testRoot = path.join(getCursorlessRepoRoot(), "packages"); let filePattern: string; - let ignore: string[] | undefined; - - if (type === TestType.unit) { - filePattern = "test.ts"; - ignore = [ - TestType.vscode, - TestType.talon, - TestType.talonJs, - TestType.neovim, - ].map((t) => `**/*.${t}.ts`); - } else { - filePattern = `${type}.cjs`; - ignore = undefined; + let ignore: string[] | undefined = undefined; + + switch (type) { + case TestType.unit: + filePattern = "test.ts"; + ignore = [ + TestType.vscode, + TestType.talon, + TestType.talonJs, + TestType.neovim, + ].map((t) => `**/*.${t}.ts`); + break; + + case TestType.talon: + case TestType.talonJs: + filePattern = `${type}.ts`; + break; + + // These tests have to be .cjs files because they import vscode and neovim modules which don't work with ts files + case TestType.vscode: + case TestType.neovim: + filePattern = `${type}.cjs`; } return runTestsInDir(testRoot, filePattern, ignore); From 49699fa3351263f98a35a53d53dae6f690dc6dd7 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 17:40:20 +0100 Subject: [PATCH 05/11] Only compile scode and neovim tests --- packages/test-runner/scripts/compile-esbuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/test-runner/scripts/compile-esbuild.sh b/packages/test-runner/scripts/compile-esbuild.sh index 926026df28d..9e4977107a2 100755 --- a/packages/test-runner/scripts/compile-esbuild.sh +++ b/packages/test-runner/scripts/compile-esbuild.sh @@ -12,5 +12,5 @@ set -euo pipefail --outfile=out/extensionTestsNeovim.cjs # Compile test cases -find .. -name '*.test.ts' -print0 | +find .. \( -name '*.vscode.test.ts' -o -name '*.neovim.test.ts' \) -print0 | xargs -0 -n 50 ./scripts/run-esbuild.sh --outdir=out --out-extension:.js=.cjs From 333b3644a5d99b1d693fab8d1c80a114b3e06ec1 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 17:45:57 +0100 Subject: [PATCH 06/11] Makes script executable --- package.json | 4 ++-- packages/app-talonjs/scripts/esbuild.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 packages/app-talonjs/scripts/esbuild.sh diff --git a/package.json b/package.json index 3e4b6b58815..2d9263e25c1 100644 --- a/package.json +++ b/package.json @@ -12,17 +12,17 @@ "build": "pnpm -r build", "clean": "pnpm -r clean", "typecheck": "pnpm -r typecheck", - "fix:prettier": "prettier --write --list-different .", "lint:meta": "pnpm run meta-updater --test", "lint:syncpack": "syncpack lint", "lint:ts": "eslint packages", - "lint:prettier": "prettier --check .", "lint:style": "stylelint '**/*.{css,scss}' --ignore-path .gitignore", + "lint:fmt": "prettier --check .", "lint": "pnpm run typecheck && pnpm run lint:meta && pnpm run lint:syncpack && pnpm run lint:ts && pnpm run lint:style", "fix:meta": "pnpm run meta-updater && pnpm -r exec prettier --write tsconfig.json package.json", "fix:syncpack": "syncpack fix", "fix:eslint": "pnpm lint:ts --fix", "fix:style": "stylelint '**/*.{css,scss}' --ignore-path .gitignore --fix", + "fix:fmt": "prettier --write --list-different .", "init-vscode-sandbox": "pnpm -F @cursorless/app-vscode init-launch-sandbox", "meta-updater": "env NODE_OPTIONS=--import=tsx meta-updater", "preinstall": "npx only-allow pnpm", diff --git a/packages/app-talonjs/scripts/esbuild.sh b/packages/app-talonjs/scripts/esbuild.sh old mode 100644 new mode 100755 From 4d6e07c3d90a464881b0580bf77e8ad5e6c12c36 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 18:25:06 +0100 Subject: [PATCH 07/11] Fix nearly import --- .../lib-engine/src/customCommandGrammar/parseCommand.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts index 8a9582cb625..26a25bd273d 100644 --- a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts +++ b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts @@ -1,17 +1,20 @@ import type { ActionDescriptor, ScopeType } from "@cursorless/lib-common"; -import { Grammar, Parser } from "nearley"; +import nearley from "nearley"; +import type { Parser } from "nearley"; import type { WithPlaceholders } from "./WithPlaceholders"; import grammar from "./generated/grammar"; +const { Grammar, Parser: NearleyParser } = nearley; + function getScopeTypeParser(): Parser { - return new Parser( + return new NearleyParser( // eslint-disable-next-line @typescript-eslint/naming-convention Grammar.fromCompiled({ ...grammar, ParserStart: "scopeType" }), ); } function getActionParser(): Parser { - return new Parser(Grammar.fromCompiled(grammar)); + return new NearleyParser(Grammar.fromCompiled(grammar)); } /** From 9d8174330708ca9b0bbd8431858ee9525dda2088 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 19:11:48 +0100 Subject: [PATCH 08/11] cleanup --- .../src/customCommandGrammar/parseCommand.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts index 26a25bd273d..77d2036bb99 100644 --- a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts +++ b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts @@ -1,20 +1,18 @@ import type { ActionDescriptor, ScopeType } from "@cursorless/lib-common"; -import nearley from "nearley"; import type { Parser } from "nearley"; +import * as nearley from "nearley"; import type { WithPlaceholders } from "./WithPlaceholders"; import grammar from "./generated/grammar"; -const { Grammar, Parser: NearleyParser } = nearley; - function getScopeTypeParser(): Parser { - return new NearleyParser( + return new nearley.Parser( // eslint-disable-next-line @typescript-eslint/naming-convention - Grammar.fromCompiled({ ...grammar, ParserStart: "scopeType" }), + nearley.Grammar.fromCompiled({ ...grammar, ParserStart: "scopeType" }), ); } function getActionParser(): Parser { - return new NearleyParser(Grammar.fromCompiled(grammar)); + return new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); } /** From af6d02692119be8f5e2477bd4b8ea8f9bfda8f0a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 19:50:45 +0100 Subject: [PATCH 09/11] fix --- packages/lib-engine/src/customCommandGrammar/parseCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts index 77d2036bb99..24e94edee3c 100644 --- a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts +++ b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts @@ -1,6 +1,6 @@ import type { ActionDescriptor, ScopeType } from "@cursorless/lib-common"; import type { Parser } from "nearley"; -import * as nearley from "nearley"; +import nearley from "nearley"; import type { WithPlaceholders } from "./WithPlaceholders"; import grammar from "./generated/grammar"; From 49b86bfcb52e57f9f4543713b8f312d73d2329a8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 19:55:02 +0100 Subject: [PATCH 10/11] nearley default export only --- packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts | 8 ++++---- .../src/keyboard/grammar/getAcceptableTokenTypes.test.ts | 6 +++--- .../src/keyboard/grammar/getAcceptableTokenTypes.ts | 5 ++--- packages/app-vscode/src/keyboard/grammar/grammar.test.ts | 6 +++--- packages/app-vscode/src/keyboard/grammar/keyboardLexer.ts | 4 ++-- .../lib-engine/src/customCommandGrammar/parseCommand.ts | 5 ++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts b/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts index abfdb2c843d..8979bf059e3 100644 --- a/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts +++ b/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts @@ -1,7 +1,7 @@ import { CompositeKeyMap } from "@cursorless/lib-common"; import type { VscodeApi } from "@cursorless/lib-vscode-common"; import { pick, sortedUniq, toPairs } from "lodash-es"; -import { Grammar, Parser } from "nearley"; +import nearley from "nearley"; import * as vscode from "vscode"; import { KeyboardCommandHandler } from "./KeyboardCommandHandler"; import { KeyboardCommandsModalLayer } from "./KeyboardCommandsModalLayer"; @@ -33,10 +33,10 @@ export default class KeyboardCommandsModal { string[], KeyboardCommandsModalLayer >((keys) => keys); - private parser!: Parser; + private parser!: nearley.Parser; private sections!: TokenTypeKeyMapMap; private keyboardCommandHandler: KeyboardCommandHandler; - private compiledGrammar = Grammar.fromCompiled(grammar); + private compiledGrammar = nearley.Grammar.fromCompiled(grammar); private keyboardConfig: KeyboardConfig; constructor( @@ -78,7 +78,7 @@ export default class KeyboardCommandsModal { } private resetParser() { - this.parser = new Parser(this.compiledGrammar); + this.parser = new nearley.Parser(this.compiledGrammar); this.computeLayer(); } diff --git a/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts b/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts index 8e5a0f9d5ff..b0639fcf7ad 100644 --- a/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts +++ b/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import { Grammar, Parser } from "nearley"; +import nearley from "nearley"; import type { KeyDescriptor } from "../TokenTypeHelpers"; import grammar from "./generated/grammar"; import type { AcceptableTokenType } from "./getAcceptableTokenTypes"; @@ -132,9 +132,9 @@ const testCases: TestCase[] = [ ]; suite("keyboard.getAcceptableTokenTypes", () => { - let parser: Parser; + let parser: nearley.Parser; setup(() => { - parser = new Parser(Grammar.fromCompiled(grammar)); + parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); }); testCases.forEach(({ tokens, expected }) => { diff --git a/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.ts b/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.ts index f878492aab7..86803199186 100644 --- a/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.ts +++ b/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.ts @@ -1,4 +1,3 @@ -import type { State } from "nearley"; import type nearley from "nearley"; import { isEqual, times } from "lodash-es"; import type { CommandRulePostProcessor } from "./CommandRulePostProcessor"; @@ -95,8 +94,8 @@ export const NEXT = Symbol("next"); function computeRootStatePartialArgs( state: nearley.State, lastSymbol: any = NEXT, - visitCounts = new DefaultMap(() => 0), - roots: { state: State; partialArg: any }[] = [], + visitCounts = new DefaultMap(() => 0), + roots: { state: nearley.State; partialArg: any }[] = [], ) { const visitCount = visitCounts.get(state); if (visitCount > MAX_VISITS) { diff --git a/packages/app-vscode/src/keyboard/grammar/grammar.test.ts b/packages/app-vscode/src/keyboard/grammar/grammar.test.ts index ef105a0b208..7400bab6085 100644 --- a/packages/app-vscode/src/keyboard/grammar/grammar.test.ts +++ b/packages/app-vscode/src/keyboard/grammar/grammar.test.ts @@ -1,4 +1,4 @@ -import { Parser, Grammar } from "nearley"; +import nearley from "nearley"; import grammar from "./generated/grammar"; import assert from "assert"; import type { KeyDescriptor } from "../TokenTypeHelpers"; @@ -179,9 +179,9 @@ const testCases: TestCase[] = [ ]; suite("keyboard grammar", () => { - let parser: Parser; + let parser: nearley.Parser; setup(() => { - parser = new Parser(Grammar.fromCompiled(grammar)); + parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); }); testCases.forEach(({ tokens, expected }) => { diff --git a/packages/app-vscode/src/keyboard/grammar/keyboardLexer.ts b/packages/app-vscode/src/keyboard/grammar/keyboardLexer.ts index 6afef2c2bdc..369103b117b 100644 --- a/packages/app-vscode/src/keyboard/grammar/keyboardLexer.ts +++ b/packages/app-vscode/src/keyboard/grammar/keyboardLexer.ts @@ -1,4 +1,4 @@ -import type { Lexer } from "nearley"; +import type nearley from "nearley"; import type { TokenTypeKeyMapMap } from "../TokenTypeHelpers"; interface LexerState { @@ -17,7 +17,7 @@ interface Token { * method that the parser will then use to transform the token into the actual * value that will be used when constructing rule outputs. */ -class KeyboardLexer implements Lexer { +class KeyboardLexer implements nearley.Lexer { buffer: any[] = []; bufferIndex = 0; index = 0; diff --git a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts index 24e94edee3c..22baa98c559 100644 --- a/packages/lib-engine/src/customCommandGrammar/parseCommand.ts +++ b/packages/lib-engine/src/customCommandGrammar/parseCommand.ts @@ -1,17 +1,16 @@ import type { ActionDescriptor, ScopeType } from "@cursorless/lib-common"; -import type { Parser } from "nearley"; import nearley from "nearley"; import type { WithPlaceholders } from "./WithPlaceholders"; import grammar from "./generated/grammar"; -function getScopeTypeParser(): Parser { +function getScopeTypeParser(): nearley.Parser { return new nearley.Parser( // eslint-disable-next-line @typescript-eslint/naming-convention nearley.Grammar.fromCompiled({ ...grammar, ParserStart: "scopeType" }), ); } -function getActionParser(): Parser { +function getActionParser(): nearley.Parser { return new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); } From b6b7a13fdac748e1b4e324134d689d4485cd4600 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 19 Mar 2026 19:59:21 +0100 Subject: [PATCH 11/11] Switch tree sister test utility to esm imports --- .../lib-engine/src/testUtil/TestTreeSitter.ts | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/packages/lib-engine/src/testUtil/TestTreeSitter.ts b/packages/lib-engine/src/testUtil/TestTreeSitter.ts index 6d3058def88..30c17a765b6 100644 --- a/packages/lib-engine/src/testUtil/TestTreeSitter.ts +++ b/packages/lib-engine/src/testUtil/TestTreeSitter.ts @@ -1,35 +1,15 @@ import type { TextDocument, TreeSitter } from "@cursorless/lib-common"; -import { createRequire } from "node:module"; import * as path from "node:path"; import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; -import type { - Tree, - Language as TreeSitterLanguage, - Parser as TreeSitterParser, - Query as TreeSitterQuery, -} from "web-tree-sitter"; +import type { Tree } from "web-tree-sitter"; +import { Parser, Query, Language } from "web-tree-sitter"; -// Force the CommonJS entrypoint because the ESM one crashes in this test -// runtime before we get a chance to initialize tree-sitter. -const moduleRequire = createRequire(__filename); - -const { - Language, - Parser, - Query, -}: { - // eslint-disable-next-line @typescript-eslint/consistent-type-imports - Parser: typeof import("web-tree-sitter").Parser; - Language: typeof TreeSitterLanguage; - Query: typeof TreeSitterQuery; -} = moduleRequire("web-tree-sitter"); - -interface Language { - language: TreeSitterLanguage; - parser: TreeSitterParser; +interface LanguageConf { + language: Language; + parser: Parser; } -const languageCache = new Map(); +const languageCache = new Map(); let initPromise: Promise | undefined; function initTreeSitter() { @@ -74,7 +54,7 @@ export class TestTreeSitter implements TreeSitter { return true; } - createQuery(languageId: string, source: string): TreeSitterQuery | undefined { + createQuery(languageId: string, source: string): Query | undefined { const language = languageCache.get(languageId); if (language == null) { return undefined;