Repository navigation
Expand file tree
/
Copy pathtest-runner.mjs
More file actions
49 lines (49 loc) · 1.48 KB
/
Copy pathtest-runner.mjs
File metadata and controls
49 lines (49 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Tests choose their own workspace. A live Loop-launched terminal must
// not inject its database, disabled memory setting, daemon flags or credentials.
import { runSupervised } from "./heavy-command.mjs";
import { globSync } from "node:fs";
import { pathToFileURL } from "node:url";
export function testEnvironment(env) {
const clean = Object.fromEntries(
Object.entries(env).filter(
([key]) => !/^LOOP_/.test(key) || /^LOOP_TEST_/.test(key),
),
);
return clean;
}
if (
process.argv[1] &&
import.meta.url === pathToFileURL(process.argv[1]).href
) {
const [suite, ...extra] = process.argv.slice(2);
if (!["vitest", "native"].includes(suite))
throw new Error("Expected vitest or native suite");
const args =
suite === "vitest"
? [
"node_modules/vitest/vitest.mjs",
"run",
"test/",
"--exclude",
"test/**/*.node.test.ts",
// "test/" matches any path containing it, so a nested checkout
// under .tmp (deployment fixtures keep sources there) would be
// collected as well.
"--exclude",
"**/.tmp/**",
...extra,
]
: [
"--import",
"tsx",
"--test",
"--test-concurrency=1",
...extra,
...globSync("test/*.node.test.ts"),
];
process.exitCode = await runSupervised(process.execPath, args, {
label: `${suite} tests`,
stdio: "inherit",
env: testEnvironment(process.env),
});
}