Skip to content

Commit c2e9c00

Browse files
josharianpokeyAndreasArvidsson
authored
move subset regular expressions to a separate file (#1690)
This enables us to ask git not to [track changes to that file. And while we're here, support multiple regular expressions. ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [x] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <[email protected]> Co-authored-by: Andreas Arvidsson <[email protected]>
1 parent 63ea8e9 commit c2e9c00

File tree

16 files changed

+147
-48
lines changed

16 files changed

+147
-48
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ yarn-error.log*
3939
# typescript
4040
*.tsbuildinfo
4141
next-env.d.ts
42+
43+
# test subset config
44+
packages/test-harness/testSubsetGrep.properties

.vscode/launch.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,33 @@
4444
]
4545
},
4646
{
47-
"name": "Talon tests",
48-
"type": "node",
47+
"name": "Extension tests subset",
48+
"type": "extensionHost",
4949
"request": "launch",
50-
"program": "${workspaceFolder}/packages/test-harness/out/scripts/runTalonTests",
5150
"env": {
5251
"CURSORLESS_TEST": "true",
52+
"CURSORLESS_RUN_TEST_SUBSET": "true",
5353
"CURSORLESS_REPO_ROOT": "${workspaceFolder}"
5454
},
55+
"args": [
56+
"--profile=cursorlessDevelopment",
57+
"--extensionDevelopmentPath=${workspaceFolder}/packages/cursorless-vscode/dist",
58+
"--extensionTestsPath=${workspaceFolder}/packages/test-harness/out/runners/extensionTests"
59+
],
5560
"outFiles": ["${workspaceFolder}/**/out/**/*.js"],
56-
"preLaunchTask": "${defaultBuildTask}",
61+
"preLaunchTask": "Prepare test subset",
5762
"resolveSourceMapLocations": [
5863
"${workspaceFolder}/**",
5964
"!**/node_modules/**"
6065
]
6166
},
6267
{
63-
"name": "Talon tests subset",
68+
"name": "Talon tests",
6469
"type": "node",
6570
"request": "launch",
6671
"program": "${workspaceFolder}/packages/test-harness/out/scripts/runTalonTests",
6772
"env": {
6873
"CURSORLESS_TEST": "true",
69-
"CURSORLESS_RUN_TEST_SUBSET": "true",
7074
"CURSORLESS_REPO_ROOT": "${workspaceFolder}"
7175
},
7276
"outFiles": ["${workspaceFolder}/**/out/**/*.js"],
@@ -77,12 +81,13 @@
7781
]
7882
},
7983
{
80-
"name": "Unit tests only",
84+
"name": "Talon tests subset",
8185
"type": "node",
8286
"request": "launch",
83-
"program": "${workspaceFolder}/packages/test-harness/out/scripts/runUnitTestsOnly",
87+
"program": "${workspaceFolder}/packages/test-harness/out/scripts/runTalonTests",
8488
"env": {
8589
"CURSORLESS_TEST": "true",
90+
"CURSORLESS_RUN_TEST_SUBSET": "true",
8691
"CURSORLESS_REPO_ROOT": "${workspaceFolder}"
8792
},
8893
"outFiles": ["${workspaceFolder}/**/out/**/*.js"],
@@ -93,19 +98,14 @@
9398
]
9499
},
95100
{
96-
"name": "Run test subset",
97-
"type": "extensionHost",
101+
"name": "Unit tests only",
102+
"type": "node",
98103
"request": "launch",
104+
"program": "${workspaceFolder}/packages/test-harness/out/scripts/runUnitTestsOnly",
99105
"env": {
100106
"CURSORLESS_TEST": "true",
101-
"CURSORLESS_RUN_TEST_SUBSET": "true",
102107
"CURSORLESS_REPO_ROOT": "${workspaceFolder}"
103108
},
104-
"args": [
105-
"--profile=cursorlessDevelopment",
106-
"--extensionDevelopmentPath=${workspaceFolder}/packages/cursorless-vscode/dist",
107-
"--extensionTestsPath=${workspaceFolder}/packages/test-harness/out/runners/extensionTests"
108-
],
109109
"outFiles": ["${workspaceFolder}/**/out/**/*.js"],
110110
"preLaunchTask": "${defaultBuildTask}",
111111
"resolveSourceMapLocations": [

.vscode/tasks.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,33 @@
4646
},
4747
"group": "build"
4848
},
49+
{
50+
"label": "Ensure test subset file exists",
51+
"type": "npm",
52+
"script": "generate-test-subset-file-strict",
53+
"path": "packages/test-harness",
54+
"presentation": {
55+
"reveal": "silent"
56+
},
57+
"group": "test"
58+
},
59+
{
60+
"label": "Generate test subset file",
61+
"type": "npm",
62+
"script": "generate-test-subset-file",
63+
"path": "packages/test-harness",
64+
"presentation": {
65+
"reveal": "silent"
66+
},
67+
"group": "none",
68+
"problemMatcher": []
69+
},
70+
{
71+
"label": "Prepare test subset",
72+
"dependsOn": ["Ensure test subset file exists", "Build"],
73+
"dependsOrder": "sequence",
74+
"group": "test"
75+
},
4976
{
5077
"type": "npm",
5178
"script": "watch",

cursorless-talon-dev/src/cursorless_dev_vscode.talon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ app: vscode
1111
user.vscode("workbench.action.tasks.terminate")
1212
insert("Serve")
1313
key(enter)
14+
15+
^debug generate subset$:
16+
user.vscode_with_plugin("workbench.action.tasks.runTask", "Generate test subset file")
17+
^debug edit subset$:
18+
user.vscode_with_plugin("commands.openFolder", "./packages/test-harness/testSubsetGrep.properties")

docs/contributing/CONTRIBUTING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ Extension" or "Extension Tests".
5656

5757
### Running a subset of tests
5858

59-
The entire test suite takes a little while to run (1-2 mins), so if you'd like to run just a subset of the tests, you can edit the constant in [`runTestSubset`](../../packages/common/src/testUtil/runTestSubset.ts) to a string supported by [mocha grep](https://mochajs.org/#-grep-regexp-g-regexp) and use the "Run Test Subset" launch config instead of the usual "Extension Tests".
59+
The entire test suite takes a little while to run (1-2 mins), so you may want to run just a subset of the tests.
60+
61+
To specify the set of tests to run, say `"debug generate subset"`, or if you haven't installed the cursorless-talon-dev files, run the VSCode task "Generate test subset file". To do this, choose "Tasks: Run Task" from the command pallete.
62+
63+
To run the specified subset of tests, use the "Run test subset" launch config instead of the usual "Extension Tests".
64+
65+
If you need to edit the subset of tests to run in the future, you can say `"debug edit subset"`.
6066

6167
## Code formatting
6268

packages/common/src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
export * from "./cursorlessCommandIds";
22
export * from "./testUtil/extractTargetedMarks";
33
export { default as FakeIDE } from "./ide/fake/FakeIDE";
4-
export {
5-
runTestSubset,
6-
TEST_SUBSET_GREP_STRING,
7-
} from "./testUtil/runTestSubset";
84
export { Message } from "./ide/spy/SpyMessages";
95
export { SpyIDERecordedValues } from "./ide/spy/SpyIDE";
106
export { default as SpyIDE } from "./ide/spy/SpyIDE";

packages/common/src/testUtil/runTestSubset.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/test-harness/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"test": "env CURSORLESS_TEST=true tsx --conditions=cursorless:bundler src/scripts/runTestsCI.ts",
99
"compile": "tsc --build",
1010
"watch": "tsc --build --watch",
11-
"clean": "rm -rf ./out tsconfig.tsbuildinfo"
11+
"clean": "rm -rf ./out tsconfig.tsbuildinfo",
12+
"generate-test-subset-file": "tsx --conditions=cursorless:bundler ./src/scripts/generateTestSubsetFile.ts --always-open",
13+
"generate-test-subset-file-strict": "tsx --conditions=cursorless:bundler ./src/scripts/generateTestSubsetFile.ts --fail-if-not-exists"
1214
},
1315
"keywords": [],
1416
"author": "",

packages/test-harness/src/util/runAllTests.ts renamed to packages/test-harness/src/runAllTests.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import * as globRaw from "glob";
22
import * as Mocha from "mocha";
33
import * as path from "path";
4-
import {
5-
getCursorlessRepoRoot,
6-
runTestSubset,
7-
TEST_SUBSET_GREP_STRING,
8-
} from "@cursorless/common";
4+
import { getCursorlessRepoRoot } from "@cursorless/common";
95
import { promisify } from "util";
6+
import { runTestSubset, testSubsetGrepString } from "./testSubset";
107

118
const glob = promisify(globRaw);
129

@@ -50,7 +47,7 @@ async function runTestsInDir(
5047
const mocha = new Mocha({
5148
ui: "tdd",
5249
color: true,
53-
grep: runTestSubset() ? TEST_SUBSET_GREP_STRING : undefined, // Only run a subset of tests
50+
grep: runTestSubset() ? testSubsetGrepString() : undefined, // Only run a subset of tests
5451
});
5552

5653
const files = filterFiles(await glob("**/**.test.js", { cwd: testRoot }));

0 commit comments

Comments
 (0)