Skip to content

Commit d7f7df1

Browse files
committed
Convert test suite to testitems
1 parent fd75cf5 commit d7f7df1

20 files changed

+1866
-1808
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ Preferences = "1"
6666
QuadGK = "2"
6767
SpatialIndexing = "0.1"
6868
StaticArrays = "1"
69+
TestItemRunner = "1.1.0"
6970
Unitful = "1.2"
7071
gmsh_jll = "4.13"
7172
julia = "1.10"
7273

7374
[extras]
7475
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
7576
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
77+
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
7678

7779
[targets]
78-
test = ["Aqua", "Test"]
80+
test = ["Aqua", "Test", "TestItemRunner"]

test/runtests.jl

Lines changed: 27 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,29 @@
1-
using Test
2-
using Preferences
3-
using DeviceLayout, Unitful, FileIO, Logging
4-
import Unitful: s, °, DimensionError
5-
import Clipper
6-
import ForwardDiff
7-
8-
const pm2μm = DeviceLayout.PreferMicrons.pm
9-
const nm2μm = DeviceLayout.PreferMicrons.nm
10-
const μm2μm = DeviceLayout.PreferMicrons.μm
11-
const mm2μm = DeviceLayout.PreferMicrons.mm
12-
const cm2μm = DeviceLayout.PreferMicrons.cm
13-
const m2μm = DeviceLayout.PreferMicrons.m
14-
15-
const nm2nm = DeviceLayout.PreferNanometers.nm
16-
const μm2nm = DeviceLayout.PreferNanometers.μm
17-
const cm2nm = DeviceLayout.PreferNanometers.cm
18-
const m2nm = DeviceLayout.PreferNanometers.m
19-
20-
import Unitful: pm, nm, μm, mm, cm, m
21-
22-
p(x, y) = Point(x, y)
23-
const tdir = mktempdir()
24-
25-
include("tests.jl")
26-
include("test_align.jl")
27-
include("test_bspline.jl")
28-
include("test_clipping.jl")
29-
include("test_coordinate_systems.jl")
30-
include("test_entity.jl")
31-
include("test_intersection.jl")
32-
include("test_shapes.jl")
33-
include("test_routes.jl")
34-
include("test_texts.jl")
35-
include("test_pointinpoly.jl")
36-
include("test_solidmodel.jl")
37-
38-
@testset "Schematic-Driven Layout" begin
39-
include("test_schematicdriven.jl")
40-
end
41-
42-
include("test_pdktools.jl")
43-
44-
@testset "ExamplePDK" begin
45-
include("../examples/DemoQPU17/DemoQPU17.jl")
46-
@time "Total" schematic, artwork = DemoQPU17.qpu17_demo(dir=tdir)
47-
# Single transmon example file requires CSV, JSON, JSONSchema, DataFrames
48-
# Just test the components
49-
using .SchematicDrivenLayout
50-
q = SchematicDrivenLayout.ExamplePDK.Transmons.ExampleRectangleTransmon()
51-
rr = SchematicDrivenLayout.ExamplePDK.ReadoutResonators.ExampleClawedMeanderReadout()
52-
@test geometry(q) isa CoordinateSystem{typeof(1.0DeviceLayout.nm)}
53-
@test geometry(rr) isa CoordinateSystem{typeof(1.0DeviceLayout.nm)}
54-
@test issubset([:readout, :xy, :z], keys(hooks(q)))
55-
@test abs(hooks(rr).qubit.p.y - hooks(rr).feedline.p.y) rr.total_height
56-
end
57-
58-
using Aqua
59-
@testset "Aqua tests" begin
60-
# Everything but stdlib should have compat versions
61-
Aqua.test_deps_compat(
62-
DeviceLayout,
63-
ignore=[:Dates, :LinearAlgebra, :Logging, :Random, :UUIDs],
64-
check_extras=(; ignore=[:Test])
65-
)
66-
# We define ForwardDiff.extract_derivative with Unitful.Quantity; ignore that one
67-
Aqua.test_piracies(
68-
DeviceLayout,
69-
treat_as_own=[DeviceLayout.ForwardDiff.extract_derivative]
70-
)
71-
Aqua.test_stale_deps(DeviceLayout)
72-
Aqua.test_undefined_exports(DeviceLayout) # This also checks exports from submodules
73-
# Be careful about ambiguities when defining GeometryEntityStyle, since we define for convenience
74-
# (T::Type{<:GeometryEntityStyle})(x::GeometryEntity, args...; kwargs...) = styled(x, T(args...; kwargs...))
75-
# A style whose first field is a GeometryEntity would be genuinely ambiguous
76-
# And otherwise you might have to define an inner constructor where the first arg isn't ::Any
77-
Aqua.test_ambiguities(DeviceLayout)
1+
using TestItemRunner
2+
3+
@testsnippet CommonTestSetup begin
4+
using Test
5+
using Preferences
6+
using DeviceLayout, Unitful, FileIO, Logging
7+
import Unitful: s, °, DimensionError
8+
import Clipper
9+
import ForwardDiff
10+
11+
const pm2μm = DeviceLayout.PreferMicrons.pm
12+
const nm2μm = DeviceLayout.PreferMicrons.nm
13+
const μm2μm = DeviceLayout.PreferMicrons.μm
14+
const mm2μm = DeviceLayout.PreferMicrons.mm
15+
const cm2μm = DeviceLayout.PreferMicrons.cm
16+
const m2μm = DeviceLayout.PreferMicrons.m
17+
18+
const nm2nm = DeviceLayout.PreferNanometers.nm
19+
const μm2nm = DeviceLayout.PreferNanometers.μm
20+
const cm2nm = DeviceLayout.PreferNanometers.cm
21+
const m2nm = DeviceLayout.PreferNanometers.m
22+
23+
import Unitful: pm, nm, μm, mm, cm, m
24+
25+
p(x, y) = Point(x, y)
26+
const tdir = mktempdir()
7827
end
7928

