forked from eclipse-thingweb/playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkCoverage.js
56 lines (51 loc) · 1.68 KB
/
checkCoverage.js
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
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and
* Document License (2015-05-13) which is available at
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document.
*
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
*/
/**
* Outputs statistics about a given assertion report
* @param {object} jsonResults assertion reports
* @param {Function} logFunc function to log the stats
*/
async function checkCoverage(jsonResults, logFunc) {
if (logFunc === undefined) {
logFunc = console.log;
}
let passCount = 0;
let failCount = 0;
let nullCount = 0;
let notImplCount = 0;
let totalCount = 0;
jsonResults = await jsonResults;
jsonResults.forEach((curResult) => {
if (curResult.Status === "fail") {
failCount++;
}
if (curResult.Status === "pass") {
passCount++;
}
if (curResult.Status === "null") {
nullCount++;
}
if (curResult.Status === "not-impl") {
notImplCount++;
}
totalCount++;
});
logFunc("Failed Assertions:", failCount);
logFunc("Not-Implemented Assertions:", notImplCount);
logFunc("Not Tested Assertions:", nullCount);
logFunc("Passed Assertions:", passCount);
logFunc("Total Assertions", totalCount);
}
module.exports = checkCoverage;