Skip to content

Commit 82770cb

Browse files
panvaaduh95
authored andcommitted
test: improve WPT report runner
Add incremental report writing after each spec completes and on worker errors so that reports survive if the process is killed before the exit handler runs. Add bytes() method to readAsFetch() to match the Response API used by newer WPT tests. PR-URL: #62107 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
1 parent cfc847d commit 82770cb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/common/wpt.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class ResourceLoader {
223223
return {
224224
ok: true,
225225
arrayBuffer() { return data.buffer; },
226+
bytes() { return new Uint8Array(data); },
226227
json() { return JSON.parse(data.toString()); },
227228
text() { return data.toString(); },
228229
};
@@ -721,6 +722,7 @@ class WPTRunner {
721722
// Mark the whole test as failed in wpt.fyi report.
722723
reportResult?.finish('ERROR');
723724
this.inProgress.delete(spec);
725+
this.report?.write();
724726
});
725727

726728
await events.once(worker, 'exit').catch(() => {});
@@ -787,6 +789,9 @@ class WPTRunner {
787789
}
788790
}
789791

792+
// Write the report on clean exit. The report is also written
793+
// incrementally after each spec completes (see completionCallback)
794+
// so that results survive if the process is killed.
790795
this.report?.write();
791796

792797
const ran = queue.length;
@@ -873,6 +878,9 @@ class WPTRunner {
873878
reportResult?.finish();
874879
}
875880
this.inProgress.delete(spec);
881+
// Write report incrementally so results survive even if the process
882+
// is killed before the exit handler runs.
883+
this.report?.write();
876884
// Always force termination of the worker. Some tests allocate resources
877885
// that would otherwise keep it alive.
878886
this.workers.get(spec).terminate();

0 commit comments

Comments
 (0)