-
Notifications
You must be signed in to change notification settings - Fork 596
Expand file tree
/
Copy pathparse-results.js
More file actions
executable file
·164 lines (140 loc) · 5.1 KB
/
Copy pathparse-results.js
File metadata and controls
executable file
·164 lines (140 loc) · 5.1 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
function parseResults() {
const resultsPath = path.join(__dirname, 'reports', 'servers', 'index.json');
if (!fs.existsSync(resultsPath)) {
console.error('Results file not found:', resultsPath);
process.exit(1);
}
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
if (!results || Object.keys(results).length === 0) {
console.error('Results file is empty or invalid.');
process.exit(1);
}
// Get the first (and presumably only) server implementation
const serverName = Object.keys(results)[0];
const testResults = results[serverName];
console.log(`\n=== Autobahn Test Suite Results for ${serverName} ===\n`);
const summary = {
total: 0,
ok: 0,
failed: 0,
nonStrict: 0,
unimplemented: 0,
informational: 0,
failedTests: [],
nonStrictTests: [],
unimplementedTests: [],
informationalTests: []
};
// Parse each test case
for (const [testCase, result] of Object.entries(testResults)) {
summary.total++;
const behavior = result.behavior;
const behaviorClose = result.behaviorClose;
if (behavior === 'OK' && behaviorClose === 'OK') {
summary.ok++;
} else if (behavior === 'UNIMPLEMENTED') {
summary.unimplemented++;
summary.unimplementedTests.push({
case: testCase,
behavior,
behaviorClose,
duration: result.duration
});
} else if (behavior === 'NON-STRICT') {
summary.nonStrict++;
summary.nonStrictTests.push({
case: testCase,
behavior,
behaviorClose,
duration: result.duration
});
} else if (behavior === 'INFORMATIONAL') {
summary.informational++;
summary.informationalTests.push({
case: testCase,
behavior,
behaviorClose,
duration: result.duration,
remoteCloseCode: result.remoteCloseCode
});
} else {
summary.failed++;
summary.failedTests.push({
case: testCase,
behavior,
behaviorClose,
duration: result.duration,
remoteCloseCode: result.remoteCloseCode
});
}
}
// Print summary
console.log('Test Summary:');
console.log(` Total tests: ${summary.total}`);
console.log(` Required tests: ${summary.total - summary.unimplemented}`);
console.log(` Optional tests: ${summary.unimplemented}`);
console.log(` Passed (OK): ${summary.ok}`);
console.log(` Failed: ${summary.failed}`);
console.log(` Non-Strict: ${summary.nonStrict}`);
console.log(` Informational: ${summary.informational}`);
// Pass rate excludes optional, non-strict, and informational tests
const strictRequired = summary.total - summary.unimplemented - summary.nonStrict - summary.informational;
const passRate = strictRequired > 0
? ((summary.ok / strictRequired) * 100).toFixed(1)
: '0.0';
console.log(` Pass rate: ${passRate}%`);
// Print failed tests if any
if (summary.failedTests.length > 0) {
console.log('\n=== FAILED TESTS ===');
summary.failedTests.forEach(test => {
console.log(` ${test.case}: behavior=${test.behavior}, behaviorClose=${test.behaviorClose}, closeCode=${test.remoteCloseCode}`);
});
}
// Print non-strict tests if any
if (summary.nonStrictTests.length > 0) {
console.log('\n=== NON-STRICT TESTS (Informational) ===');
summary.nonStrictTests.forEach(test => {
console.log(` ${test.case}: behavior=${test.behavior}, behaviorClose=${test.behaviorClose}`);
});
}
// Print informational tests if any
if (summary.informationalTests.length > 0) {
console.log('\n=== INFORMATIONAL TESTS (Not failures) ===');
summary.informationalTests.forEach(test => {
console.log(` ${test.case}: behavior=${test.behavior}, behaviorClose=${test.behaviorClose}, closeCode=${test.remoteCloseCode}`);
});
}
// Print unimplemented tests summary (grouped by major version)
if (summary.unimplementedTests.length > 0) {
console.log('\n=== OPTIONAL FEATURES NOT IMPLEMENTED (Informational) ===');
// Group by major test category
const unimplementedByCategory = {};
summary.unimplementedTests.forEach(test => {
const majorCategory = test.case.split('.')[0];
if (!unimplementedByCategory[majorCategory]) {
unimplementedByCategory[majorCategory] = [];
}
unimplementedByCategory[majorCategory].push(test.case);
});
for (const [category, tests] of Object.entries(unimplementedByCategory)) {
console.log(` Category ${category}: ${tests.length} tests`);
console.log(` Cases: ${tests.join(', ')}`);
}
}
console.log('\n');
// Exit with error code if there are actual failures
if (summary.failed > 0) {
console.error(`❌ ${summary.failed} test(s) failed!`);
process.exit(1);
} else {
console.log(`✅ All tests passed! (${summary.ok} OK, ${summary.nonStrict} non-strict, ${summary.informational} informational, ${summary.unimplemented} unimplemented)`);
}
return summary;
}
if (require.main === module) {
parseResults();
}
module.exports = { parseResults };