@@ -70,6 +70,14 @@ function parseOptions(args) {
7070 return null ;
7171}
7272
73+ function print_test_successful ( ) {
74+ process . stdout . write ( "." ) ;
75+ }
76+ function print_test_erroneous ( ) {
77+ // Bold Red "F" Reset
78+ process . stdout . write ( "\033[1m\x1b[31mF\x1b[0m" ) ;
79+ }
80+
7381async function main ( argv ) {
7482 let opts = parseOptions ( argv . slice ( 2 ) ) ;
7583 if ( opts === null ) {
@@ -100,27 +108,48 @@ async function main(argv) {
100108
101109 let failed = false ;
102110 let files ;
111+ let tests = [ ] ;
103112 if ( opts [ "files" ] . length === 0 ) {
104113 files = fs . readdirSync ( opts [ "tests_folder" ] ) . filter ( file => path . extname ( file ) == ".goml" ) ;
105114 } else {
106115 files = opts [ "files" ] . filter ( file => path . extname ( file ) == ".goml" ) ;
107116 }
108-
117+ if ( files . length === 0 ) {
118+ console . log ( "rustdoc-gui: No test selected" ) ;
119+ process . exit ( 2 ) ;
120+ }
109121 files . sort ( ) ;
122+
123+ console . log ( `running ${ files . length } rustdoc-gui tests` ) ;
124+ process . setMaxListeners ( files . length + 1 ) ;
110125 for ( var i = 0 ; i < files . length ; ++ i ) {
111126 const testPath = path . join ( opts [ "tests_folder" ] , files [ i ] ) ;
112- await runTest ( testPath , options ) . then ( out => {
127+ tests . push ( runTest ( testPath , options ) ) ;
128+ }
129+
130+ let error_outputs = "" ;
131+ let failed_outputs = "" ;
132+ for ( var i = 0 ; i < tests . length ; ++ i ) {
133+ await tests [ i ] . then ( out => {
113134 const [ output , nb_failures ] = out ;
114- console . log ( output ) ;
115135 if ( nb_failures > 0 ) {
136+ failed_outputs += output + "\n" ;
137+ print_test_erroneous ( )
116138 failed = true ;
139+ } else {
140+ print_test_successful ( )
117141 }
118142 } ) . catch ( err => {
119- console . error ( err ) ;
143+ error_outputs += err + "\n" ;
144+ print_test_erroneous ( ) ;
120145 failed = true ;
121146 } ) ;
122147 }
148+ console . log ( "" )
149+
123150 if ( failed ) {
151+ console . log ( failed_outputs ) ;
152+ console . error ( error_outputs ) ;
124153 process . exit ( 1 ) ;
125154 }
126155}
0 commit comments