Skip to content

Commit 4047538

Browse files
more build updates
1 parent e29cde9 commit 4047538

10 files changed

Lines changed: 46 additions & 55 deletions

File tree

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{
3232
"label": "Build test harness",
3333
"type": "npm",
34-
"script": "bundle",
34+
"script": "build",
3535
"path": "packages/test-harness",
3636
"presentation": {
3737
"reveal": "silent"

packages/test-harness/package.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,15 @@
1515
"scripts": {
1616
"typecheck": "tsc",
1717
"clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build",
18-
"test": "c-tsx ./src/scripts/runUnitTestsOnly.ts",
19-
"test:subset": "c-tsx ./src/scripts/runUnitTestsOnly.ts --subset",
20-
"test:update": "c-tsx ./src/scripts/runUnitTestsOnly.ts --update",
21-
"test:update:subset": "c-tsx ./src/scripts/runUnitTestsOnly.ts --update --subset",
18+
"test": "c-tsx ./src/scripts/runUnitTests.ts",
19+
"test:subset": "c-tsx ./src/scripts/runUnitTests.ts --subset",
20+
"test:update": "c-tsx ./src/scripts/runUnitTests.ts --update",
21+
"test:update:subset": "c-tsx ./src/scripts/runUnitTests.ts --update --subset",
2222
"test:vscode": "c-tsx ./src/scripts/runVscodeTestsCI.ts",
2323
"test:neovim": "c-tsx ./src/scripts/runNeovimTestsCI.ts",
2424
"test:talon": "c-tsx ./src/scripts/runTalonTests.ts",
2525
"test:talonJs": "c-tsx ./src/scripts/runTalonJsTests.ts",
26-
"pretest": "pnpm run bundle",
27-
"pretest:subset": "pnpm run bundle",
28-
"pretest:update": "pnpm run bundle",
29-
"pretest:update:subset": "pnpm run bundle",
30-
"pretest:vscode": "pnpm run bundle",
31-
"pretest:neovim": "pnpm run bundle",
32-
"pretest:talon": "pnpm run bundle",
33-
"pretest:talonJs": "pnpm run bundle",
34-
"bundle": "bash ./scripts/compile-esbuild.sh",
26+
"build": "bash ./scripts/compile-esbuild.sh",
3527
"generate-test-subset-file": "c-tsx ./src/scripts/generateTestSubsetFile.ts --always-open",
3628
"generate-test-subset-file-strict": "c-tsx ./src/scripts/generateTestSubsetFile.ts --fail-if-not-exists"
3729
},

packages/test-harness/src/launchVscodeAndRunTests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export async function launchVscodeAndRunTests(extensionTestsPath: string) {
6969
vscodeExecutablePath,
7070
extensionDevelopmentPath,
7171
extensionTestsPath,
72+
extensionTestsEnv: {
73+
["CURSORLESS_MODE"]: "test",
74+
},
7275
// Note: Crash dump causes legacy VSCode and Windows to hang, so we just
7376
// don't bother. Can be re-enabled if we ever need it; on windows it only
7477
// hangs some of the time, so might be enough to get a crash dump when you

packages/test-harness/src/runAllTests.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export enum TestType {
3030
}
3131

3232
export function runAllTests(type: TestType): Promise<void> {
33+
parseArgumentsAndUpdateEnv();
34+
3335
return runTestsInDir(
3436
path.join(getCursorlessRepoRoot(), "packages"),
3537
(files) =>
@@ -68,6 +70,12 @@ async function runTestsInDir(
6870

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

73+
if (files.length === 0) {
74+
throw new Error(
75+
`No test files found. Do you need to run "pnpm run build" first?`,
76+
);
77+
}
78+
7179
// Add files to the test suite
7280
files.forEach((f) => mocha.addFile(path.resolve(testRoot, f)));
7381

@@ -97,3 +105,17 @@ async function runTestsInDir(
97105
throw err;
98106
}
99107
}
108+
109+
function parseArgumentsAndUpdateEnv() {
110+
const args = new Set(process.argv.slice(2));
111+
112+
process.env.CURSORLESS_MODE = "test";
113+
114+
if (args.has("--subset")) {
115+
process.env.CURSORLESS_RUN_TEST_SUBSET = "true";
116+
}
117+
118+
if (args.has("--update")) {
119+
process.env.CURSORLESS_TEST_UPDATE_FIXTURES = "true";
120+
}
121+
}

packages/test-harness/src/scripts/runNeovimTestsCI.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import { launchNeovimAndRunTests } from "../launchNeovimAndRunTests";
66

7-
process.env.CURSORLESS_MODE = "test";
8-
97
void (async () => {
108
await launchNeovimAndRunTests();
119
})();

packages/test-harness/src/scripts/runTalonJsTests.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
* Runs all Talon everywhere/JS tests.
33
*/
44

5-
process.env.CURSORLESS_MODE = "test";
6-
75
void (async () => {
86
const { TestType, runAllTests } = await import("../runAllTests");
97

10-
try {
11-
await runAllTests(TestType.talonJs);
12-
} catch (_ex) {
13-
process.exit(1);
14-
}
8+
await runAllTests(TestType.talonJs);
159
})();
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
* Runs all Talon tests.
33
*/
4-
import { TestType, runAllTests } from "../runAllTests";
54

6-
void runAllTests(TestType.talon);
5+
void (async () => {
6+
const { TestType, runAllTests } = await import("../runAllTests");
7+
8+
await runAllTests(TestType.talon);
9+
})();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Runs all tests that don't have to be run within a particular environment.
3+
*/
4+
5+
void (async () => {
6+
const { TestType, runAllTests } = await import("../runAllTests");
7+
8+
await runAllTests(TestType.unit);
9+
})();

packages/test-harness/src/scripts/runUnitTestsOnly.ts

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

packages/test-harness/src/scripts/runVscodeTestsCI.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { getCursorlessRepoRoot } from "@cursorless/node-common";
66
import * as path from "node:path";
77
import { launchVscodeAndRunTests } from "../launchVscodeAndRunTests";
88

9-
process.env.CURSORLESS_MODE = "test";
10-
119
void (async () => {
1210
const extensionTestsPath = path.resolve(
1311
getCursorlessRepoRoot(),

0 commit comments

Comments
 (0)