Browse Source

Create separate Project.toml for tests.

This is the preferred method in Julia v1.2+ and can be made to work with
Julia v1.0 by a hack.
pull/48/head
Evan Patterson 4 weeks ago
parent
commit
074868f124
  1. 11
      .github/workflows/test.yml
  2. 4
      Project.toml
  3. 1
      src/AlgebraicPetri.jl
  4. 5
      src/interoperability.jl
  5. 5
      test/Project.toml
  6. 2
      test/runtests.jl

11
.github/workflows/test.yml

@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.0', '1.6']
julia_version: ['1.0', '1.6']
os: [ubuntu-latest]
steps:
@ -16,6 +16,13 @@ jobs:
- name: "Set up Julia"
uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}
version: ${{ matrix.julia_version }}
- name: "Run tests"
uses: julia-actions/julia-runtest@master
if: matrix.julia_version != '1.0'
- name: "Run tests (Julia v1.0)"
run: |
julia -e 'using Pkg; Pkg.activate("test"); Pkg.develop(PackageSpec(path="."))'
julia --color=yes --check-bounds=yes --project=test test/runtests.jl
# XXX: Julia 1.0 does not use the Project.toml in `tests` directory.
if: matrix.julia_version == '1.0'

4
Project.toml

@ -21,8 +21,4 @@ StatsBase = "^0.33"
julia = "1.0"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Petri = "4259d249-1051-49fa-8328-3f8ab9391c33"
[targets]
test = ["Test", "Petri"]

1
src/AlgebraicPetri.jl

@ -17,7 +17,6 @@ using Catlab.CategoricalAlgebra
using Catlab.CategoricalAlgebra.FinSets
using Catlab.Present
using Catlab.Theories
using Petri
using LabelledArrays
using LinearAlgebra: mul!

5
src/interoperability.jl

@ -2,10 +2,9 @@ using Requires
@require Petri="4259d249-1051-49fa-8328-3f8ab9391c33" begin
import .Petri
import .Petri: Model
# Interoperability with Petri.jl
Model(p::AbstractPetriNet) = begin
Petri.Model(p::AbstractPetriNet) = begin
ts = TransitionMatrices(p)
t_in = map(i->Dict(k=>v for (k,v) in enumerate(ts.input[i,:]) if v != 0), 1:nt(p))
t_out = map(i->Dict(k=>v for (k,v) in enumerate(ts.output[i,:]) if v != 0), 1:nt(p))
@ -14,7 +13,7 @@ using Requires
return Model(ns(p), Δ)
end
Model(p::Union{AbstractLabelledPetriNet, AbstractLabelledReactionNet}) = begin
Petri.Model(p::Union{AbstractLabelledPetriNet, AbstractLabelledReactionNet}) = begin
snames = [sname(p, s) for s in 1:ns(p)]
tnames = [tname(p, t) for t in 1:nt(p)]
ts = TransitionMatrices(p)

5
test/Project.toml

@ -0,0 +1,5 @@
[deps]
AlgebraicPetri = "4f99eebe-17bf-4e98-b6a1-2c4f205a959b"
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
Petri = "4259d249-1051-49fa-8328-3f8ab9391c33"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

2
test/runtests.jl

@ -1,6 +1,6 @@
using Test
using Petri
import Petri
using LabelledArrays
using AlgebraicPetri
using AlgebraicPetri.Epidemiology

Loading…
Cancel
Save