@@ -70,12 +70,33 @@ function parseOptions(args) {
70
70
return null ;
71
71
}
72
72
73
- function print_test_successful ( ) {
74
- process . stdout . write ( "." ) ;
73
+ /// Print single char status information without \n
74
+ function char_printer ( n_tests ) {
75
+ const max_per_line = 10 ;
76
+ let current = 0 ;
77
+ return {
78
+ successful : function ( ) {
79
+ current += 1 ;
80
+ if ( current % max_per_line === 0 ) {
81
+ process . stdout . write ( `. (${ current } /${ n_tests } )\n` ) ;
82
+ } else {
83
+ process . stdout . write ( "." ) ;
84
+ }
85
+ } ,
86
+ erroneous : function ( ) {
87
+ current += 1 ;
88
+ if ( current % max_per_line === 0 ) {
89
+ process . stderr . write ( `F (${ current } /${ n_tests } )\n` ) ;
90
+ } else {
91
+ process . stderr . write ( "F" ) ;
92
+ }
93
+ } ,
94
+ } ;
75
95
}
76
96
77
- function print_test_erroneous ( ) {
78
- process . stderr . write ( "F" ) ;
97
+ /// Sort array by .file_name property
98
+ function by_filename ( a , b ) {
99
+ return a . file_name - b . file_name ;
79
100
}
80
101
81
102
async function main ( argv ) {
@@ -129,32 +150,36 @@ async function main(argv) {
129
150
console . log ( `Running ${ files . length } rustdoc-gui tests...` ) ;
130
151
process . setMaxListeners ( files . length + 1 ) ;
131
152
let tests = [ ] ;
132
- let results = new Array ( files . length ) ;
133
- // poormans enum
134
- const RUN_SUCCESS = 42 , RUN_FAILED = 23 , RUN_ERRORED = 13 ;
153
+ let results = {
154
+ successful : [ ] ,
155
+ failed : [ ] ,
156
+ errored : [ ] ,
157
+ } ;
158
+ const status_bar = char_printer ( files . length ) ;
135
159
for ( let i = 0 ; i < files . length ; ++ i ) {
136
- const testPath = path . join ( opts [ "tests_folder" ] , files [ i ] ) ;
160
+ const file_name = files [ i ] ;
161
+ const testPath = path . join ( opts [ "tests_folder" ] , file_name ) ;
137
162
tests . push (
138
163
runTest ( testPath , options )
139
164
. then ( out => {
140
165
const [ output , nb_failures ] = out ;
141
- results [ i ] = {
142
- status : nb_failures === 0 ? RUN_SUCCESS : RUN_FAILED ,
166
+ results [ nb_failures === 0 ? "successful" : "failed" ] . push ( {
167
+ file_name : file_name ,
143
168
output : output ,
144
- } ;
169
+ } ) ;
145
170
if ( nb_failures > 0 ) {
146
- print_test_erroneous ( )
171
+ status_bar . erroneous ( )
147
172
failed = true ;
148
173
} else {
149
- print_test_successful ( )
174
+ status_bar . successful ( )
150
175
}
151
176
} )
152
177
. catch ( err => {
153
- results [ i ] = {
154
- status : RUN_ERRORED ,
178
+ results . errored . push ( {
179
+ file_name : file_name ,
155
180
output : err ,
156
- } ;
157
- print_test_erroneous ( ) ;
181
+ } ) ;
182
+ status_bar . erroneous ( ) ;
158
183
failed = true ;
159
184
} )
160
185
) ;
@@ -166,28 +191,20 @@ async function main(argv) {
166
191
// final \n after the tests
167
192
console . log ( "\n" ) ;
168
193
169
- results . forEach ( r => {
170
- switch ( r . status ) {
171
- case RUN_SUCCESS :
172
- if ( debug === false ) {
173
- break ;
174
- }
175
- case RUN_FAILED :
176
- console . log ( r . output ) ;
177
- break ;
178
- case RUN_ERRORED :
179
- // skip
180
- break ;
181
- default :
182
- console . error ( `unexpected status = ${ r . status } ` ) ;
183
- process . exit ( 4 ) ;
184
- }
194
+ if ( debug === false ) {
195
+ results . successful . sort ( by_filename ) ;
196
+ results . successful . forEach ( r => {
197
+ console . log ( r . output ) ;
198
+ } ) ;
199
+ }
200
+ results . failed . sort ( by_filename ) ;
201
+ results . failed . forEach ( r => {
202
+ console . log ( r . output ) ;
185
203
} ) ;
186
204
// print run errors on the bottom so developers see them better
187
- results . forEach ( r => {
188
- if ( r . status === RUN_ERRORED ) {
189
- console . error ( r . output ) ;
190
- }
205
+ results . errored . sort ( by_filename ) ;
206
+ results . errored . forEach ( r => {
207
+ console . error ( r . output ) ;
191
208
} ) ;
192
209
193
210
if ( failed ) {
0 commit comments