Skip to content

Commit

Permalink
Use dev version for examples when running tests (#22)
Browse files Browse the repository at this point in the history
* Use environment variable to toggle dev version for examples when running tests.
  • Loading branch information
hellemo authored Jun 18, 2024
1 parent 4d401ac commit 3e20fd2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes

## Unversioned

* Use dev version of EMG for examples when running as part of tests, similar to [PR #33 of EMB](https://github.com/EnergyModelsX/EnergyModelsBase.jl/pull/33).

## Version 0.9.0 (2024-05-24)

### Update on function calls for dispatching on `modeltype`
Expand Down
2 changes: 2 additions & 0 deletions examples/network.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Pkg
# Activate the local environment including EnergyModelsGeography, HiGHS, PrettyTables
Pkg.activate(@__DIR__)
# Use dev version if run as part of tests
haskey(ENV, "EMX_TEST") && Pkg.develop(path=joinpath(@__DIR__,".."))
# Install the dependencies.
Pkg.instantiate()

Expand Down
13 changes: 5 additions & 8 deletions test/test_examples.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
ENV["EMX_TEST"] = true # Set flag for example scripts to check if they are run as part of the tests

@testset "Run examples" begin
exdir = joinpath(@__DIR__, "../examples")
files = first(walkdir(exdir))[3]
files = filter(endswith(".jl"), readdir(exdir))
for file in files
if splitext(file)[2] == ".jl"
@testset "Example $file" begin
@info "Run example $file"
include(joinpath(exdir, file))

@test termination_status(m) == MOI.OPTIMAL
end
@testset "Example $file" begin
include(joinpath(exdir, file))
@test termination_status(m) == MOI.OPTIMAL
end
end
Pkg.activate(@__DIR__)
Expand Down

0 comments on commit 3e20fd2

Please sign in to comment.