PkgTemplates.jl/test/runtests.jl

49 lines
1.2 KiB
Julia
Raw Normal View History

using Base.Filesystem: path_separator
2019-08-31 10:33:33 +00:00
using Pkg: Pkg
using Random: Random
using Test: @test, @testset, @test_throws
using ReferenceTests: @test_reference
using PkgTemplates
const PT = PkgTemplates
2019-09-01 01:36:33 +00:00
const PKG = "TestPkg"
2019-08-31 10:33:33 +00:00
const USER = "tester"
Random.seed!(1)
tpl(; kwargs...) = Template(; user=USER, kwargs...)
2019-09-01 01:36:33 +00:00
function with_pkg(f::Function, t::Template, pkg::AbstractString=PKG)
t(pkg)
try
f(pkg)
finally
haskey(Pkg.installed(), pkg) && Pkg.rm(pkg)
rm(joinpath(t.dir, pkg); recursive=true, force=true)
end
end
2019-08-31 10:33:33 +00:00
@testset "PkgTemplates.jl" begin
mktempdir() do dir
Pkg.activate(dir)
pushfirst!(DEPOT_PATH, dir)
try
include("template.jl")
2019-09-01 01:36:33 +00:00
include("plugin.jl")
2019-08-31 11:45:41 +00:00
2019-09-01 01:36:33 +00:00
# Quite a bit of output depends on the Julia version, and the test fixtures are
# made with Julia 1.2. Also, Windows uses CRLF which breaks everything.
if !Sys.iswindows() && VERSION.major == 1 && VERSION.minor == 2
include("reference.jl")
2019-08-31 11:45:41 +00:00
else
@info "Skipping reference tests" julia=VERSION
2019-08-31 11:45:41 +00:00
end
2019-08-31 10:33:33 +00:00
finally
popfirst!(DEPOT_PATH)
end
end
end