@@ -200,6 +200,19 @@ function runtest(::Type{TestRecord}, f, name)
200200    return  res
201201end 
202202
203+ #  This is an internal function, not to be used by end users.  The keyword
204+ #  arguments are only for testing purposes.
205+ """ 
206+     default_njobs() 
207+ 
208+ Determine default number of parallel jobs. 
209+ """ 
210+ function  default_njobs (; cpu_threads =  Sys. CPU_THREADS, free_memory =  Sys. free_memory ())
211+     jobs =  cpu_threads
212+     memory_jobs =  Int64 (free_memory) ÷  (2  *  2 ^ 30 )
213+     return  max (1 , min (jobs, memory_jobs))
214+ end 
215+ 
203216function  runtests (ARGS , testfilter =  _ ->  true , RecordType =  TestRecord)
204217    do_help, _ =  extract_flag! (ARGS , " --help"  )
205218    if  do_help
@@ -211,7 +224,7 @@ function runtests(ARGS, testfilter = _ -> true, RecordType = TestRecord)
211224               --list             List all available tests. 
212225               --verbose          Print more information during testing. 
213226               --quickfail        Fail the entire run as soon as a single test errored. 
214-                --jobs=N           Launch `N` processes to perform tests (default: Sys.CPU_THREADS ). 
227+                --jobs=N           Launch `N` processes to perform tests (default: $( default_njobs ())  ). 
215228
216229               Remaining arguments filter the tests that will be executed."""  
217230        )
@@ -288,9 +301,7 @@ function runtests(ARGS, testfilter = _ -> true, RecordType = TestRecord)
288301
289302    #  determine parallelism
290303    if  ! set_jobs
291-         jobs =  Sys. CPU_THREADS
292-         memory_jobs =  Int64 (Sys. free_memory ()) ÷  (2  *  2 ^ 30 )
293-         jobs =  max (1 , min (jobs, memory_jobs))
304+         jobs =  default_njobs ()
294305    end 
295306    @info  " Running $jobs  tests in parallel. If this is too many, specify the `--jobs` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable." 
296307
0 commit comments