SRS/tools/printIssue.ts

71 lines
1.9 KiB
TypeScript
Raw Permalink Normal View History

2022-06-11 16:58:08 +09:00
import testcaseData from "./testcases.json" assert { type: "json"};
2022-06-11 15:10:10 +09:00
type Testcase = {
id: number,
subId: number | null,
content: string,
procedure: string,
testData: string| null,
expected: string,
actual: string,
pass: boolean
}
2022-06-11 16:58:08 +09:00
const testcase: Testcase[] = testcaseData;
2022-06-11 15:10:10 +09:00
import {Issue} from "./githubType.ts"
2022-06-11 16:58:08 +09:00
const data = await Deno.readTextFile("../cache/issues.json")
2022-06-11 15:10:10 +09:00
const issues = JSON.parse(data) as Issue[]
const table = new Map<string, Issue[]>();
issues.forEach((x)=>{
const category = x.title.split(":")[0];
if(!category) return;
let c = table.get(category)
if(!c){
c = [];
table.set(category,c);
}
c.push(x);
2022-06-11 16:58:08 +09:00
});
2022-06-11 15:10:10 +09:00
const keys = Array.from(table.keys());
keys.forEach(x=>{
console.log(`\n### ${x}\n`);
const issues = table.get(x);
console.log("<table>");
console.log("<thead>");
console.log("<tr>");
//console.log("<th>Category</th>");
console.log("<th>ID</th>");
console.log("<th>Content</th>");
console.log("<th>Procedure</th>");
console.log("<th>Test Data</th>");
console.log("<th>P/F</th>");
console.log("</tr>");
console.log("</thead>");
console.log("<tbody>");
const ts = issues!.map(x=> testcase.filter(y=>y.id==x.number)).flat() as Testcase[];
if(ts?.length == 0) return;
//console.log(`<tr><th rowspan="${ts?.length}">${x}</th>`);
ts.forEach((y,i)=>{
//if(i>0)
console.log("<tr>");
const id = y.subId ? `${y.id}-${y.subId}` : y.id;
console.log(`<td>${id}</td>`);
console.log(`<td>${y.content}</td>`);
console.log(`<td>${y.procedure}</td>`);
console.log(`<td>${y.testData ?? ""}</td>`);
console.log(`<td>${y.pass ? "P" : "F"}</td>`);
console.log("</tr>");
})
console.log("</tbody>");
console.log("</table>");
})