| 1 |
'use strict' |
| 2 |
|
| 3 |
const result = require('./reports/clients/index.json').undici |
| 4 |
|
| 5 |
const failOnError = process.env.FAIL_ON_ERROR === 'true' |
| 6 |
let runFailed = false |
| 7 |
|
| 8 |
let okTests = 0 |
| 9 |
let failedTests = 0 |
| 10 |
let nonStrictTests = 0 |
| 11 |
let wrongCodeTests = 0 |
| 12 |
let uncleanTests = 0 |
| 13 |
let failedByClientTests = 0 |
| 14 |
let informationalTests = 0 |
| 15 |
let unimplementedTests = 0 |
| 16 |
|
| 17 |
let totalTests = 0 |
| 18 |
|
| 19 |
function testCaseIdToWeight (testCaseId) { |
| 20 |
const [major, minor, sub] = testCaseId.split('.') |
| 21 |
return sub |
| 22 |
? parseInt(major, 10) * 10000 + parseInt(minor, 10) * 100 + parseInt(sub, 10) |
| 23 |
: parseInt(major, 10) * 10000 + parseInt(minor, 10) * 100 |
| 24 |
} |
| 25 |
|
| 26 |
function isFailedTestCase (testCase) { |
| 27 |
return ( |
| 28 |
testCase.behavior === 'FAILED' || |
| 29 |
testCase.behavior === 'WRONG CODE' || |
| 30 |
testCase.behavior === 'UNCLEAN' || |
| 31 |
testCase.behavior === 'FAILED BY CLIENT' || |
| 32 |
testCase.behaviorClose === 'FAILED' || |
| 33 |
testCase.behaviorClose === 'WRONG CODE' || |
| 34 |
testCase.behaviorClose === 'UNCLEAN' || |
| 35 |
testCase.behaviorClose === 'FAILED BY CLIENT' |
| 36 |
) |
| 37 |
} |
| 38 |
|
| 39 |
const keys = Object.keys(result).sort((a, b) => { |
| 40 |
a = testCaseIdToWeight(a) |
| 41 |
b = testCaseIdToWeight(b) |
| 42 |
return a - b |
| 43 |
}) |
| 44 |
|
| 45 |
const reorderedResult = {} |
| 46 |
for (const key of keys) { |
| 47 |
reorderedResult[key] = result[key] |
| 48 |
delete reorderedResult[key].reportfile |
| 49 |
|
| 50 |
totalTests++ |
| 51 |
|
| 52 |
if ( |
| 53 |
failOnError && |
| 54 |
!runFailed && |
| 55 |
isFailedTestCase(result[key]) |
| 56 |
) { |
| 57 |
runFailed = true |
| 58 |
} |
| 59 |
|
| 60 |
switch (result[key].behavior) { |
| 61 |
case 'OK': |
| 62 |
okTests++ |
| 63 |
break |
| 64 |
case 'FAILED': |
| 65 |
failedTests++ |
| 66 |
break |
| 67 |
case 'NON-STRICT': |
| 68 |
nonStrictTests++ |
| 69 |
break |
| 70 |
case 'WRONG CODE': |
| 71 |
wrongCodeTests++ |
| 72 |
break |
| 73 |
case 'UNCLEAN': |
| 74 |
uncleanTests++ |
| 75 |
break |
| 76 |
case 'FAILED BY CLIENT': |
| 77 |
failedByClientTests++ |
| 78 |
break |
| 79 |
case 'INFORMATIONAL': |
| 80 |
informationalTests++ |
| 81 |
break |
| 82 |
case 'UNIMPLEMENTED': |
| 83 |
unimplementedTests++ |
| 84 |
break |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
console.log('Autobahn Test Report\n\nSummary:') |
| 89 |
|
| 90 |
console.table({ |
| 91 |
OK: okTests, |
| 92 |
Failed: failedTests, |
| 93 |
'Non-Strict': nonStrictTests, |
| 94 |
'Wrong Code': wrongCodeTests, |
| 95 |
Unclean: uncleanTests, |
| 96 |
'Failed By Client': failedByClientTests, |
| 97 |
Informational: informationalTests, |
| 98 |
Unimplemented: unimplementedTests, |
| 99 |
Total: totalTests |
| 100 |
}) |
| 101 |
|
| 102 |
console.log('Details:') |
| 103 |
|
| 104 |
console.table(reorderedResult) |
| 105 |
|
| 106 |
process.exitCode = runFailed ? 1 : 0 |