Skip to content

Commit 579d68d

Browse files
authored
Updated framework for testing (#5)
1 parent c095ef6 commit 579d68d

9 files changed

+85
-42
lines changed

.pre-commit-config.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ repos:
77
- id: check-yaml
88
- id: end-of-file-fixer
99
exclude_types: [markdown] # incompatible with Literate.jl
10-
- repo: https://github.com/qiaojunfeng/pre-commit-julia-format
11-
rev: v0.2.0
10+
11+
- repo: "https://github.com/domluna/JuliaFormatter.jl"
12+
rev: v1.0.62
1213
hooks:
13-
- id: julia-format
14+
- id: "julia-formatter"

Project.toml

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
name = "UnspecifiedTypes"
22
uuid = "42b3faec-625b-4613-8ddc-352bf9672b8d"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[compat]
7-
Aqua = "0.8.9"
8-
Test = "1.10"
97
julia = "1.10"
10-
11-
[extras]
12-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
13-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
14-
15-
[targets]
16-
test = ["Aqua", "Test"]

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/stable/)
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/dev/)
5-
[![Build Status](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/CI.yml?query=branch%3Amain)
5+
[![Build Status](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/Tests.yml?query=branch%3Amain)
66
[![Coverage](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl)
77
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
@@ -19,6 +19,12 @@ julia> using Pkg: Pkg
1919

2020
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
2121
```
22+
or:
23+
```julia
24+
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
25+
```
26+
if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
27+
2228
Then, the package can be added as usual through the package manager:
2329

2430
```julia

examples/README.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/stable/)
44
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/dev/)
5-
# [![Build Status](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/CI.yml?query=branch%3Amain)
5+
# [![Build Status](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/UnspecifiedTypes.jl/actions/workflows/Tests.yml?query=branch%3Amain)
66
# [![Coverage](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl)
77
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
@@ -21,6 +21,14 @@ julia> using Pkg: Pkg
2121
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
2222
```
2323
=#
24+
# or:
25+
#=
26+
```julia
27+
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
28+
```
29+
=#
30+
# if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
31+
2432
# Then, the package can be added as usual through the package manager:
2533

2634
#=

test/Project.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
[deps]
2-
UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d"
32
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
4+
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
45
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6+
7+
[compat]
8+
Aqua = "0.8.9"
9+
SafeTestsets = "0.1"
10+
Suppressor = "0.2"
11+
Test = "1.10"

test/runtests.jl

+56-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,61 @@
1-
@eval module $(gensym())
2-
using Test: @testset
1+
using SafeTestsets: @safetestset
2+
using Suppressor: Suppressor
33

4-
@testset "UnspecifiedTypes.jl" begin
5-
filenames = filter(readdir(@__DIR__)) do f
6-
startswith("test_")(f) && endswith(".jl")(f)
4+
# check for filtered groups
5+
# either via `--group=ALL` or through ENV["GROUP"]
6+
const pat = r"(?:--group=)(\w+)"
7+
arg_id = findfirst(contains(pat), ARGS)
8+
const GROUP = uppercase(
9+
if isnothing(arg_id)
10+
get(ENV, "GROUP", "ALL")
11+
else
12+
only(match(pat, ARGS[arg_id]).captures)
13+
end,
14+
)
15+
16+
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17+
istestfile(fn) =
18+
endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
19+
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
20+
isexamplefile(fn) =
21+
endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
22+
23+
@time begin
24+
# tests in groups based on folder structure
25+
for testgroup in filter(isdir, readdir(@__DIR__))
26+
if GROUP == "ALL" || GROUP == uppercase(testgroup)
27+
for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true))
28+
@eval @safetestset $file begin
29+
include($file)
30+
end
31+
end
32+
end
733
end
8-
@testset "Test $filename" for filename in filenames
9-
include(filename)
34+
35+
# single files in top folder
36+
for file in filter(istestfile, readdir(@__DIR__))
37+
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
38+
@eval @safetestset $file begin
39+
include($file)
40+
end
1041
end
11-
end
1242

43+
# test examples
44+
examplepath = joinpath(@__DIR__, "..", "examples")
45+
for (root, _, files) in walkdir(examplepath)
46+
contains(chopprefix(root, @__DIR__), "setup") && continue
47+
for file in filter(isexamplefile, files)
48+
filename = joinpath(root, file)
49+
@eval begin
50+
@safetestset $file begin
51+
$(Expr(
52+
:macrocall,
53+
GlobalRef(Suppressor, Symbol("@suppress")),
54+
LineNumberNode(@__LINE__, @__FILE__),
55+
:(include($filename)),
56+
))
57+
end
58+
end
59+
end
60+
end
1361
end

test/test_aqua.jl

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
@eval module $(gensym())
21
using UnspecifiedTypes: UnspecifiedTypes
32
using Aqua: Aqua
43
using Test: @testset
54

65
@testset "Code quality (Aqua.jl)" begin
76
Aqua.test_all(UnspecifiedTypes)
87
end
9-
end

test/test_basics.jl

-8
This file was deleted.

test/test_examples.jl

-8
This file was deleted.

0 commit comments

Comments
 (0)