From b67ad4d56a551a7b3037da4ded97fb613aaaafea Mon Sep 17 00:00:00 2001 From: mtfishman Date: Thu, 21 Nov 2024 14:16:22 -0500 Subject: [PATCH] Fix and test workflow --- src/ITensorPkgSkeleton.jl | 12 +++++++++--- templates/default/test/test_basics.jl | 8 ++++++++ test/test_basics.jl | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 templates/default/test/test_basics.jl create mode 100644 test/test_basics.jl diff --git a/src/ITensorPkgSkeleton.jl b/src/ITensorPkgSkeleton.jl index 43522ae..5c9a833 100644 --- a/src/ITensorPkgSkeleton.jl +++ b/src/ITensorPkgSkeleton.jl @@ -42,9 +42,15 @@ function change_branch_name(path, branch_name) return nothing end -function generate(pkg_name) - # TODO: Use `joinpath(first(DEPOT_PATH), "dev", pkg_name)`? - pkg_path = joinpath(homedir(), ".julia", "dev", pkg_name) +function default_path() + # TODO: Use something like `joinpath(first(DEPOT_PATH), "dev", pkg_name)` + # to make it more general. + return joinpath(homedir(), ".julia", "dev") +end + +function generate(pkg_name; path=default_path()) + pkg_path = joinpath(path, pkg_name) + # TODO: Turn this into a keyword argument. template_dir = joinpath(pkgdir(ITensorPkgSkeleton), "templates", "default") branch_name = default_branch_name() diff --git a/templates/default/test/test_basics.jl b/templates/default/test/test_basics.jl new file mode 100644 index 0000000..2722ccb --- /dev/null +++ b/templates/default/test/test_basics.jl @@ -0,0 +1,8 @@ +@eval module $(gensym()) +using {PKGNAME}: {PKGNAME} +using Test: @test, @testset + +@testset "{PKGNAME}" begin + # Tests go here. +end +end diff --git a/test/test_basics.jl b/test/test_basics.jl new file mode 100644 index 0000000..0473ecd --- /dev/null +++ b/test/test_basics.jl @@ -0,0 +1,15 @@ +@eval module $(gensym()) +using ITensorPkgSkeleton: ITensorPkgSkeleton +using Test: @test, @testset + +@testset "ITensorPkgSkeleton" begin + path = tempdir() + @test isnothing(ITensorPkgSkeleton.generate("NewPkg"; path)) + @test isdir(joinpath(path, "NewPkg")) + @test isdir(joinpath(path, "NewPkg", ".github")) + @test isdir(joinpath(path, "NewPkg", "benchmark")) + @test isdir(joinpath(path, "NewPkg", "docs")) + @test isdir(joinpath(path, "NewPkg", "src")) + @test isdir(joinpath(path, "NewPkg", "test")) +end +end