Skip to content

Commit 2e4490e

Browse files
committed
rebase tests for extensions
1 parent 4e0b791 commit 2e4490e

File tree

9 files changed

+78
-66
lines changed

9 files changed

+78
-66
lines changed

docs/src/resources/contributing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ The tests are divided into several test groups, where the group names are define
3838
make GROUP=Core test
3939
```
4040

41-
### [Test items](@id doc-Contribute:Test-items)
41+
### [Test Item Framework for Core tests](@id doc-Contribute:Test-Item-Framework-for-Core-tests)
4242

43-
Our tests are provided using the [Test Item Framework](https://www.julia-vscode.org/docs/stable/userguide/testitems/), which structures the test code into `@testitems` and makes it easy to run individually.
43+
The tests in `GROUP=Core` are provided using the [Test Item Framework](https://www.julia-vscode.org/docs/stable/userguide/testitems/), which structures the test codes into `@testitems` and makes it easier to run individually.
4444

45-
The [VS Code](https://code.visualstudio.com/) and its [Julia extension](https://www.julia-vscode.org/) provides us with options to run individual `@testitems`. It is much easier to find the specific test that failed since the [Julia extension](https://www.julia-vscode.org/) in [VS Code](https://code.visualstudio.com/) will collect all these test failures and then display them in a structured way, directly at the place in the code where a specific test failed. See [here](https://www.julia-vscode.org/docs/stable/userguide/testitems/) for more details.
45+
The [VS Code](https://code.visualstudio.com/) and its [Julia extension](https://www.julia-vscode.org/) provides us with options to run individual `@testitems`. It is much easier to find the specific core test that failed since the [Julia extension](https://www.julia-vscode.org/) in [VS Code](https://code.visualstudio.com/) will collect all core test failures and then display them in a structured way, directly at the place in the code where a specific core test failed. See [here](https://www.julia-vscode.org/docs/stable/userguide/testitems/) for more details.
4646

4747
## [Julia Code Format](@id doc-Contribute:Julia-Code-Format)
4848

test/Project.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
[deps]
2-
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
3-
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
42
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
5-
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
63
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
74
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
85
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
9-
SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1"
106
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
117
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
128
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
139
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
14-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
1510

1611
[compat]
1712
Pkg = "1"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
3+
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
4+
SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1"
5+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

test/ext-test/cpu/autodiff/zygote.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
@testitem "Zygote Extension" tags=[:autodiff] default_imports=false begin
2-
using Test
3-
using QuantumToolbox
4-
using Zygote
5-
using Enzyme
6-
using SciMLSensitivity
7-
1+
@testset "Zygote Extension" verbose=true begin
82
@testset "sesolve" begin
93
coef_Ω(p, t) = p[1]
104

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
3+
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"

test/ext-test/cpu/makie/makie_ext.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
@testitem "Makie Extension" tags=[:makie] default_imports=false begin
2-
using Test
3-
using QuantumToolbox
4-
# Makie is imported below
5-
1+
@testset "Makie Extension" verbose = true begin
62
ψ = normalize(coherent(50, 5.0) + coherent(50, -5.0))
73
xvec = yvec = -15.0:0.1:15.0
84
wig = transpose(wigner(ψ, xvec, yvec))

test/ext-test/gpu/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
3+
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
4+
5+
[compat]
6+
CUDA = "5"

test/ext-test/gpu/cuda_ext.jl

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
@testitem "CUDA Extension" tags=[:cuda] default_imports=false begin
2-
using Test
3-
using QuantumToolbox
4-
import LinearAlgebra: Diagonal
5-
6-
using CUDA
7-
using CUDA.CUSPARSE
8-
CUDA.versioninfo()
9-
1+
@testset "CUDA Extension" verbose = true begin
102
# Test that scalar indexing is disallowed
113
@test_throws ErrorException CUDA.rand(1)[1]
124

@@ -137,12 +129,7 @@
137129
@test all([isapprox(sol_cpu.expect[i], sol_gpu32.expect[i]; atol = 1e-6) for i in 1:length(tlist)])
138130
end
139131

140-
@testitem "CUDA steadystate" tags=[:cuda] default_imports=false begin
141-
using Test
142-
using QuantumToolbox
143-
using CUDA
144-
using CUDA.CUSPARSE
145-
132+
@testset "CUDA steadystate" begin
146133
N = 50
147134
Δ = 0.01
148135
F = 0.1
@@ -167,7 +154,7 @@ end
167154
@test ρ_ss_cpu.data Array(ρ_ss_gpu_csr.data) atol = 1e-8 * length(ρ_ss_cpu)
168155
end
169156

170-
@testitem "CUDA ptrace" tags=[:cuda] default_imports=false begin
157+
@testset "CUDA ptrace" begin
171158
using Test
172159
using QuantumToolbox
173160
import StaticArraysCore: SVector

test/runtests.jl

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,80 @@
1+
using Test
12
using TestItemRunner
23
using Pkg
34

4-
using QuantumToolbox
5-
65
const GROUP_LIST = String["All", "Core", "Code-Quality", "AutoDiff_Ext", "Makie_Ext", "CUDA_Ext"]
76

87
const GROUP = get(ENV, "GROUP", "All")
98
(GROUP in GROUP_LIST) || throw(ArgumentError("Unknown GROUP = $GROUP"))
109

11-
testfilter = ti -> begin
12-
if (GROUP == "All") || (GROUP == "Core")
13-
return :core in ti.tags
14-
end
10+
# Core tests
11+
if (GROUP == "All") || (GROUP == "Core")
12+
import QuantumToolbox
13+
14+
QuantumToolbox.about()
15+
16+
println("\nStart running Core tests...\n")
17+
@run_package_tests verbose=true
18+
end
1519

16-
if GROUP == "AutoDiff_Ext"
17-
return :autodiff in ti.tags
18-
end
20+
########################################################################
21+
# Use traditional Test.jl instead of TestItemRunner.jl for other tests #
22+
########################################################################
23+
24+
const testdir = dirname(@__FILE__)
25+
26+
if (GROUP == "All") || (GROUP == "Code-Quality")
27+
Pkg.activate("core-test/code-quality")
28+
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
29+
Pkg.instantiate()
1930

20-
if GROUP == "Makie_Ext"
21-
return :makie in ti.tags
22-
end
31+
using QuantumToolbox
32+
using Aqua, JET
2333

24-
if GROUP == "CUDA_Ext"
25-
return :cuda in ti.tags
26-
end
34+
(GROUP == "Code-Quality") && QuantumToolbox.about() # print version info. for code quality CI in GitHub
2735

28-
if GROUP == "Code-Quality"
29-
return false
30-
end
36+
include(joinpath(testdir, "core-test", "code-quality", "code_quality.jl"))
3137
end
3238

33-
QuantumToolbox.about()
39+
if (GROUP == "AutoDiff_Ext")
40+
Pkg.activate("ext-test/cpu/autodiff")
41+
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
42+
Pkg.instantiate()
3443

35-
println("\nStart running tests [for GROUP = $GROUP]...\n")
44+
using QuantumToolbox
45+
using Zygote
46+
using Enzyme
47+
using SciMLSensitivity
3648

37-
# TestItemRunner.jl
38-
@run_package_tests filter=testfilter
39-
(GROUP == "Code-Quality") && println("[Other tests skipped]\n")
49+
QuantumToolbox.about()
4050

41-
# Use traditional Test.jl instead of TestItemRunner.jl for Aqua and JET
42-
if (GROUP == "All") || (GROUP == "Code-Quality")
43-
println("Start running code quality tests...")
51+
include(joinpath(testdir, "ext-test", "cpu", "autodiff", "zygote.jl"))
52+
end
4453

45-
Pkg.activate("core-test/code-quality")
54+
if (GROUP == "Makie_Ext")
55+
Pkg.activate("ext-test/cpu/makie")
4656
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
4757
Pkg.instantiate()
4858

49-
using Test
5059
using QuantumToolbox
51-
using Aqua, JET
60+
QuantumToolbox.about()
61+
62+
# CarioMakie is imported in the following script
63+
include(joinpath(testdir, "ext-test", "cpu", "makie", "makie_ext.jl"))
64+
end
65+
66+
if (GROUP == "CUDA_Ext")
67+
Pkg.activate("ext-test/gpu")
68+
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
69+
Pkg.instantiate()
70+
71+
using QuantumToolbox
72+
using CUDA
73+
using CUDA.CUSPARSE
74+
# CUDA.allowscalar(false) # This is already set in the extension script
75+
76+
QuantumToolbox.about()
77+
CUDA.versioninfo()
5278

53-
include(joinpath(dirname(@__FILE__), "core-test", "code-quality", "code_quality.jl"))
79+
include(joinpath(testdir, "ext-test", "gpu", "cuda_ext.jl"))
5480
end

0 commit comments

Comments
 (0)