@@ -17,6 +17,11 @@ function showHelp() {
1717 console . log ( " --no-headless : disable headless mode" ) ;
1818 console . log ( " --help : show this message then quit" ) ;
1919 console . log ( " --tests-folder [PATH] : location of the .GOML tests folder" ) ;
20+ console . log ( " --jobs [NUMBER] : number of threads to run tests on" ) ;
21+ }
22+
23+ function isNumeric ( s ) {
24+ return / ^ \d + $ / . test ( s ) ;
2025}
2126
2227function parseOptions ( args ) {
@@ -27,6 +32,7 @@ function parseOptions(args) {
2732 "debug" : false ,
2833 "show_text" : false ,
2934 "no_headless" : false ,
35+ "jobs" : - 1 ,
3036 } ;
3137 var correspondances = {
3238 "--doc-folder" : "doc_folder" ,
@@ -39,13 +45,21 @@ function parseOptions(args) {
3945 for ( var i = 0 ; i < args . length ; ++ i ) {
4046 if ( args [ i ] === "--doc-folder"
4147 || args [ i ] === "--tests-folder"
42- || args [ i ] === "--file" ) {
48+ || args [ i ] === "--file"
49+ || args [ i ] === "--jobs" ) {
4350 i += 1 ;
4451 if ( i >= args . length ) {
4552 console . log ( "Missing argument after `" + args [ i - 1 ] + "` option." ) ;
4653 return null ;
4754 }
48- if ( args [ i - 1 ] !== "--file" ) {
55+ if ( args [ i - 1 ] === "--jobs" ) {
56+ if ( ! isNumeric ( args [ i ] ) ) {
57+ console . log (
58+ "`--jobs` option expects a positive number, found `" + args [ i ] + "`" ) ;
59+ return null ;
60+ }
61+ opts [ "jobs" ] = parseInt ( args [ i ] ) ;
62+ } else if ( args [ i - 1 ] !== "--file" ) {
4963 opts [ correspondances [ args [ i - 1 ] ] ] = args [ i ] ;
5064 } else {
5165 opts [ "files" ] . push ( args [ i ] ) ;
@@ -158,7 +172,11 @@ async function main(argv) {
158172 files . sort ( ) ;
159173
160174 console . log ( `Running ${ files . length } rustdoc-gui tests...` ) ;
161- process . setMaxListeners ( files . length + 1 ) ;
175+ if ( opts [ "jobs" ] < 1 ) {
176+ process . setMaxListeners ( files . length + 1 ) ;
177+ } else {
178+ process . setMaxListeners ( opts [ "jobs" ] ) ;
179+ }
162180 let tests = [ ] ;
163181 let results = {
164182 successful : [ ] ,
0 commit comments