@@ -70,12 +70,33 @@ function parseOptions(args) {
7070 return null ;
7171}
7272
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+ } ;
7595}
7696
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 ;
79100}
80101
81102async function main ( argv ) {
@@ -129,32 +150,36 @@ async function main(argv) {
129150 console . log ( `Running ${ files . length } rustdoc-gui tests...` ) ;
130151 process . setMaxListeners ( files . length + 1 ) ;
131152 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 ) ;
135159 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 ) ;
137162 tests . push (
138163 runTest ( testPath , options )
139164 . then ( out => {
140165 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 ,
143168 output : output ,
144- } ;
169+ } ) ;
145170 if ( nb_failures > 0 ) {
146- print_test_erroneous ( )
171+ status_bar . erroneous ( )
147172 failed = true ;
148173 } else {
149- print_test_successful ( )
174+ status_bar . successful ( )
150175 }
151176 } )
152177 . catch ( err => {
153- results [ i ] = {
154- status : RUN_ERRORED ,
178+ results . errored . push ( {
179+ file_name : file_name ,
155180 output : err ,
156- } ;
157- print_test_erroneous ( ) ;
181+ } ) ;
182+ status_bar . erroneous ( ) ;
158183 failed = true ;
159184 } )
160185 ) ;
@@ -166,28 +191,20 @@ async function main(argv) {
166191 // final \n after the tests
167192 console . log ( "\n" ) ;
168193
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 ) ;
185203 } ) ;
186204 // 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 ) ;
191208 } ) ;
192209
193210 if ( failed ) {
0 commit comments