Skip to content

Commit

Permalink
Better handling of downstream tests, project template
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Nov 26, 2024
1 parent a974aed commit 20add1f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/ITensorPkgSkeleton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,7 @@ $(SIGNATURES)
All available templates when constructing a package. Includes the following templates: `$(all_templates())`
"""
function all_templates()
return [
"benchmark",
"docs",
"examples",
"formatter",
"github",
"gitignore",
"license",
"precommit",
"readme",
"src",
"test",
]
end
all_templates() = readdir(joinpath(pkgdir(ITensorPkgSkeleton), "templates"))

"""
$(SIGNATURES)
Expand All @@ -182,7 +168,7 @@ Generate a package template for a package, by default in the ITensor organizatio
```jldoctest
julia> using ITensorPkgSkeleton: ITensorPkgSkeleton;
julia> ITensorPkgSkeleton.generate("NewPkg");
julia> ITensorPkgSkeleton.generate("NewPkg"; path=mktempdir());
julia> ITensorPkgSkeleton.generate("NewPkg"; path=mktempdir());
Expand Down Expand Up @@ -226,9 +212,12 @@ function generate(
# Process downstream package information.
user_replacements = format_downstreampkgs(user_replacements)
templates = setdiff(templates, ignore_templates)
# Set default values.
if haskey(user_replacements, :downstreampkgs)
templates = [templates; "downstreampkgs"]
# Check if there are downstream tests.
if haskey(user_replacements, :downstreampkgs) &&
!isempty(user_replacements.downstreampkgs)
templates = [templates; ["downstreampkgs"]]
else
templates = setdiff(templates, ["downstreampkgs"])
end
# Fill in default path if missing.
templates = set_default_template_path.(templates)
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ using Test: @test, @testset
path = mktempdir()
ITensorPkgSkeleton.generate("NewPkg"; path)
@test isdir(joinpath(path, "NewPkg"))
@test isfile(joinpath(path, "NewPkg", "Project.toml"))
for dir in pkgdirs
@test isdir(joinpath(path, "NewPkg", dir))
end
@test !isfile(joinpath(path, "NewPkg", ".github", "workflows", "Downstream.yml"))
end
@testset "generate with downstream tests" begin
for templates in (ITensorPkgSkeleton.default_templates(), [])
Expand Down

0 comments on commit 20add1f

Please sign in to comment.