Skip to content

Commit 8a03a1f

Browse files
committed
test: ensure fail on precompilation error
1 parent cbaf8c0 commit 8a03a1f

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

test/runtests.jl

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,41 @@
11
include("front_matter.jl")
22

3-
@testset "SymbolicRegression.jl" begin
4-
# Validate TEST_GROUP format
5-
if !occursin(r"^(unit|integration)/", TEST_GROUP)
6-
error("TEST_GROUP must start with 'unit/' or 'integration/', got: $(TEST_GROUP)")
7-
end
3+
if !occursin(r"^(unit|integration)/", TEST_GROUP)
4+
error("TEST_GROUP must start with 'unit/' or 'integration/', got: $(TEST_GROUP)")
5+
end
86

9-
# Check if this is an integration test
10-
if startswith(TEST_GROUP, "integration/")
11-
# Extract integration name (e.g., "integration/ad/zygote" -> "ad/zygote")
12-
integration_name = replace(TEST_GROUP, "integration/" => "")
13-
integration_dir = joinpath(@__DIR__, "integration", integration_name)
7+
if startswith(TEST_GROUP, "integration/")
8+
integration_name = replace(TEST_GROUP, "integration/" => "")
9+
integration_dir = joinpath(@__DIR__, "integration", integration_name)
1410

15-
# Validate directory exists
16-
if !isdir(integration_dir)
17-
error("Integration directory does not exist: $(integration_dir)")
18-
end
11+
if !isdir(integration_dir)
12+
error("Integration directory does not exist: $(integration_dir)")
13+
end
14+
15+
using Pkg
16+
Pkg.activate(integration_dir)
17+
Pkg.instantiate()
1918

20-
# Activate the integration environment
21-
# Note: Pkg.test() automatically develops the package being tested,
22-
# so we don't need to manually call Pkg.develop here
23-
using Pkg
24-
Pkg.activate(integration_dir)
25-
# Ensure optional dependencies (e.g. MLJBase, Zygote) are available
26-
# for each integration environment before we run its tests.
27-
Pkg.instantiate()
28-
29-
# Special case: MLJ integrations run additional setup
30-
if startswith(integration_name, "ext/mlj")
31-
ENV["SYMBOLIC_REGRESSION_IS_TESTING"] = "true"
32-
if integration_name == "ext/mlj/templates"
33-
include(joinpath(@__DIR__, "..", "example.jl"))
34-
include(joinpath(@__DIR__, "..", "examples", "parameterized_function.jl"))
35-
include(joinpath(@__DIR__, "..", "examples", "custom_types.jl"))
36-
end
19+
if startswith(integration_name, "ext/mlj")
20+
ENV["SYMBOLIC_REGRESSION_IS_TESTING"] = "true"
21+
if integration_name == "ext/mlj/templates"
22+
include(joinpath(@__DIR__, "..", "example.jl"))
23+
include(joinpath(@__DIR__, "..", "examples", "parameterized_function.jl"))
24+
include(joinpath(@__DIR__, "..", "examples", "custom_types.jl"))
3725
end
26+
end
3827

39-
# Run all test items in the integration directory
40-
@run_package_tests(
41-
filter = ti -> startswith(ti.filename, integration_dir), verbose = true
42-
)
43-
else
44-
# Unit tests
28+
@run_package_tests(
29+
filter = ti -> startswith(ti.filename, integration_dir), verbose = true
30+
)
31+
else
32+
@testset "SymbolicRegression.jl" begin
4533
test_dir = joinpath(@__DIR__, TEST_GROUP)
4634

47-
# Validate directory exists
4835
if !isdir(test_dir)
4936
error("Test directory does not exist: $(test_dir)")
5037
end
5138

52-
# Run all test items in the directory specified by TEST_GROUP
5339
@run_package_tests(filter = ti -> startswith(ti.filename, test_dir), verbose = true)
5440
end
5541
end

0 commit comments

Comments
 (0)