80-
rm(tdir, recursive=true)
29+
@run_package_tests

test/test_align.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Alignment" begin
1+
@testitem "Alignment" setup = [CommonTestSetup] begin
22
r1 = Rectangle(1, 1)
33
r2 = Rectangle(Point(-1, -1), Point(2, 3))
44
p1 = Polygon(Point(0, -3), Point(2, -1), Point(-1, 3))

test/test_aqua.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@testitem "Aqua tests" begin
2+
using Aqua, DeviceLayout
3+
# Everything but stdlib should have compat versions
4+
Aqua.test_deps_compat(
5+
DeviceLayout,
6+
ignore=[:Dates, :LinearAlgebra, :Logging, :Random, :UUIDs],
7+
check_extras=(; ignore=[:Test])
8+
)
9+
# We define ForwardDiff.extract_derivative with Unitful.Quantity; ignore that one
10+
Aqua.test_piracies(
11+
DeviceLayout,
12+
treat_as_own=[DeviceLayout.ForwardDiff.extract_derivative]
13+
)
14+
Aqua.test_stale_deps(DeviceLayout)
15+
Aqua.test_undefined_exports(DeviceLayout) # This also checks exports from submodules
16+
# Be careful about ambiguities when defining GeometryEntityStyle, since we define for convenience
17+
# (T::Type{<:GeometryEntityStyle})(x::GeometryEntity, args...; kwargs...) = styled(x, T(args...; kwargs...))
18+
# A style whose first field is a GeometryEntity would be genuinely ambiguous
19+
# And otherwise you might have to define an inner constructor where the first arg isn't ::Any
20+
Aqua.test_ambiguities(DeviceLayout)
21+
end

test/test_bspline.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "BSpline" begin
1+
@testitem "BSpline" setup = [CommonTestSetup] begin
22
po0 = Point(1.0μm, 1.0μm)
33
po1 = Point(1000.0μm, -20.0μm)
44

@@ -134,7 +134,7 @@
134134
rotated_direction(direction(pa3[3].seg, 50μm), tr)
135135
end
136136

137-
@testset "BSpline approximation" begin
137+
@testitem "BSpline approximation" setup = [CommonTestSetup] begin
138138
pa = Path(Point(0.0, 0.0)nm, α0=90°)
139139
bspline!(
140140
pa,
@@ -185,8 +185,8 @@ end
185185
(gety.(p.p) + gety.(circshift(p.p, -1))) .*
186186
(getx.(p.p) - getx.(circshift(p.p, -1)))
187187
) / 2
188-
p = Polygon([pts; reverse(pts_approx)])
189-
@test abs(area(p) / perimeter(p)) < 100nm # It's actually ~25nm but the guarantee is ~< tolerance
188+
poly = Polygon([pts; reverse(pts_approx)])
189+
@test abs(area(poly) / perimeter(poly)) < 100nm # It's actually ~25nm but the guarantee is ~< tolerance
190190
c = curv[8].curves[1] # ConstantOffset Turn
191191
@test Paths.curvatureradius(c, 10μm) == sign(c.seg.α) * c.seg.r - c.offset
192192
@test curvatureradius_fd(c, 10μm) Paths.curvatureradius(c, 10μm) atol = 1nm
@@ -203,7 +203,7 @@ end
203203
@test_logs (:warn, r"Maximum error") Paths.bspline_approximation(cps[1].curves[1])
204204
end
205205

