Skip to content

Commit

Permalink
Add relconfig option to rein in config option expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgr committed Oct 17, 2024
1 parent d4bb172 commit dfd48fe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/testrel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ Note that `test_rel` creates a new schema for each test.
- `include_stdlib::Bool`: boolean that specifies whether to include the stdlib
- `install::Dict{String, String}`: source files to install in the database.
- `inputs::AbstractDict`: input data to the transaction
- `relconfig`: configuration options to be inserted into rel[:config, :key]: value
- `abort_on_error::Bool`: boolean that specifies whether to abort on any
triggered error.
- `debug::Bool`: boolean that specifies debugging mode.
Expand All @@ -356,6 +357,7 @@ function test_rel(;
location::Option{LineNumberNode}=nothing,
include_stdlib::Bool=true,
install::AcceptedSourceTypes=Dict{String, String}(),
relconfig::Option{Dict{Symbol, <:Any}}=nothing,
abort_on_error::Bool=false,
debug::Bool=false,
debug_trace::Bool=false,
Expand Down Expand Up @@ -403,6 +405,7 @@ function test_rel(;
name=name,
location=location,
include_stdlib=include_stdlib,
relconfig=relconfig,
abort_on_error=abort_on_error,
debug=debug,
debug_trace=debug_trace,
Expand Down Expand Up @@ -432,6 +435,7 @@ Note that `test_rel` creates a new schema for each test.
- `name::String`: name of the testcase
- `location::LineNumberNode`: Sourcecode location
- `include_stdlib::Bool`: boolean that specifies whether to include the stdlib
- `relconfig`: configuration options to be inserted into rel[:config, :key]: value
- `abort_on_error::Bool`: boolean that specifies whether to abort on any
triggered error.
- `debug::Bool`: boolean that specifies debugging mode.
Expand All @@ -444,6 +448,7 @@ function test_rel_steps(;
name::Option{String}=nothing,
location::Option{LineNumberNode}=nothing,
include_stdlib::Bool=true,
relconfig::Option{Dict{Symbol, <:Any}}=nothing,
abort_on_error::Bool=false,
debug::Bool=false,
debug_trace::Bool=false,
Expand Down Expand Up @@ -481,6 +486,16 @@ function test_rel_steps(;
config_query *= """def insert[:rel, :config, :corerel_deprecations]: "disable"\n"""
end

if !isnothing(relconfig)
rel(v::AbstractString) = "\"$v\""
rel(v::Int64) = string(v)
rel(v::Float64) = string(v)
rel(v::Bool) = string(v)
for (k, v) in relconfig
config_query *= "def insert[:rel, :config, :$(string(k))]: $(rel(v))\n"
end
end

if config_query != ""
insert!(steps, 1, Step(; name="configuration", query=config_query))
end
Expand Down

0 comments on commit dfd48fe

Please sign in to comment.