forked from security/hakurei
cmd/pkgserver: move StreamReporter display() to Reporter interface
This commit is contained in:
@@ -8,6 +8,7 @@ export interface TestResult {
|
||||
|
||||
export interface Reporter {
|
||||
update(path: string[], result: TestResult): void;
|
||||
finalize(): void;
|
||||
}
|
||||
|
||||
export interface Stream {
|
||||
@@ -40,7 +41,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)[]>();
|
||||
@@ -117,6 +118,8 @@ export class DOMReporter implements Reporter {
|
||||
}
|
||||
parent.appendChild(p);
|
||||
}
|
||||
|
||||
finalize() {}
|
||||
}
|
||||
|
||||
let r = typeof document !== "undefined" ? new DOMReporter() : new StreamReporter({ writeln: console.log });
|
||||
@@ -127,4 +130,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();
|
||||
|
||||
Reference in New Issue
Block a user