-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate.ts
81 lines (71 loc) · 2.81 KB
/
update.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
import {$, file} from 'bun';
import { glob } from 'glob'
import { writeFile } from 'fs/promises';
import {relative } from 'path';
import { uniq } from 'lodash';
console.info('Updating Deno tests...');
await $`git submodule update --recursive --init --remote --merge deno`
const testJsonConfigFileText = await file('deno/tests/node_compat/config.jsonc').text();
const jsonConfigFileWithCommentsRemoved = testJsonConfigFileText
.split('\n')
.filter(line => !line.trim().startsWith('//'))
.join('\n');
const jsonConfigObject = JSON.parse(jsonConfigFileWithCommentsRemoved);
const basePath = 'deno/tests/node_compat/runner/suite/test';
const availableCategoryPaths = await glob('deno/tests/node_compat/runner/suite/test/**/*');
const categories = uniq(availableCategoryPaths.map(path => {
const relativePath = relative(basePath, path);
return relativePath.substring(0, relativePath.lastIndexOf('/'))
}));
//from: https://github.com/denoland/deno/blob/main/tests/node_compat/runner/setup.ts
const ignoredDirectories = [
"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",
];
const finalResult = new Array<any>();
for(const category of categories) {
if(!category || ignoredDirectories.includes(category)) {
continue;
}
const testsIgnored = jsonConfigObject.ignore[category] || [];
const testsWindowsIgnored = jsonConfigObject.windowsIgnore[category] || [];
const testsDarwinIgnored = jsonConfigObject.darwinIgnore[category] || [];
const testsImplemented = jsonConfigObject.tests[category] || [];
const categoryBasePath = `${basePath}/${category}`;
const allTestFilePaths = await glob(`${categoryBasePath}/*`);
const allTestFileNames = allTestFilePaths.map(path => relative(categoryBasePath, path));
console.info('Processing category:', category, allTestFileNames, testsImplemented, testsIgnored.length + testsWindowsIgnored.length + testsDarwinIgnored.length);
console.info();
finalResult.push(...allTestFileNames.map(testFileName => {
return {
name: category + "/" + testFileName,
implemented:
testsImplemented.includes(testFileName) &&
!testsIgnored.includes(testFileName) &&
!testsWindowsIgnored.includes(testFileName) &&
!testsDarwinIgnored.includes(testFileName)
} as TestCoverage;
}));
}
// persist to a JSON file in the react app public folder
const jsonFilePath = `app/public/tests.json`;
await writeFile(jsonFilePath, JSON.stringify({
coverage: finalResult,
date: new Date().toISOString()
} as TestCoverageReport, null, 1));