Skip to content

Commit 4823f2b

Browse files
authored
chore(ext/node): ignore some node test cases (#29462)
1 parent 077f0c5 commit 4823f2b

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

tests/node_compat/run_all_test_unmodified.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type TestReportMetadata = {
3737
runId: string | null;
3838
total: number;
3939
pass: number;
40+
ignore: number;
4041
};
4142

4243
// The test report format, which is stored in JSON file
@@ -67,6 +68,10 @@ const NODE_IGNORED_TEST_DIRS = [
6768
"wpt",
6869
];
6970

71+
const NODE_IGNORED_TEST_CASES = new Set([
72+
"parallel/test-benchmark-cli.js", // testing private benchmark utility
73+
]);
74+
7075
/** The group is the directory name of the test file.
7176
* e.g. parallel, internet, pummel, sequential, pseudo-tty, etc */
7277
function getGroupRelUrl(str: string) {
@@ -84,7 +89,8 @@ function truncateTestOutput(output: string): string {
8489
enum NodeTestFileResult {
8590
PASS = "pass",
8691
FAIL = "fail",
87-
SKIP = "skip",
92+
SKIP = "skip", // skipped because of filtering (for debugging locally)
93+
IGNORED = "ignored", // ignored because the test case does not need to pass in Deno
8894
}
8995

9096
interface NodeTestFileReport {
@@ -95,7 +101,7 @@ interface NodeTestFileReport {
95101
type TestReports = Record<string, NodeTestFileReport>;
96102

97103
export type SingleResult = [
98-
pass: boolean,
104+
pass: boolean | "IGNORE",
99105
error?: ErrorExit | ErrorTimeout | ErrorUnexpected,
100106
];
101107
type ErrorExit = {
@@ -136,6 +142,9 @@ async function runSingle(
136142
testPath: string,
137143
retry = 0,
138144
): Promise<NodeTestFileReport> {
145+
if (NODE_IGNORED_TEST_CASES.has(testPath)) {
146+
return { result: NodeTestFileResult.IGNORED };
147+
}
139148
let cmd: Deno.ChildProcess | undefined;
140149
const testPath_ = "tests/node_compat/runner/suite/test/" + testPath;
141150
try {
@@ -203,6 +212,8 @@ function transformReportsIntoResults(
203212
let result: SingleResult = [true];
204213
if (value.result === NodeTestFileResult.FAIL) {
205214
result = [false, value.error];
215+
} else if (value.result === NodeTestFileResult.IGNORED) {
216+
result = ["IGNORE"];
206217
}
207218
results[key] = result;
208219
}
@@ -214,6 +225,7 @@ async function writeTestReport(
214225
reports: TestReports,
215226
total: number,
216227
pass: number,
228+
ignore: number,
217229
) {
218230
// First transform the results - before we added `NodeTestFileReport` we used `SingleResult`.
219231
// For now we opt to keep that format, as migrating existing results is cumbersome.
@@ -231,6 +243,7 @@ async function writeTestReport(
231243
runId: Deno.env.get("GITHUB_RUN_ID") ?? null,
232244
total,
233245
pass,
246+
ignore,
234247
results,
235248
} satisfies TestReport,
236249
),
@@ -270,6 +283,8 @@ async function main() {
270283
console.log(`${num} %cPASS`, "color: green", testPath);
271284
} else if (result.result === NodeTestFileResult.FAIL) {
272285
console.log(`${num} %cFAIL`, "color: red", testPath);
286+
} else if (result.result === NodeTestFileResult.IGNORED) {
287+
console.log(`${num} %cIGNORED`, "color: gray", testPath);
273288
} else {
274289
// Don't print message for "skip" for now, as it's too noisy
275290
// console.log(`${num} %cSKIP`, "color: yellow", testPath);
@@ -339,6 +354,10 @@ async function main() {
339354
// console.log(` %cSKIP`, "color: yellow", testPath);
340355
break;
341356
}
357+
case NodeTestFileResult.IGNORED: {
358+
console.log(` %cIGNORED`, "color: gray", testPath);
359+
break;
360+
}
342361
default:
343362
console.warn(
344363
`Unknown result (${fileResult.result}) for ${testPath}`,
@@ -347,19 +366,21 @@ async function main() {
347366
}
348367

349368
// Summary
350-
let total;
351369
const pass =
352370
tests.filter((test) => reports[test].result === NodeTestFileResult.PASS)
353371
.length;
372+
const fail =
373+
tests.filter((test) => reports[test].result === NodeTestFileResult.FAIL)
374+
.length;
375+
const ignore =
376+
tests.filter((test) => reports[test].result === NodeTestFileResult.IGNORED)
377+
.length;
378+
const total = pass + fail;
354379
if (filterTerm) {
355-
total = tests.map((testPath) =>
356-
reports[testPath].result
357-
).filter((result) => result !== NodeTestFileResult.SKIP).length;
358380
console.log(
359381
`Filtered tests: ${pass}/${total} (${(pass / total * 100).toFixed(2)}%)`,
360382
);
361383
} else {
362-
total = tests.length;
363384
console.log(
364385
`All tests: ${pass}/${total} (${(pass / total * 100).toFixed(2)}%)`,
365386
);
@@ -369,7 +390,7 @@ async function main() {
369390
// Store the results in a JSON file
370391

371392
if (!filterTerm) {
372-
await writeTestReport(reports, total, pass);
393+
await writeTestReport(reports, total, pass, ignore);
373394
}
374395

375396
Deno.exit(0);

0 commit comments

Comments
 (0)