Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add relconfig option to rein in config option expansion #92

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 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,14 @@ function test_rel_steps(;
config_query *= """def insert[:rel, :config, :corerel_deprecations]: "disable"\n"""
end

if !isnothing(relconfig)
rel(v::AbstractString) = "\"$v\""
rel(v::Union{Int64,Float64,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
7 changes: 7 additions & 0 deletions test/integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@
expect_abort = true,
)

@test_rel(
name = "relconfig abort_on_error",
query = "def output { a }",
relconfig = Dict(:abort_on_error => true),
expect_abort = true,
)

# `setup` and `tags` keywords ignored
# --------------------------------------------------------

Expand Down
Loading