Skip to content

Commit 4190538

Browse files
committed
chore: update test case
1 parent 355a906 commit 4190538

File tree

2 files changed

+47
-18
lines changed

2 files changed

+47
-18
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mkdirSync
2+
openSync
3+
readDirSync
4+
removeSync
5+
statSync
6+
writeFileSync
7+
writeTextFileSync
Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1-
let blocklist: string[] = Deno.readTextFileSync(".blocklisted")
1+
const blocklist: string[] = Deno.readTextFileSync(".blocklisted")
2+
.trim()
3+
.split("\n");
4+
const blocklistOnPoll: string[] = Deno.readTextFileSync(".blocklisted.poll")
25
.trim()
36
.split("\n");
47

5-
for (const api of blocklist) {
6-
console.log(api);
7-
if (Deno[api] === void 0) {
8-
continue;
9-
}
8+
function check(list: string[]) {
9+
for (const api of list) {
10+
console.log(api);
11+
if (Deno[api] === void 0) {
12+
continue;
13+
}
14+
15+
if (typeof Deno[api] !== "function") {
16+
throw new Error(`invalid api: ${api}`);
17+
}
18+
19+
try {
20+
Deno[api]();
21+
throw new Error(`unreachable: ${api}`);
22+
} catch (ex) {
23+
if (ex instanceof Deno.errors.PermissionDenied) {
24+
continue;
25+
} else if (ex instanceof TypeError) {
26+
if (ex.message === "called MOCK_FN") {
27+
continue;
28+
}
29+
}
30+
}
1031

11-
if (typeof Deno[api] !== "function") {
1232
throw new Error(`invalid api: ${api}`);
1333
}
34+
}
35+
36+
check(blocklist);
1437

38+
const { promise: fence, resolve, reject } = Promise.withResolvers<void>();
39+
40+
setTimeout(() => {
1541
try {
16-
Deno[api]();
17-
throw new Error(`unreachable: ${api}`);
42+
check(blocklistOnPoll);
43+
resolve();
1844
} catch (ex) {
19-
if (ex instanceof Deno.errors.PermissionDenied) {
20-
continue;
21-
} else if (ex instanceof TypeError) {
22-
if (ex.message === "called MOCK_FN") {
23-
continue;
24-
}
25-
}
45+
reject(ex);
2646
}
47+
});
2748

28-
throw new Error(`invalid api: ${api}`);
29-
}
49+
await fence;
50+
51+
export {};

0 commit comments

Comments
 (0)