-
Notifications
You must be signed in to change notification settings - Fork 2
/
coverage-summary.ts
84 lines (71 loc) · 3.3 KB
/
coverage-summary.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/******************************************************************************
*
* Copyright (c) 2019-2023 Fraunhofer IOSB-INA Lemgo,",
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft",
* zur Foerderung der angewandten Forschung e.V.",
*
*****************************************************************************/
import { readFileSync } from 'fs';
main();
function main() {
const aasCoreSummary = read('./reports/aas-core/coverage-summary.json');
const aasServerSummary = read('./reports/aas-server/coverage-summary.json');
const aasLibSummary = read('./reports/aas-lib/coverage-summary.json');
const aasPortalSummary = read('./reports/aas-portal/coverage-summary.json');
const statementsTotal =
aasCoreSummary.total.statements.total +
aasServerSummary.total.statements.total +
aasLibSummary.total.statements.total +
aasPortalSummary.total.statements.total;
const statementsCovered =
aasCoreSummary.total.statements.covered +
aasServerSummary.total.statements.covered +
aasLibSummary.total.statements.covered +
aasPortalSummary.total.statements.covered;
const branchesTotal =
aasCoreSummary.total.branches.total +
aasServerSummary.total.branches.total +
aasLibSummary.total.branches.total +
aasPortalSummary.total.branches.total;
const branchesCovered =
aasCoreSummary.total.branches.covered +
aasServerSummary.total.branches.covered +
aasLibSummary.total.branches.covered +
aasPortalSummary.total.branches.covered;
const functionsTotal =
aasCoreSummary.total.functions.total +
aasServerSummary.total.functions.total +
aasLibSummary.total.functions.total +
aasPortalSummary.total.functions.total;
const functionsCovered =
aasCoreSummary.total.functions.covered +
aasServerSummary.total.functions.covered +
aasLibSummary.total.functions.covered +
aasPortalSummary.total.functions.covered;
const total =
aasCoreSummary.total.lines.total +
aasServerSummary.total.lines.total +
aasLibSummary.total.lines.total +
aasPortalSummary.total.lines.total;
const covered =
aasCoreSummary.total.lines.covered +
aasServerSummary.total.lines.covered +
aasLibSummary.total.lines.covered +
aasPortalSummary.total.lines.covered;
console.info('=============================== Coverage summary ===============================');
console.info(
`Statements : ${((statementsCovered / statementsTotal) * 100).toFixed(2)}% ( ${statementsCovered}/${statementsTotal} )`,
);
console.info(
`Branches : ${((branchesCovered / branchesTotal) * 100).toFixed(2)}% ( ${branchesCovered}/${branchesTotal} )`,
);
console.info(
`Functions : ${((functionsCovered / functionsTotal) * 100).toFixed(2)}% ( ${functionsCovered}/${functionsTotal} )`,
);
console.info(`Lines : ${((covered / total) * 100).toFixed(2)}% ( ${covered}/${total} )`);
console.info('================================================================================');
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function read(path: string): any {
return JSON.parse(readFileSync(path).toString());
}