-
Notifications
You must be signed in to change notification settings - Fork 6k
Expand file tree
/
Copy pathcommon.ts
More file actions
46 lines (38 loc) · 1.05 KB
/
common.ts
File metadata and controls
46 lines (38 loc) · 1.05 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
// Copyright 2018-2026 the Deno authors. MIT license.
import { parse } from "@std/toml";
export interface SingleFileConfig {
flaky?: boolean;
windows?: boolean;
darwin?: boolean;
linux?: boolean;
/** Optional reason for ignoring the test */
reason?: string;
}
type Config = {
tests: Record<string, SingleFileConfig>;
};
export const configFile = await Deno.readTextFile(
new URL("./config.toml", import.meta.url),
).then(parse) as Config;
/** Checks if the test file uses `node:test` module */
export function usesNodeTestModule(testSource: string): boolean {
return testSource.includes("'node:test'");
}
export const RUN_ARGS = [
"-A",
"--quiet",
"--unstable-unsafe-proto",
"--unstable-bare-node-builtins",
];
export const TEST_ARGS = [
"test",
...RUN_ARGS,
"--no-check",
"--unstable-detect-cjs",
];
/** Parses the special "Flags:"" syntax in Node.js test files */
export function parseFlags(source: string): string[] {
const line = /^\/\/ Flags: (.+)$/um.exec(source);
if (line == null) return [];
return line[1].split(" ");
}