/
list_remaining_tests.ts
96 lines (82 loc) · 2.33 KB
/
list_remaining_tests.ts
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { withoutAll } from "../../collections/without_all.ts";
import { walk } from "../../fs/walk.ts";
import { relative } from "../path/posix.ts";
import config from "./config.json" assert { type: "json" };
const encoder = new TextEncoder();
const NODE_BASE_URL = "https://github.com/nodejs/node";
const NODE_IGNORED_TEST_DIRS = [
"addons",
"async-hooks",
"cctest",
"common",
"doctool",
"embedding",
"fixtures",
"fuzzers",
"js-native-api",
"node-api",
"overlapped-checker",
"report",
"testpy",
"tick-processor",
"tools",
"v8-updates",
"wasi",
"wpt",
];
async function getNodeTests(): Promise<string[]> {
const paths: string[] = [];
const root = new URL(
`versions/node-v${config.nodeVersion}/test`,
import.meta.url,
);
const rootPath = root.href.slice(7);
for await (const item of walk(root, { includeDirs: false, exts: [".js"] })) {
const path = relative(rootPath, item.path);
if (NODE_IGNORED_TEST_DIRS.every((dir) => !path.startsWith(dir))) {
paths.push(path);
}
}
return paths.sort();
}
function getDenoTests(): string[] {
return Object.entries(config.tests)
.filter(([testDir]) => !NODE_IGNORED_TEST_DIRS.includes(testDir))
.flatMap(([testDir, tests]) => tests.map((test) => testDir + "/" + test));
}
async function getMissingTests(): Promise<string[]> {
const nodeTests = await getNodeTests();
const denoTests = await getDenoTests();
return withoutAll(nodeTests, denoTests);
}
export async function updateToDo() {
const file = await Deno.open(new URL("./TODO.md", import.meta.url), {
write: true,
create: true,
truncate: true,
});
const missingTests = await getMissingTests();
await file.write(encoder.encode("# Remaining Node Tests\n\n"));
await file.write(
encoder.encode(
"NOTE: This file should not be manually edited. Please edit `config.json` and run `deno task node:setup` instead.\n\n",
),
);
await file.write(
encoder.encode(`Total: ${missingTests.length}\n\n`),
);
for (const test of missingTests) {
await file.write(
encoder.encode(
`- [${test}](${
NODE_BASE_URL + `/tree/v${config.nodeVersion}/test/` + test
})\n`,
),
);
}
file.close();
}
if (import.meta.main) {
await updateToDo();
}