2
2
3
3
const result = require ( './reports/clients/index.json' ) . undici
4
4
5
+ const failOnError = process . env . FAIL_ON_ERROR === 'true'
6
+ const reporter = process . env . REPORTER || 'table'
7
+ let runFailed = false
8
+
9
+ let okTests = 0
10
+ let failedTests = 0
11
+ let nonStrictTests = 0
12
+ let wrongCodeTests = 0
13
+ let uncleanTests = 0
14
+ let failedByClientTests = 0
15
+ let informationalTests = 0
16
+ let unimplementedTests = 0
17
+
18
+ let totalTests = 0
19
+
5
20
function testCaseIdToWeight ( testCaseId ) {
6
21
const [ major , minor , sub ] = testCaseId . split ( '.' )
7
22
return sub
8
23
? parseInt ( major , 10 ) * 10000 + parseInt ( minor , 10 ) * 100 + parseInt ( sub , 10 )
9
24
: parseInt ( major , 10 ) * 10000 + parseInt ( minor , 10 ) * 100
10
25
}
11
26
27
+ function isFailedTestCase ( testCase ) {
28
+ return (
29
+ testCase . behavior === 'FAILED' ||
30
+ testCase . behavior === 'WRONG CODE' ||
31
+ testCase . behavior === 'UNCLEAN' ||
32
+ testCase . behavior === 'FAILED BY CLIENT' ||
33
+ testCase . behaviorClose === 'FAILED' ||
34
+ testCase . behaviorClose === 'WRONG CODE' ||
35
+ testCase . behaviorClose === 'UNCLEAN' ||
36
+ testCase . behaviorClose === 'FAILED BY CLIENT'
37
+ )
38
+ }
39
+
12
40
const keys = Object . keys ( result ) . sort ( ( a , b ) => {
13
41
a = testCaseIdToWeight ( a )
14
42
b = testCaseIdToWeight ( b )
@@ -18,6 +46,97 @@ const keys = Object.keys(result).sort((a, b) => {
18
46
const reorderedResult = { }
19
47
for ( const key of keys ) {
20
48
reorderedResult [ key ] = result [ key ]
49
+ delete reorderedResult [ key ] . reportfile
50
+
51
+ totalTests ++
52
+
53
+ if (
54
+ failOnError &&
55
+ ! runFailed &&
56
+ isFailedTestCase ( result [ key ] )
57
+ ) {
58
+ runFailed = true
59
+ }
60
+
61
+ switch ( result [ key ] . behavior ) {
62
+ case 'OK' :
63
+ okTests ++
64
+ break
65
+ case 'FAILED' :
66
+ failedTests ++
67
+ break
68
+ case 'NON-STRICT' :
69
+ nonStrictTests ++
70
+ break
71
+ case 'WRONG CODE' :
72
+ wrongCodeTests ++
73
+ break
74
+ case 'UNCLEAN' :
75
+ uncleanTests ++
76
+ break
77
+ case 'FAILED BY CLIENT' :
78
+ failedByClientTests ++
79
+ break
80
+ case 'INFORMATIONAL' :
81
+ informationalTests ++
82
+ break
83
+ case 'UNIMPLEMENTED' :
84
+ unimplementedTests ++
85
+ break
86
+ }
87
+ }
88
+
89
+ if (
90
+ reporter === 'table'
91
+ ) {
92
+ console . log ( 'Autobahn Test Report\n\nSummary:' )
93
+
94
+ console . table ( {
95
+ OK : okTests ,
96
+ Failed : failedTests ,
97
+ 'Non-Strict' : nonStrictTests ,
98
+ 'Wrong Code' : wrongCodeTests ,
99
+ Unclean : uncleanTests ,
100
+ 'Failed By Client' : failedByClientTests ,
101
+ Informational : informationalTests ,
102
+ Unimplemented : unimplementedTests ,
103
+ 'Total Tests' : totalTests
104
+ } )
105
+
106
+ console . log ( 'Details:' )
107
+
108
+ console . table ( reorderedResult )
109
+ }
110
+
111
+ if ( reporter === 'markdown' ) {
112
+ console . log ( `## Autobahn Test Report
113
+
114
+ ### Summary
115
+
116
+ | Type | Count |
117
+ |---|---|
118
+ | OK | ${ okTests } |
119
+ | Failed | ${ failedTests } |
120
+ | Non-Strict | ${ nonStrictTests } |
121
+ | Wrong Code | ${ wrongCodeTests } |
122
+ | Unclean | ${ uncleanTests } |
123
+ | Failed By Client | ${ failedByClientTests } |
124
+ | Informational | ${ informationalTests } |
125
+ | Unimplemented | ${ unimplementedTests } |
126
+ | Total Tests | ${ totalTests } |
127
+
128
+ <details>
129
+ <summary>Details</summary>
130
+
131
+ | Test Case | Behavior | Close Behavior | Duration | Remote Close Code |
132
+ |---|---|---|---|---|
133
+ ${ keys . map ( key => {
134
+ const testCase = reorderedResult [ key ]
135
+ return `| ${ key } | ${ testCase . behavior } | ${ testCase . behaviorClose } | ${ testCase . duration } | ${ testCase . remoteCloseCode } |`
136
+ } ) . join ( '\n' ) }
137
+
138
+ </details>
139
+ ` )
21
140
}
22
141
23
- console . table ( reorderedResult )
142
+ process . exit ( runFailed ? 1 : 0 )
0 commit comments