File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1717[compat ]
1818Dates = " 1"
1919IOCapture = " 0.2.5"
20- Malt = " 1.2.1 "
20+ Malt = " 1.3.0 "
2121Printf = " 1"
2222Random = " 1"
2323Scratch = " 1.3.0"
Original file line number Diff line number Diff line change @@ -414,15 +414,36 @@ worker_id(wrkr) = WORKER_IDS[wrkr.proc_pid]
414414Add `X` worker processes.
415415"""
416416addworkers (X; kwargs... ) = [addworker (; kwargs... ) for _ in 1 : X]
417- function addworker (; env= Vector {Pair{String, String}} ())
417+
418+ """
419+ addworker(; env=Vector{Pair{String, String}}())
420+
421+ Add a single worker process.
422+
423+ ## Arguments
424+ - `env`: Vector of environment variable pairs to set for the worker process.
425+ - `exename`: Custom executable to use for the worker process.
426+ - `exeflags`: Custom flags to pass to the worker process.
427+ """
428+ function addworker (;
429+ env = Vector {Pair{String, String}} (),
430+ exename = nothing , exeflags = nothing
431+ )
418432 exe = test_exe ()
419- exeflags = exe[2 : end ]
433+ if exename === nothing
434+ exename = exe[1 ]
435+ end
436+ if exeflags != = nothing
437+ exeflags = vcat (exe[2 : end ], exeflags)
438+ else
439+ exeflags = exe[2 : end ]
440+ end
420441
421442 push! (env, " JULIA_NUM_THREADS" => " 1" )
422443 # Malt already sets OPENBLAS_NUM_THREADS to 1
423444 push! (env, " OPENBLAS_NUM_THREADS" => " 1" )
424445
425- wrkr = Malt. Worker (;exeflags, env)
446+ wrkr = Malt. Worker (; exename, exeflags, env)
426447 WORKER_IDS[wrkr. proc_pid] = length (WORKER_IDS) + 1
427448 return wrkr
428449end
Original file line number Diff line number Diff line change 6868 function test_worker (name)
6969 if name == " needs env var"
7070 return addworker (env = [" SPECIAL_ENV_VAR" => " 42" ])
71+ elseif name == " threads/2"
72+ return addworker (exeflags = [" --threads=2" ])
7173 end
7274 return nothing
7375 end
7779 end ,
7880 " doesn't need env var" => quote
7981 @test ! haskey (ENV , " SPECIAL_ENV_VAR" )
82+ end ,
83+ " threads/1" => quote
84+ @test Base. Threads. nthreads () == 1
85+ end ,
86+ " threads/2" => quote
87+ @test Base. Threads. nthreads () == 2
8088 end
8189 )
8290
8694 str = String (take! (io))
8795 @test contains (str, r" needs env var .+ started at" )
8896 @test contains (str, r" doesn't need env var .+ started at" )
97+ @test contains (str, r" threads/1 .+ started at" )
98+ @test contains (str, r" threads/2 .+ started at" )
8999 @test contains (str, " SUCCESS" )
90100end
91101
You can’t perform that action at this time.
0 commit comments