Skip to content

Commit c63e995

Browse files
authored
Merge pull request #82 from ReactiveBayes/81-select-test-files-using-make-test-test_args
Parallelize make test. #81 Add make test test_args= filter.
2 parents 3cdae9a + ad07d23 commit c63e995

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ julia = "1.10"
4747
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
4848
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
4949
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
50+
Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
5051
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
5152
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
5253
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
@@ -57,4 +58,4 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
5758
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5859

5960
[targets]
60-
test = ["Test", "Aqua", "BenchmarkTools", "Plots", "Printf", "ForwardDiff", "Manifolds", "ReTestItems", "RollingFunctions", "JET", "StableRNGs"]
61+
test = ["Test", "Aqua", "BenchmarkTools", "Hwloc", "Plots", "Printf", "ForwardDiff", "Manifolds", "ReTestItems", "RollingFunctions", "JET", "StableRNGs"]

test/runtests.jl

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
1-
using ExponentialFamilyProjection, Test, ReTestItems, Random
1+
using Aqua, Hwloc, ReTestItems, ExponentialFamilyProjection, Random
22

33
# Set the random seed for reproducibility of kl-divergence tests
44
Random.seed!(42)
55

6-
runtests(ExponentialFamilyProjection; memory_threshold = 1.0)
6+
if get(ENV, "RUN_AQUA", "true") == "true"
7+
Aqua.test_all(ExponentialFamilyProjection; ambiguities = false, piracies = false, deps_compat = (; check_extras = false, check_weakdeps = true))
8+
end
9+
10+
nthreads, ncores = Hwloc.num_virtual_cores(), Hwloc.num_physical_cores()
11+
nthreads, ncores = max(nthreads, 1), max(ncores, 1)
12+
nworker_threads = Int(nthreads / ncores)
13+
memory_threshold = 1.0
14+
15+
pkg_root = dirname(pathof(ExponentialFamilyProjection)) |> dirname
16+
test_root = joinpath(pkg_root, "test")
17+
18+
if isempty(ARGS)
19+
runtests(ExponentialFamilyProjection; nworkers = ncores, nworker_threads = nworker_threads, memory_threshold = memory_threshold)
20+
else
21+
for arg in ARGS
22+
# Translate colon syntax (e.g., rules:normal_mean_variance → rules/normal_mean_variance)
23+
candidate = join(split(arg, ":"), "/")
24+
25+
# Build possible test paths relative to the package test directory
26+
paths = [joinpath(test_root, candidate), joinpath(test_root, candidate * ".jl")]
27+
28+
path = findfirst(ispath, paths)
29+
30+
if path !== nothing
31+
selected_path = paths[path]
32+
@info "Running selective tests from $selected_path"
33+
runtests(selected_path; nworkers = ncores, nworker_threads = nworker_threads, memory_threshold = memory_threshold)
34+
else
35+
@warn "Test target not found: $arg"
36+
end
37+
end
38+
end

0 commit comments

Comments
 (0)