206-
@testset "BSpline optimization" begin
206+
@testitem "BSpline optimization" setup = [CommonTestSetup] begin
207207
## 90 degree turn
208208
pa = Path() # auto_speed
209209
bspline!(pa, [Point(100μm, 100μm)], 90°, Paths.Trace(1μm); auto_speed=true)

test/test_clipping.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import DeviceLayout.Polygons: circularapprox, circularequality
2-
@testset "Polygon clipping" begin
1+
@testitem "Polygon clipping" setup = [CommonTestSetup] begin
2+
import DeviceLayout.Polygons: circularapprox, circularequality
33
@testset "> Clipping individuals w/o units" begin
44
# Rectangle{Int}, Rectangle{Int} clipping
55
r1 = Rectangle(2, 2)
@@ -476,7 +476,7 @@ import DeviceLayout.Polygons: circularapprox, circularequality
476476
end
477477
end
478478

479-
@testset "Polygon offsetting" begin
479+
@testitem "Polygon offsetting" setup = [CommonTestSetup] begin
480480
@testset "Offsetting individuals w/o units" begin
481481
# Int rectangle, Int delta
482482
r = Rectangle(1, 1)
@@ -776,7 +776,7 @@ end
776776
end
777777
end
778778

779-
@testset "Clipping CurvilinearPolygon" begin
779+
@testitem "Clipping CurvilinearPolygon" setup = [CommonTestSetup] begin
780780

781781
# Reversing curve index formula tests
782782
f = (i, N) -> mod1(i + 1, N) - N - 1 # circ inc by 1 then reverse then negate

test/test_coordinate_systems.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "CoordinateSystems" begin
1+
@testitem "CoordinateSystems" setup = [CommonTestSetup] begin
22
# Setup nested cell refs
33
c = CoordinateSystem{Float64}("main")
44
c2 = CoordinateSystem{Float64}("c2")

test/test_entity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "GeometryEntity" begin
1+
@testitem "GeometryEntity" setup = [CommonTestSetup] begin
22
# Plus shape entity to test methods
33
struct OriginPlus{S} <: GeometryEntity{S}
44
h::S

test/test_examples.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@testitem "ExamplePDK" setup = [CommonTestSetup] begin
2+
include("../examples/DemoQPU17/DemoQPU17.jl")
3+
@time "Total" schematic, artwork = DemoQPU17.qpu17_demo(dir=tdir)
4+
# Single transmon example file requires CSV, JSON, JSONSchema, DataFrames
5+
# Just test the components
6+
using .SchematicDrivenLayout
7+
q = SchematicDrivenLayout.ExamplePDK.Transmons.ExampleRectangleTransmon()
8+
rr = SchematicDrivenLayout.ExamplePDK.ReadoutResonators.ExampleClawedMeanderReadout()
9+
@test geometry(q) isa CoordinateSystem{typeof(1.0DeviceLayout.nm)}
10+
@test geometry(rr) isa CoordinateSystem{typeof(1.0DeviceLayout.nm)}
11+
@test issubset([:readout, :xy, :z], keys(hooks(q)))
12+
@test abs(hooks(rr).qubit.p.y - hooks(rr).feedline.p.y) rr.total_height
13+
end

test/test_intersection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Path intersections" begin
1+
@testitem "Path intersections" setup = [CommonTestSetup] begin
22
paths_vert = [Path(i * 0.1mm, (-1)^(i + 1) * (1mm), α0=(-1)^i * π / 2) for i = -5:5]
33
paths_horiz =
44
[Path((-1)^(i) * (1mm), i * 0.1mm, α0=(-1)^i * π / 2 + π / 2) for i = -5:5]

0 commit comments

Comments
 (0)