forked from rosa/hakurei
cmd/pkgserver: move StreamReporter display() to Reporter interface
This commit is contained in:
@@ -8,6 +8,7 @@ export interface TestResult {
|
|||||||
|
|
||||||
export interface Reporter {
|
export interface Reporter {
|
||||||
update(path: string[], result: TestResult);
|
update(path: string[], result: TestResult);
|
||||||
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Stream {
|
export interface Stream {
|
||||||
@@ -39,7 +40,7 @@ export class StreamReporter implements Reporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display() {
|
finalize() {
|
||||||
// Transform [{ path: ['a', 'b', 'c'] }, { path: ['a', 'b', 'd'] }]
|
// Transform [{ path: ['a', 'b', 'c'] }, { path: ['a', 'b', 'd'] }]
|
||||||
// into { 'a ❯ b': ['c', 'd'] }.
|
// into { 'a ❯ b': ['c', 'd'] }.
|
||||||
let pathMap = new Map<string, ({ name: string } & TestResult)[]>();
|
let pathMap = new Map<string, ({ name: string } & TestResult)[]>();
|
||||||
@@ -115,6 +116,8 @@ export class DOMReporter implements Reporter {
|
|||||||
}
|
}
|
||||||
parent.appendChild(p);
|
parent.appendChild(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finalize() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = typeof document !== 'undefined' ? new DOMReporter() : new StreamReporter({ writeln: console.log });
|
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(['Tetromino', 'solve', 'works'], { success: true, output: '' });
|
||||||
r.update(['discombobulate'], { success: false, output: 'hippopotamonstrosesquippedaliophobia' });
|
r.update(['discombobulate'], { success: false, output: 'hippopotamonstrosesquippedaliophobia' });
|
||||||
r.update(['recombobulate'], { success: true, output: '' });
|
r.update(['recombobulate'], { success: true, output: '' });
|
||||||
if (r instanceof StreamReporter) r.display();
|
r.finalize();
|
||||||
|
|||||||
Reference in New Issue
Block a user