From 20add1f6b2606a01c209c4f0ba18cc98e05d7eb3 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Mon, 25 Nov 2024 20:17:32 -0500 Subject: [PATCH] Better handling of downstream tests, project template --- src/ITensorPkgSkeleton.jl | 27 ++++++++----------------- templates/{src => project}/Project.toml | 0 test/test_basics.jl | 2 ++ 3 files changed, 10 insertions(+), 19 deletions(-) rename templates/{src => project}/Project.toml (100%) diff --git a/src/ITensorPkgSkeleton.jl b/src/ITensorPkgSkeleton.jl index c139551..4de80eb 100644 --- a/src/ITensorPkgSkeleton.jl +++ b/src/ITensorPkgSkeleton.jl @@ -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) @@ -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()); @@ -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) diff --git a/templates/src/Project.toml b/templates/project/Project.toml similarity index 100% rename from templates/src/Project.toml rename to templates/project/Project.toml diff --git a/test/test_basics.jl b/test/test_basics.jl index 8506b88..9e6f46c 100644 --- a/test/test_basics.jl +++ b/test/test_basics.jl @@ -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(), [])