Skip to content

Commit 0c170c7

Browse files
authored
Format README, fix test groups (#90)
1 parent 1b2c513 commit 0c170c7

File tree

8 files changed

+39
-33
lines changed

8 files changed

+39
-33
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensorPkgSkeleton"
22
uuid = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
33
authors = ["ITensor developers <support@itensor.org> and contributors"]
4-
version = "0.3.21"
4+
version = "0.3.22"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ This step is only required once.
2525
```julia
2626
julia> using Pkg: Pkg
2727

28-
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
28+
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
2929
```
3030
or:
3131
```julia
32-
julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git")
32+
julia> Pkg.Registry.add(url = "git@github.com:ITensor/ITensorRegistry.git")
3333
```
3434
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.
3535

examples/README.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
```julia
2323
julia> using Pkg: Pkg
2424
25-
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
25+
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
2626
```
2727
=#
2828
# or:
2929
#=
3030
```julia
31-
julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git")
31+
julia> Pkg.Registry.add(url = "git@github.com:ITensor/ITensorRegistry.git")
3232
```
3333
=#
3434
# 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.

src/ITensorPkgSkeleton.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ function pkg_registration_message(; pkgname, path)
155155
```julia
156156
julia> using Pkg: Pkg
157157
158-
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
158+
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
159159
```
160160
or:
161161
```julia
162-
julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git")
162+
julia> Pkg.Registry.add(url = "git@github.com:ITensor/ITensorRegistry.git")
163163
```
164164
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.
165165

templates/docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ This step is only required once.
2525
```julia
2626
julia> using Pkg: Pkg
2727

28-
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
28+
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
2929
```
3030
or:
3131
```julia
32-
julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git")
32+
julia> Pkg.Registry.add(url = "git@github.com:ITensor/ITensorRegistry.git")
3333
```
3434
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.
3535

templates/test/test/runtests.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,42 @@ const pat = r"(?:--group=)(\w+)"
77
arg_id = findfirst(contains(pat), ARGS)
88
const GROUP = uppercase(
99
if isnothing(arg_id)
10-
get(ENV, "GROUP", "ALL")
10+
arg = get(ENV, "GROUP", "ALL")
11+
# For some reason `ENV["GROUP"]` is set to `""`
12+
# when running via GitHub Actions, so handle that case:
13+
arg == "" ? "ALL" : arg
1114
else
1215
only(match(pat, ARGS[arg_id]).captures)
1316
end,
1417
)
1518

1619
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17-
function istestfile(fn)
20+
function istestfile(path)
21+
fn = basename(path)
1822
return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
1923
end
2024
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
21-
function isexamplefile(fn)
25+
function isexamplefile(path)
26+
fn = basename(path)
2227
return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
2328
end
2429

2530
@time begin
2631
# tests in groups based on folder structure
27-
for testgroup in filter(isdir, readdir(@__DIR__))
28-
if GROUP == "ALL" || GROUP == uppercase(testgroup)
29-
groupdir = joinpath(@__DIR__, testgroup)
30-
for file in filter(istestfile, readdir(groupdir))
31-
filename = joinpath(groupdir, file)
32-
@eval @safetestset $file begin
32+
for testgroup in filter(isdir, readdir(@__DIR__; join = true))
33+
if GROUP == "ALL" || GROUP == uppercase(basename(testgroup))
34+
for filename in filter(istestfile, readdir(testgroup; join = true))
35+
@eval @safetestset $(basename(filename)) begin
3336
include($filename)
3437
end
3538
end
3639
end
3740
end
3841

3942
# single files in top folder
40-
for file in filter(istestfile, readdir(@__DIR__))
41-
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
42-
@eval @safetestset $file begin
43+
for file in filter(istestfile, readdir(@__DIR__; join = true))
44+
(basename(file) == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
45+
@eval @safetestset $(basename(file)) begin
4346
include($file)
4447
end
4548
end

test/runtests.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,42 @@ const pat = r"(?:--group=)(\w+)"
77
arg_id = findfirst(contains(pat), ARGS)
88
const GROUP = uppercase(
99
if isnothing(arg_id)
10-
get(ENV, "GROUP", "ALL")
10+
arg = get(ENV, "GROUP", "ALL")
11+
# For some reason `ENV["GROUP"]` is set to `""`
12+
# when running via GitHub Actions, so handle that case:
13+
arg == "" ? "ALL" : arg
1114
else
1215
only(match(pat, ARGS[arg_id]).captures)
1316
end,
1417
)
1518

1619
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17-
function istestfile(fn)
20+
function istestfile(path)
21+
fn = basename(path)
1822
return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
1923
end
2024
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
21-
function isexamplefile(fn)
25+
function isexamplefile(path)
26+
fn = basename(path)
2227
return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
2328
end
2429

2530
@time begin
2631
# tests in groups based on folder structure
27-
for testgroup in filter(isdir, readdir(@__DIR__))
28-
if GROUP == "ALL" || GROUP == uppercase(testgroup)
29-
groupdir = joinpath(@__DIR__, testgroup)
30-
for file in filter(istestfile, readdir(groupdir))
31-
filename = joinpath(groupdir, file)
32-
@eval @safetestset $file begin
32+
for testgroup in filter(isdir, readdir(@__DIR__; join = true))
33+
if GROUP == "ALL" || GROUP == uppercase(basename(testgroup))
34+
for filename in filter(istestfile, readdir(testgroup; join = true))
35+
@eval @safetestset $(basename(filename)) begin
3336
include($filename)
3437
end
3538
end
3639
end
3740
end
3841

3942
# single files in top folder
40-
for file in filter(istestfile, readdir(@__DIR__))
41-
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
42-
@eval @safetestset $file begin
43+
for file in filter(istestfile, readdir(@__DIR__; join = true))
44+
(basename(file) == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
45+
@eval @safetestset $(basename(file)) begin
4346
include($file)
4447
end
4548
end

0 commit comments

Comments
 (0)