From 34f5a380e7d21e9dd09db20592086555f1b492f4 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Thu, 5 Dec 2024 10:18:51 -0500 Subject: [PATCH 1/4] Clean up test structure --- Project.toml | 6 ++++- README.md | 6 +++++ examples/README.jl | 8 +++++++ test/Project.toml | 4 ---- test/runtests.jl | 52 ++++++++++++++++++++++++++++++++++++------- test/test_aqua.jl | 2 -- test/test_basics.jl | 8 ------- test/test_examples.jl | 8 ------- 8 files changed, 63 insertions(+), 31 deletions(-) delete mode 100644 test/Project.toml delete mode 100644 test/test_basics.jl delete mode 100644 test/test_examples.jl diff --git a/Project.toml b/Project.toml index e5db503..fc6504b 100644 --- a/Project.toml +++ b/Project.toml @@ -5,12 +5,16 @@ version = "0.1.0" [compat] Aqua = "0.8.9" +SafeTestsets = "0.1" +Suppressor = "0.2" Test = "1.10" julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" [targets] -test = ["Aqua", "Test"] +test = ["Aqua", "Test", "Suppressor", "SafeTestsets"] diff --git a/README.md b/README.md index 269ec00..b044602 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ julia> using Pkg: Pkg julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry") ``` +or: +```julia +julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git") +``` +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. + Then, the package can be added as usual through the package manager: ```julia diff --git a/examples/README.jl b/examples/README.jl index 3045804..7c9d8b4 100644 --- a/examples/README.jl +++ b/examples/README.jl @@ -21,6 +21,14 @@ julia> using Pkg: Pkg julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry") ``` =# +# or: +#= +```julia +julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git") +``` +=# +# 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. + # Then, the package can be added as usual through the package manager: #= diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 213d51d..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,4 +0,0 @@ -[deps] -UnspecifiedTypes = "42b3faec-625b-4613-8ddc-352bf9672b8d" -Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 524caf4..bb62115 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,13 +1,49 @@ -@eval module $(gensym()) -using Test: @testset +using SafeTestsets: @safetestset +using Suppressor: @suppress -@testset "UnspecifiedTypes.jl" begin - filenames = filter(readdir(@__DIR__)) do f - startswith("test_")(f) && endswith(".jl")(f) +# check for filtered groups +# either via `--group=ALL` or through ENV["GROUP"] +const pat = r"(?:--group=)(\w+)" +arg_id = findfirst(contains(pat), ARGS) +const GROUP = uppercase( + if isnothing(arg_id) + get(ENV, "GROUP", "ALL") + else + only(match(pat, ARGS[arg_id]).captures) + end, +) + +function istestfile(filename) + return isfile(filename) && + endswith(filename, ".jl") && + startswith(basename(filename), "test") +end + +@time begin + # tests in groups based on folder structure + for testgroup in filter(isdir, readdir(@__DIR__)) + if GROUP == "ALL" || GROUP == uppercase(testgroup) + for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true)) + @eval @safetestset $file begin + include($file) + end + end + end end - @testset "Test $filename" for filename in filenames - include(filename) + + # single files in top folder + for file in filter(istestfile, readdir(@__DIR__)) + (file == basename(@__FILE__)) && continue + @eval @safetestset $file begin + include($file) + end end -end + # test examples + examplepath = joinpath(@__DIR__, "..", "examples") + for file in filter(endswith(".jl"), readdir(examplepath; join=true)) + @suppress @eval @safetestset $file begin + include($file) + end + end end diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 35bee1d..8803cd3 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -1,4 +1,3 @@ -@eval module $(gensym()) using UnspecifiedTypes: UnspecifiedTypes using Aqua: Aqua using Test: @testset @@ -6,4 +5,3 @@ using Test: @testset @testset "Code quality (Aqua.jl)" begin Aqua.test_all(UnspecifiedTypes) end -end diff --git a/test/test_basics.jl b/test/test_basics.jl deleted file mode 100644 index 33b9e0f..0000000 --- a/test/test_basics.jl +++ /dev/null @@ -1,8 +0,0 @@ -@eval module $(gensym()) -using UnspecifiedTypes: UnspecifiedTypes -using Test: @test, @testset - -@testset "UnspecifiedTypes" begin - # Tests go here. -end -end diff --git a/test/test_examples.jl b/test/test_examples.jl deleted file mode 100644 index 9c09d3f..0000000 --- a/test/test_examples.jl +++ /dev/null @@ -1,8 +0,0 @@ -@eval module $(gensym()) -using UnspecifiedTypes: UnspecifiedTypes -using Test: @test, @testset - -@testset "examples" begin - include(joinpath(pkgdir(UnspecifiedTypes), "examples", "README.jl")) -end -end From fe76f66c8287bf734fcebb5a699fda7c9fcb1c9c Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Thu, 5 Dec 2024 10:21:04 -0500 Subject: [PATCH 2/4] update version v0.1.1 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index fc6504b..b94328a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UnspecifiedTypes" uuid = "42b3faec-625b-4613-8ddc-352bf9672b8d" authors = ["ITensor developers and contributors"] -version = "0.1.0" +version = "0.1.1" [compat] Aqua = "0.8.9" From 1abbe8920fa3714813ce0dc50ec6ca57d4361783 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Thu, 5 Dec 2024 11:35:50 -0500 Subject: [PATCH 3/4] update test badge --- README.md | 2 +- examples/README.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b044602..21c074e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/dev/) -[![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) +[![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) [![Coverage](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl) [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) diff --git a/examples/README.jl b/examples/README.jl index 7c9d8b4..f92ffe7 100644 --- a/examples/README.jl +++ b/examples/README.jl @@ -2,7 +2,7 @@ # # [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/stable/) # [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/UnspecifiedTypes.jl/dev/) -# [![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) +# [![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) # [![Coverage](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/UnspecifiedTypes.jl) # [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) # [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) From 1ddb88d8b29e9cadebefbc69247bddaef3ee00d2 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 9 Dec 2024 18:44:21 -0500 Subject: [PATCH 4/4] update with skeleton v0.2.0 --- .pre-commit-config.yaml | 7 ++++--- Project.toml | 13 ------------- test/Project.toml | 11 +++++++++++ test/runtests.jl | 32 ++++++++++++++++++++++---------- 4 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 test/Project.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bff1fb7..6599365 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,8 @@ repos: - id: check-yaml - id: end-of-file-fixer exclude_types: [markdown] # incompatible with Literate.jl -- repo: https://github.com/qiaojunfeng/pre-commit-julia-format - rev: v0.2.0 + +- repo: "https://github.com/domluna/JuliaFormatter.jl" + rev: v1.0.62 hooks: - - id: julia-format + - id: "julia-formatter" diff --git a/Project.toml b/Project.toml index b94328a..7c387e6 100644 --- a/Project.toml +++ b/Project.toml @@ -4,17 +4,4 @@ authors = ["ITensor developers and contributors"] version = "0.1.1" [compat] -Aqua = "0.8.9" -SafeTestsets = "0.1" -Suppressor = "0.2" -Test = "1.10" julia = "1.10" - -[extras] -Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" -Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" - -[targets] -test = ["Aqua", "Test", "Suppressor", "SafeTestsets"] diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..e9c291e --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,11 @@ +[deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +Aqua = "0.8.9" +SafeTestsets = "0.1" +Suppressor = "0.2" +Test = "1.10" diff --git a/test/runtests.jl b/test/runtests.jl index bb62115..bd97441 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ using SafeTestsets: @safetestset -using Suppressor: @suppress +using Suppressor: Suppressor # check for filtered groups # either via `--group=ALL` or through ENV["GROUP"] @@ -13,11 +13,12 @@ const GROUP = uppercase( end, ) -function istestfile(filename) - return isfile(filename) && - endswith(filename, ".jl") && - startswith(basename(filename), "test") -end +"match files of the form `test_*.jl`, but exclude `*setup*.jl`" +istestfile(fn) = + endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") +"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`" +isexamplefile(fn) = + endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") @time begin # tests in groups based on folder structure @@ -33,7 +34,7 @@ end # single files in top folder for file in filter(istestfile, readdir(@__DIR__)) - (file == basename(@__FILE__)) && continue + (file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion @eval @safetestset $file begin include($file) end @@ -41,9 +42,20 @@ end # test examples examplepath = joinpath(@__DIR__, "..", "examples") - for file in filter(endswith(".jl"), readdir(examplepath; join=true)) - @suppress @eval @safetestset $file begin - include($file) + for (root, _, files) in walkdir(examplepath) + contains(chopprefix(root, @__DIR__), "setup") && continue + for file in filter(isexamplefile, files) + filename = joinpath(root, file) + @eval begin + @safetestset $file begin + $(Expr( + :macrocall, + GlobalRef(Suppressor, Symbol("@suppress")), + LineNumberNode(@__LINE__, @__FILE__), + :(include($filename)), + )) + end + end end end end