Skip to content

Commit

Permalink
rework the tests to use TestItems (probably should have been a separa…
Browse files Browse the repository at this point in the history
…te PR)
  • Loading branch information
Krastanov committed Oct 20, 2024
1 parent 43da8c7 commit ad3b0b7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Quantikz = "b0d11df0-eea3-4d79-b4a5-421488cbf74b"
QuantumClifford = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
40 changes: 13 additions & 27 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
using SafeTestsets
using BPGates
using TestItemRunner

function doset(descr)
if length(ARGS) == 0
return true
end
for a in ARGS
if occursin(lowercase(a), lowercase(descr))
return true
end
end
return false
end
# filter for the test
testfilter = ti -> begin
exclude = Symbol[]
if get(ENV,"JET_TEST","")!="true"
push!(exclude, :jet)
end
if !(VERSION >= v"1.10")
push!(exclude, :doctests)
push!(exclude, :aqua)
end

macro doset(descr)
quote
if doset($descr)
@safetestset $descr begin include("test_"*$descr*".jl") end
end
end
return all(!in(exclude), ti.tags)
end

println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREADS = $(Sys.CPU_THREADS)`...")

@doset "quantumclifford"
@doset "quantikz"
get(ENV,"JET_TEST","")=="true" && @doset "jet"
@doset "doctests"

using Aqua
doset("aqua") && begin
Aqua.test_all(BPGates)
end
@run_package_tests filter=testfilter
7 changes: 7 additions & 0 deletions test/test_aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@testitem "Aqua analysis" begin

using Aqua, BPGates

Aqua.test_all(BPGates)

end
4 changes: 4 additions & 0 deletions test/test_doctests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@testitem "doctests" begin

using Documenter
using BPGates

DocMeta.setdocmeta!(BPGates, :DocTestSetup, :(using QuantumClifford, BPGates); recursive=true)
doctest(BPGates)

end
4 changes: 4 additions & 0 deletions test/test_jet.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@testitem "JET analysis" begin

using JET
using Test
using BPGates
Expand All @@ -9,3 +11,5 @@ rep = report_package("BPGates";
)
@show rep
@test length(JET.get_reports(rep)) == 0

end
4 changes: 4 additions & 0 deletions test/test_quantikz.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@testitem "Quantikz circuit plotting" begin

using BPGates
using Quantikz
using Test
Expand All @@ -6,3 +8,5 @@ using Test
quantikz_circ = Quantikz.QuantikzOp.([BellSinglePermutation(2,2), BellDoublePermutation(1,2,3), BellPauliPermutation(4,1), BellMeasure(3,1), BellGate(1,1,1,1,1,1,2), CNOTPerm(1,2,3,4), GoodSingleQubitPerm(1,2), PauliNoiseOp(1,0.0,0.0,0.0), PauliNoiseBellGate(CNOTPerm(1,2,3,4),0.0,0.0,0.0), NoisyBellMeasure(BellMeasure(1,2),0.0), NoisyBellMeasureNoisyReset(BellMeasure(1,2),0.0,0.0,0.0,0.0)])
img = Quantikz.circuit2image(quantikz_circ)
end

end
4 changes: 4 additions & 0 deletions test/test_quantumclifford.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@testitem "QuantumClifford comparisons" begin

using BPGates, QuantumClifford
using QuantumClifford.Experimental.NoisyCircuits
using Random
Expand Down Expand Up @@ -59,3 +61,5 @@ end
@test_throws ArgumentError BellState(S"ZX")
@test_throws ArgumentError BellState(S"XXII ZZII IIXX Y_ZZ") # this is not really a valid stabilizer tableau anyway
@test_throws ArgumentError BellState(ghz(4))

end

0 comments on commit ad3b0b7

Please sign in to comment.