Skip to content

Commit 0f1db98

Browse files
authored
Merge pull request #515 from JuliaParallel/test-procs
Add option to the tests for setting the number of workers
2 parents f292c49 + c25f732 commit 0f1db98

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: test/runtests.jl

+15-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ tests = [
2424
#("Fault Tolerance", "fault-tolerance.jl"),
2525
]
2626
all_test_names = map(test -> replace(last(test), ".jl"=>""), tests)
27+
additional_workers::Int = 3
28+
2729
if PROGRAM_FILE != "" && realpath(PROGRAM_FILE) == @__FILE__
2830
pushfirst!(LOAD_PATH, @__DIR__)
2931
pushfirst!(LOAD_PATH, joinpath(@__DIR__, ".."))
@@ -41,8 +43,13 @@ if PROGRAM_FILE != "" && realpath(PROGRAM_FILE) == @__FILE__
4143
"-s", "--simulate"
4244
action = :store_true
4345
help = "Don't actually run the tests"
46+
"-p", "--procs"
47+
arg_type = Int
48+
default = additional_workers
49+
help = "How many additional workers to launch"
4450
end
4551
end
52+
4653
parsed_args = parse_args(s)
4754
to_test = String[]
4855
for test in parsed_args["test"]
@@ -64,16 +71,23 @@ if PROGRAM_FILE != "" && realpath(PROGRAM_FILE) == @__FILE__
6471
exit(1)
6572
end
6673
end
74+
6775
@info "Running tests: $(join(to_test, ", "))"
6876
parsed_args["simulate"] && exit(0)
77+
78+
additional_workers = parsed_args["procs"]
6979
else
7080
to_test = all_test_names
7181
@info "Running all tests"
7282
end
7383

7484

7585
using Distributed
76-
addprocs(3; exeflags="--project=$(joinpath(@__DIR__, ".."))")
86+
if additional_workers > 0
87+
# We put this inside a branch because addprocs() takes a minimum of 1s to
88+
# complete even if doing nothing, which is annoying.
89+
addprocs(additional_workers; exeflags="--project=$(joinpath(@__DIR__, ".."))")
90+
end
7791

7892
include("imports.jl")
7993
include("util.jl")

0 commit comments

Comments
 (0)