1
0
forked from rosa/hakurei

cmd/pkgserver: move StreamReporter display() to Reporter interface

This commit is contained in:
Kat
2026-03-14 14:23:10 +11:00
parent f92385e9b0
commit a3d0a4776c

View File

@@ -8,6 +8,7 @@ export interface TestResult {
export interface Reporter {
update(path: string[], result: TestResult);
finalize();
}
export interface Stream {
@@ -39,7 +40,7 @@ export class StreamReporter implements Reporter {
}
}
display() {
finalize() {
// Transform [{ path: ['a', 'b', 'c'] }, { path: ['a', 'b', 'd'] }]
// into { 'a b': ['c', 'd'] }.
let pathMap = new Map<string, ({ name: string } & TestResult)[]>();
@@ -115,6 +116,8 @@ export class DOMReporter implements Reporter {
}
parent.appendChild(p);
}
finalize() {}
}
let r = typeof document !== 'undefined' ? new DOMReporter() : new StreamReporter({ writeln: console.log });
@@ -125,4 +128,4 @@ r.update(['Tetromino', 'generate', 'tessellates'], { success: false, output: 'as
r.update(['Tetromino', 'solve', 'works'], { success: true, output: '' });
r.update(['discombobulate'], { success: false, output: 'hippopotamonstrosesquippedaliophobia' });
r.update(['recombobulate'], { success: true, output: '' });
if (r instanceof StreamReporter) r.display();
r.finalize();