Skip to content

Commit 9b77572

Browse files
committed
move global config to own file
1 parent dffcfff commit 9b77572

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

src/ChainRulesTestUtils.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@ using Test
1111

1212
import FiniteDifferences: rand_tangent
1313

14-
const _fdm = central_fdm(5, 1; max_range=1e-2)
15-
const TEST_INFERRED = Ref(true)
16-
const TRANSFORMS_TO_ALT_TANGENTS = Function[] # e.g. [x -> @thunk(x), _ -> ZeroTangent(), x -> rebasis(x)]
17-
1814
export TestIterator
1915
export test_approx, test_scalar, test_frule, test_rrule, generate_well_conditioned_matrix
2016
export
2117
export @maybe_inferred
2218

23-
function __init__()
24-
TEST_INFERRED[] = if haskey(ENV, "CHAINRULES_TEST_INFERRED")
25-
parse(Bool, "CHAINRULES_TEST_INFERRED")
26-
else
27-
!parse(Bool, get(ENV, "JULIA_PKGEVAL", "false"))
28-
end
19+
__init__() = init_test_inferred_setting!()
2920

30-
!TEST_INFERRED[] && @warn "inference tests have been disabled"
31-
end
21+
include("global_config.jl")
3222

3323
include("generate_tangent.jl")
3424
include("data_generation.jl")

src/global_config.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const _fdm = central_fdm(5, 1; max_range=1e-2)
2+
const TEST_INFERRED = Ref(true)
3+
const TRANSFORMS_TO_ALT_TANGENTS = Function[] # e.g. [x -> @thunk(x), _ -> ZeroTangent(), x -> rebasis(x)]
4+
5+
6+
7+
"sets up TEST_INFERRED based ion enviroment variables"
8+
function init_test_inferred_setting!()
9+
TEST_INFERRED[] = if haskey(ENV, "CHAINRULES_TEST_INFERRED")
10+
parse(Bool, "CHAINRULES_TEST_INFERRED")
11+
else
12+
!parse(Bool, get(ENV, "JULIA_PKGEVAL", "false"))
13+
end
14+
15+
!TEST_INFERRED[] && @warn "inference tests have been disabled"
16+
end

src/testers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ end
316316
"""
317317
_test_inferred(f, args...; kwargs...)
318318
319-
Simple wrapper for `@inferred f(args...: kwargs...)`, avoiding the type-instability in not
319+
Simple wrapper for [`@maybe_inferred f(args...: kwargs...)`](@ref `@maybe_inferred`), avoiding the type-instability in not
320320
knowing how many `kwargs` there are.
321321
"""
322322
function _test_inferred(f, args...; kwargs...)

0 commit comments

Comments
 (0)