Skip to content

Commit

Permalink
Only do ADRIA.setup() and create temp dir once when running tests
Browse files Browse the repository at this point in the history
We need to set the location to a temporary folder before running the model in test environment but if we do that before running `ADRIA.setup()` some ENV variables will not be set, which causes a problem.
  • Loading branch information
Zapiano committed Sep 13, 2024
1 parent 34d070a commit 33ac1e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 6 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ const TEST_REEFMOD_ENGINE_DOMAIN_PATH = joinpath(TEST_DATA_DIR, "Reefmod_test_do

include("aqua.jl")

# Load and apply configuration options
ADRIA.setup()

# Set result location to temporary folder within the current path
ENV["ADRIA_OUTPUT_DIR"] = mktempdir()

"""Test smaller scenario run with example scenario specification"""
function test_small_spec_rs()
# Load and apply configuration options
ADRIA.setup()

# Run scenarios with example Domain
dom = ADRIA.load_domain(TEST_DOMAIN_PATH)

Expand All @@ -37,18 +40,12 @@ end

"""Test ReefMod Engine domain loading"""
function test_reefmod_engine_domain()
# Load and apply configuration options
ADRIA.setup()

# Load test RMEDomain
return ADRIA.load_domain(RMEDomain, TEST_REEFMOD_ENGINE_DOMAIN_PATH, "45")
end

"""Test result set. Return domain, n_samples, scenarios and result set"""
function test_rs()
# Load and apply configuration options
ADRIA.setup()

# Load domain data
dom = ADRIA.load_domain(TEST_DOMAIN_PATH)

Expand Down
3 changes: 0 additions & 3 deletions test/viz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ if !@isdefined(TEST_RS)
const TEST_DOM, TEST_N_SAMPLES, TEST_SCENS, TEST_RS = test_rs()
end

# Set result location to temporary folder within the current path
ENV["ADRIA_OUTPUT_DIR"] = mktempdir()

"""Test larger scenario run with figure creation"""
function test_rs_w_fig(rs::ADRIA.ResultSet, scens::ADRIA.DataFrame)
Makie.inline!(false)
Expand Down

0 comments on commit 33ac1e1

Please sign in to comment.