2017-08-17 22:06:05 +00:00
|
|
|
struct Foo <: GenericPlugin
|
|
|
|
gitignore::Vector{AbstractString}
|
|
|
|
src::Nullable{AbstractString}
|
|
|
|
dest::AbstractString
|
2017-08-18 04:06:33 +00:00
|
|
|
badges::Vector{Badge}
|
2017-08-17 22:06:05 +00:00
|
|
|
view::Dict{String, Any}
|
2017-08-22 20:00:48 +00:00
|
|
|
function Foo(; config_file=test_file)
|
|
|
|
new([], @__FILE__, config_file, [Badge("foo", "bar", "baz")], Dict{String, Any}())
|
|
|
|
end
|
2017-08-17 22:06:05 +00:00
|
|
|
end
|
2017-08-18 04:06:33 +00:00
|
|
|
struct Bar <: CustomPlugin end
|
|
|
|
struct Baz <: Plugin end
|
2017-08-17 22:06:05 +00:00
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
const me = "christopher-dG"
|
2017-08-23 17:50:52 +00:00
|
|
|
const gitconfig = Dict(
|
2017-08-14 18:13:26 +00:00
|
|
|
"user.name" => "Tester McTestFace",
|
|
|
|
"user.email" => "email@web.site",
|
2017-08-22 19:31:28 +00:00
|
|
|
"github.user" => "TesterMcTestFace",
|
2017-08-14 18:13:26 +00:00
|
|
|
)
|
2017-08-15 23:46:36 +00:00
|
|
|
const test_pkg = "TestPkg"
|
|
|
|
const fake_path = bin(hash("/this/file/does/not/exist"))
|
2017-08-14 22:57:49 +00:00
|
|
|
const test_file = tempname()
|
2017-08-23 17:50:52 +00:00
|
|
|
const template_text = """
|
2017-08-15 02:40:04 +00:00
|
|
|
PKGNAME: {{PKGNAME}}
|
|
|
|
VERSION: {{VERSION}}}
|
2017-08-14 18:13:26 +00:00
|
|
|
{{#DOCUMENTER}}Documenter{{/DOCUMENTER}}
|
|
|
|
{{#CODECOV}}CodeCov{{/CODECOV}}
|
2017-08-23 17:50:52 +00:00
|
|
|
{{#COVERALLS}}Coveralls{{/COVERALLS}}
|
2017-08-14 18:13:26 +00:00
|
|
|
{{#AFTER}}After{{/AFTER}}
|
|
|
|
{{#OTHER}}Other{{/OTHER}}
|
|
|
|
"""
|
|
|
|
write(test_file, template_text)
|
|
|
|
|
|
|
|
@testset "Template creation" begin
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me)
|
|
|
|
@test t.user == me
|
2017-08-22 18:54:03 +00:00
|
|
|
@test t.license == "MIT"
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.years == string(Dates.year(Dates.today()))
|
|
|
|
@test t.authors == LibGit2.getconfig("user.name", "")
|
2017-08-15 23:46:36 +00:00
|
|
|
@test t.dir == Pkg.dir()
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.julia_version == VERSION
|
2017-08-23 17:50:52 +00:00
|
|
|
@test isempty(t.gitconfig)
|
2017-08-14 18:13:26 +00:00
|
|
|
@test isempty(t.plugins)
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, license="")
|
|
|
|
@test t.license == ""
|
2017-08-22 18:54:03 +00:00
|
|
|
|
|
|
|
t = Template(; user=me, license="MPL")
|
|
|
|
@test t.license == "MPL"
|
2017-08-14 18:13:26 +00:00
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me, years=2014)
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.years == "2014"
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(user=me, years="2014-2015")
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.years == "2014-2015"
|
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me, authors="Some Guy")
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.authors == "Some Guy"
|
2017-08-16 22:58:12 +00:00
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me, authors=["Guy", "Gal"])
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.authors == "Guy, Gal"
|
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me, dir=test_file)
|
2017-08-25 04:50:44 +00:00
|
|
|
@test t.dir == abspath(test_file)
|
2017-08-25 05:09:49 +00:00
|
|
|
if is_unix() # ~ means temporary file on Windows, not $HOME.
|
|
|
|
t = Template(; user=me, dir="~/$(basename(test_file))")
|
|
|
|
@test t.dir == joinpath(homedir(), basename(test_file))
|
|
|
|
end
|
2017-08-14 18:13:26 +00:00
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me, julia_version=v"0.1.2")
|
2017-08-14 18:13:26 +00:00
|
|
|
@test t.julia_version == v"0.1.2"
|
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me, requirements=["$test_pkg 0.1"])
|
2017-08-18 07:08:03 +00:00
|
|
|
@test t.requirements == ["$test_pkg 0.1"]
|
2017-08-18 21:08:48 +00:00
|
|
|
@test_warn r".+" t = Template(; user=me, requirements=[test_pkg, test_pkg])
|
2017-08-18 07:08:03 +00:00
|
|
|
@test t.requirements == [test_pkg]
|
2017-08-28 23:28:44 +00:00
|
|
|
@test_throws ArgumentError Template(;
|
2017-08-18 21:08:48 +00:00
|
|
|
user=me,
|
2017-08-18 07:08:03 +00:00
|
|
|
requirements=[test_pkg, "$test_pkg 0.1"]
|
|
|
|
)
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, gitconfig=gitconfig)
|
|
|
|
@test t.gitconfig == gitconfig
|
2017-08-14 18:13:26 +00:00
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, gitconfig=gitconfig)
|
|
|
|
@test t.authors == gitconfig["user.name"]
|
2017-08-14 20:58:14 +00:00
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; gitconfig=gitconfig)
|
|
|
|
@test t.user == gitconfig["github.user"]
|
|
|
|
@test t.authors == gitconfig["user.name"]
|
2017-08-15 16:10:05 +00:00
|
|
|
|
|
|
|
t = Template(;
|
2017-08-18 21:08:48 +00:00
|
|
|
user=me,
|
2017-08-17 22:06:05 +00:00
|
|
|
plugins = [GitHubPages(), TravisCI(), AppVeyor(), CodeCov(), Coveralls()],
|
2017-08-14 18:13:26 +00:00
|
|
|
)
|
2017-08-17 22:06:05 +00:00
|
|
|
@test Set(keys(t.plugins)) == Set(
|
|
|
|
[GitHubPages, TravisCI, AppVeyor, CodeCov, Coveralls]
|
|
|
|
)
|
|
|
|
@test Set(values(t.plugins)) == Set(
|
|
|
|
[GitHubPages(), TravisCI(), AppVeyor(), CodeCov(), Coveralls()]
|
|
|
|
)
|
2017-08-14 18:13:26 +00:00
|
|
|
|
2017-08-16 22:58:12 +00:00
|
|
|
@test_warn r".+" t = Template(;
|
2017-08-18 21:08:48 +00:00
|
|
|
user=me,
|
2017-08-14 19:16:04 +00:00
|
|
|
plugins=[TravisCI(), TravisCI()],
|
|
|
|
)
|
2017-08-16 22:58:12 +00:00
|
|
|
|
2017-08-22 19:31:28 +00:00
|
|
|
if isempty(LibGit2.getconfig("github.user", ""))
|
2017-08-28 23:28:44 +00:00
|
|
|
@test_throws ArgumentError Template()
|
2017-08-16 22:01:52 +00:00
|
|
|
else
|
|
|
|
t = Template()
|
2017-08-22 19:31:28 +00:00
|
|
|
@test t.user == LibGit2.getconfig("github.user", "")
|
2017-08-16 22:01:52 +00:00
|
|
|
end
|
2017-08-28 23:28:44 +00:00
|
|
|
@test_throws ArgumentError Template(; user=me, license="FakeLicense")
|
2017-08-14 19:16:04 +00:00
|
|
|
end
|
|
|
|
|
2017-08-24 19:03:05 +00:00
|
|
|
if get(ENV, "TRAVIS_OS_NAME", "") != "osx"
|
|
|
|
include("interactive.jl")
|
2017-08-22 20:00:48 +00:00
|
|
|
end
|
|
|
|
|
2017-08-14 20:58:14 +00:00
|
|
|
@testset "File generation" begin
|
|
|
|
t = Template(;
|
2017-08-18 21:08:48 +00:00
|
|
|
user=me,
|
2017-08-14 20:58:14 +00:00
|
|
|
license="MPL",
|
2017-08-18 07:08:03 +00:00
|
|
|
requirements=[test_pkg],
|
2017-08-23 17:50:52 +00:00
|
|
|
gitconfig=gitconfig,
|
2017-08-17 22:06:05 +00:00
|
|
|
plugins=[Coveralls(), TravisCI(), CodeCov(), GitHubPages(), AppVeyor()],
|
2017-08-14 20:58:14 +00:00
|
|
|
)
|
2017-08-23 17:50:52 +00:00
|
|
|
temp_dir = mktempdir()
|
|
|
|
pkg_dir = joinpath(temp_dir, test_pkg)
|
2017-08-14 20:58:14 +00:00
|
|
|
|
|
|
|
temp_file = tempname()
|
|
|
|
gen_file(temp_file, "Hello, world")
|
|
|
|
@test isfile(temp_file)
|
|
|
|
@test readstring(temp_file) == "Hello, world\n"
|
|
|
|
rm(temp_file)
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
@test gen_readme(temp_dir, test_pkg, t) == ["README.md"]
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isfile(joinpath(pkg_dir, "README.md"))
|
|
|
|
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
|
|
|
rm(joinpath(pkg_dir, "README.md"))
|
|
|
|
@test contains(readme, "# $test_pkg")
|
|
|
|
for p in values(t.plugins)
|
|
|
|
@test contains(readme, join(badges(p, t.user, test_pkg), "\n"))
|
2017-08-14 20:58:14 +00:00
|
|
|
end
|
2017-08-15 23:46:36 +00:00
|
|
|
# Check the order of the badges.
|
|
|
|
@test search(readme, "github.io").start <
|
|
|
|
search(readme, "travis").start <
|
|
|
|
search(readme, "appveyor").start <
|
2017-08-17 22:06:05 +00:00
|
|
|
search(readme, "codecov").start <
|
|
|
|
search(readme, "coveralls").start
|
|
|
|
# Plugins with badges but not in BADGE_ORDER should appear at the far right side.
|
|
|
|
t.plugins[Foo] = Foo()
|
2017-08-23 17:50:52 +00:00
|
|
|
gen_readme(temp_dir, test_pkg, t)
|
2017-08-17 22:06:05 +00:00
|
|
|
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
|
|
|
rm(joinpath(pkg_dir, "README.md"))
|
|
|
|
@test search(readme, "coveralls").start < search(readme, "baz").start
|
2017-08-15 23:46:36 +00:00
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
@test gen_gitignore(temp_dir, test_pkg, t) == [".gitignore"]
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isfile(joinpath(pkg_dir, ".gitignore"))
|
|
|
|
gitignore = readstring(joinpath(pkg_dir, ".gitignore"))
|
|
|
|
rm(joinpath(pkg_dir, ".gitignore"))
|
|
|
|
@test contains(gitignore, ".DS_Store")
|
|
|
|
for p in values(t.plugins)
|
2017-08-17 06:57:58 +00:00
|
|
|
for entry in p.gitignore
|
2017-08-15 23:46:36 +00:00
|
|
|
@test contains(gitignore, entry)
|
2017-08-14 20:58:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
@test gen_license(temp_dir, test_pkg, t) == ["LICENSE"]
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isfile(joinpath(pkg_dir, "LICENSE"))
|
|
|
|
license = readchomp(joinpath(pkg_dir, "LICENSE"))
|
|
|
|
rm(joinpath(pkg_dir, "LICENSE"))
|
|
|
|
@test contains(license, t.authors)
|
|
|
|
@test contains(license, t.years)
|
|
|
|
@test contains(license, read_license(t.license))
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
@test gen_entrypoint(temp_dir, test_pkg, t) == ["src/"]
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isdir(joinpath(pkg_dir, "src"))
|
|
|
|
@test isfile(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
|
|
|
entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
|
|
|
rm(joinpath(pkg_dir, "src"); recursive=true)
|
|
|
|
@test contains(entrypoint, "module $test_pkg")
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
@test gen_require(temp_dir, test_pkg, t) == ["REQUIRE"]
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isfile(joinpath(pkg_dir, "REQUIRE"))
|
|
|
|
vf = version_floor(t.julia_version)
|
2017-08-18 07:08:03 +00:00
|
|
|
@test readchomp(joinpath(pkg_dir, "REQUIRE")) == "julia $vf\n$test_pkg"
|
2017-08-15 23:46:36 +00:00
|
|
|
rm(joinpath(pkg_dir, "REQUIRE"))
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
@test gen_tests(temp_dir, test_pkg, t) == ["test/"]
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isdir(joinpath(pkg_dir, "test"))
|
|
|
|
@test isfile(joinpath(pkg_dir, "test", "runtests.jl"))
|
|
|
|
runtests = readchomp(joinpath(pkg_dir, "test", "runtests.jl"))
|
|
|
|
rm(joinpath(pkg_dir, "test"); recursive=true)
|
|
|
|
@test contains(runtests, "using $test_pkg")
|
|
|
|
@test contains(runtests, "using Base.Test")
|
2017-08-16 22:58:12 +00:00
|
|
|
|
2017-08-28 23:28:44 +00:00
|
|
|
rm(temp_dir; recursive=true)
|
2017-08-14 20:58:14 +00:00
|
|
|
end
|
2017-08-14 22:57:49 +00:00
|
|
|
|
|
|
|
@testset "Package generation" begin
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, gitconfig=gitconfig)
|
2017-08-15 23:46:36 +00:00
|
|
|
generate(test_pkg, t)
|
2017-08-22 18:54:03 +00:00
|
|
|
@test isfile(Pkg.dir(test_pkg, "LICENSE"))
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, "REQUIRE"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, ".gitignore"))
|
|
|
|
@test isdir(Pkg.dir(test_pkg, "src"))
|
2017-08-17 06:57:58 +00:00
|
|
|
@test isfile(Pkg.dir(test_pkg, "src", "$test_pkg.jl"))
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isdir(Pkg.dir(test_pkg, "test"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, "test", "runtests.jl"))
|
|
|
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
2017-08-15 16:10:05 +00:00
|
|
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
|
|
|
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
2017-08-23 17:50:52 +00:00
|
|
|
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
2017-08-18 21:08:48 +00:00
|
|
|
@test LibGit2.url(remote) == "https://github.com/$me/$test_pkg.jl"
|
2017-08-15 16:10:05 +00:00
|
|
|
@test in("master", branches)
|
|
|
|
@test !in("gh-pages", branches)
|
2017-08-15 02:40:04 +00:00
|
|
|
@test !LibGit2.isdirty(repo)
|
2017-08-15 23:46:36 +00:00
|
|
|
rm(Pkg.dir(test_pkg); recursive=true)
|
2017-08-15 02:40:04 +00:00
|
|
|
|
2017-09-21 14:51:19 +00:00
|
|
|
generate(t, test_pkg; ssh=true) # Test the reversed-arguments method.
|
2017-08-15 23:46:36 +00:00
|
|
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
2017-08-15 16:10:05 +00:00
|
|
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
2017-08-18 21:08:48 +00:00
|
|
|
@test LibGit2.url(remote) == "git@github.com:$me/$test_pkg.jl.git"
|
2017-08-15 23:46:36 +00:00
|
|
|
rm(Pkg.dir(test_pkg); recursive=true)
|
2017-08-15 16:10:05 +00:00
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, host="gitlab.com", gitconfig=gitconfig)
|
2017-08-15 23:46:36 +00:00
|
|
|
generate(test_pkg, t)
|
|
|
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
2017-08-15 16:10:05 +00:00
|
|
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
2017-08-18 21:08:48 +00:00
|
|
|
@test LibGit2.url(remote) == "https://gitlab.com/$me/$test_pkg.jl"
|
2017-08-15 23:46:36 +00:00
|
|
|
rm(Pkg.dir(test_pkg); recursive=true)
|
2017-08-15 16:10:05 +00:00
|
|
|
|
2017-08-16 06:47:46 +00:00
|
|
|
temp_dir = mktempdir()
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, dir=temp_dir, gitconfig=gitconfig)
|
2017-08-16 06:47:46 +00:00
|
|
|
generate(test_pkg, t)
|
|
|
|
@test isdir(joinpath(temp_dir, test_pkg))
|
|
|
|
rm(temp_dir; recursive=true)
|
|
|
|
|
2017-08-15 02:40:04 +00:00
|
|
|
t = Template(;
|
2017-08-18 21:08:48 +00:00
|
|
|
user=me,
|
2017-08-23 17:50:52 +00:00
|
|
|
license="",
|
|
|
|
gitconfig=gitconfig,
|
2017-08-17 06:57:58 +00:00
|
|
|
plugins=[AppVeyor(), GitHubPages(), Coveralls(), CodeCov(), TravisCI()],
|
2017-08-15 02:40:04 +00:00
|
|
|
)
|
2017-08-15 23:46:36 +00:00
|
|
|
generate(test_pkg, t)
|
2017-08-23 17:50:52 +00:00
|
|
|
@test isdir(joinpath(Pkg.dir(), test_pkg))
|
2017-08-22 18:54:03 +00:00
|
|
|
@test !isfile(Pkg.dir(test_pkg, "LICENSE"))
|
2017-08-15 23:46:36 +00:00
|
|
|
@test isfile(Pkg.dir(test_pkg, ".travis.yml"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, ".appveyor.yml"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, ".codecov.yml"))
|
|
|
|
@test isdir(Pkg.dir(test_pkg, "docs"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, "docs", "make.jl"))
|
|
|
|
@test isdir(Pkg.dir(test_pkg, "docs", "src"))
|
|
|
|
@test isfile(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
|
|
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
2017-08-23 17:50:52 +00:00
|
|
|
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
2017-08-15 16:10:05 +00:00
|
|
|
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
|
|
|
@test in("gh-pages", branches)
|
2017-08-14 22:57:49 +00:00
|
|
|
@test !LibGit2.isdirty(repo)
|
2017-08-15 23:46:36 +00:00
|
|
|
rm(Pkg.dir(test_pkg); recursive=true)
|
2017-08-14 22:57:49 +00:00
|
|
|
|
2017-08-15 23:46:36 +00:00
|
|
|
mkdir(Pkg.dir(test_pkg))
|
|
|
|
@test_throws ArgumentError generate(test_pkg, t)
|
|
|
|
generate(test_pkg, t; force=true)
|
|
|
|
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
2017-08-16 22:15:06 +00:00
|
|
|
rm(Pkg.dir(test_pkg); recursive=true)
|
|
|
|
|
2017-08-29 11:24:39 +00:00
|
|
|
temp_file, fd = mktemp()
|
|
|
|
close(fd)
|
2017-08-31 14:51:28 +00:00
|
|
|
temp_dir = mktempdir()
|
2017-08-25 04:50:44 +00:00
|
|
|
t = Template(; user=me, dir=temp_file, gitconfig=gitconfig)
|
2017-08-31 14:51:28 +00:00
|
|
|
@test_warn r".+" generate(test_pkg, t; backup_dir=temp_dir)
|
|
|
|
rm(temp_dir; recursive=true)
|
|
|
|
temp_dir = mktempdir()
|
2017-08-29 11:24:39 +00:00
|
|
|
t = Template(; user=me, dir=joinpath(temp_file, "file"), gitconfig=gitconfig)
|
2017-08-31 14:51:28 +00:00
|
|
|
@test_warn r".+" generate(test_pkg, t; backup_dir=temp_dir)
|
|
|
|
rm(temp_dir; recursive=true)
|
2017-08-28 23:28:44 +00:00
|
|
|
rm(temp_file)
|
2017-08-25 04:50:44 +00:00
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t = Template(; user=me, gitconfig=gitconfig, plugins=[GitHubPages()])
|
2017-08-16 22:15:06 +00:00
|
|
|
generate(test_pkg, t)
|
|
|
|
readme = readstring(Pkg.dir(test_pkg, "README.md"))
|
|
|
|
index = readstring(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
|
|
|
@test readme == index
|
2017-08-16 22:58:12 +00:00
|
|
|
rm(Pkg.dir(test_pkg); recursive=true)
|
2017-08-14 22:57:49 +00:00
|
|
|
end
|
|
|
|
|
2017-08-15 02:40:04 +00:00
|
|
|
@testset "Version floor" begin
|
|
|
|
@test version_floor(v"1.0.0") == "1.0"
|
|
|
|
@test version_floor(v"1.0.1") == "1.0"
|
|
|
|
@test version_floor(v"1.0.1-pre") == "1.0"
|
|
|
|
@test version_floor(v"1.0.0-pre") == "1.0-"
|
|
|
|
end
|
|
|
|
|
|
|
|
@testset "Mustache substitution" begin
|
2017-08-17 22:06:05 +00:00
|
|
|
view = Dict{String, Any}()
|
|
|
|
text = substitute(template_text, view)
|
|
|
|
@test !contains(text, "PKGNAME: $test_pkg")
|
|
|
|
@test !contains(text, "Documenter")
|
|
|
|
@test !contains(text, "CodeCov")
|
|
|
|
@test !contains(text, "Coveralls")
|
|
|
|
@test !contains(text, "After")
|
|
|
|
@test !contains(text, "Other")
|
|
|
|
view["PKGNAME"] = test_pkg
|
|
|
|
view["OTHER"] = true
|
|
|
|
text = substitute(template_text, view)
|
|
|
|
@test contains(text, "PKGNAME: $test_pkg")
|
|
|
|
@test contains(text, "Other")
|
|
|
|
|
2017-08-18 21:08:48 +00:00
|
|
|
t = Template(; user=me)
|
2017-08-17 22:06:05 +00:00
|
|
|
view["OTHER"] = false
|
2017-08-15 02:40:04 +00:00
|
|
|
|
2017-08-17 22:06:05 +00:00
|
|
|
text = substitute(template_text, t; view=view)
|
2017-08-17 06:57:58 +00:00
|
|
|
@test contains(text, "PKGNAME: $test_pkg")
|
2017-08-15 02:40:04 +00:00
|
|
|
@test contains(text, "VERSION: $(t.julia_version.major).$(t.julia_version.minor)")
|
|
|
|
@test !contains(text, "Documenter")
|
|
|
|
@test !contains(text, "After")
|
|
|
|
@test !contains(text, "Other")
|
|
|
|
|
|
|
|
t.plugins[GitHubPages] = GitHubPages()
|
2017-08-17 22:06:05 +00:00
|
|
|
text = substitute(template_text, t; view=view)
|
2017-08-15 02:40:04 +00:00
|
|
|
@test contains(text, "Documenter")
|
|
|
|
@test contains(text, "After")
|
|
|
|
empty!(t.plugins)
|
|
|
|
|
|
|
|
t.plugins[CodeCov] = CodeCov()
|
2017-08-17 22:06:05 +00:00
|
|
|
text = substitute(template_text, t; view=view)
|
2017-08-15 02:40:04 +00:00
|
|
|
@test contains(text, "CodeCov")
|
|
|
|
@test contains(text, "After")
|
|
|
|
empty!(t.plugins)
|
|
|
|
|
2017-08-23 17:50:52 +00:00
|
|
|
t.plugins[Coveralls] = Coveralls()
|
2017-08-17 22:06:05 +00:00
|
|
|
text = substitute(template_text, t; view=view)
|
|
|
|
@test contains(text, "Coveralls")
|
|
|
|
@test contains(text, "After")
|
|
|
|
empty!(t.plugins)
|
2017-08-17 06:57:58 +00:00
|
|
|
|
2017-08-17 22:06:05 +00:00
|
|
|
view["OTHER"] = true
|
|
|
|
text = substitute(template_text, t; view=view)
|
2017-08-15 02:40:04 +00:00
|
|
|
@test contains(text, "Other")
|
|
|
|
end
|
|
|
|
|
|
|
|
@testset "License display" begin
|
|
|
|
old_stdout = STDOUT
|
|
|
|
out_read, out_write = redirect_stdout()
|
2017-08-23 17:50:52 +00:00
|
|
|
available_licenses()
|
2017-08-16 22:58:12 +00:00
|
|
|
licenses = join(Char(c) for c in readavailable(out_read))
|
2017-08-15 02:40:04 +00:00
|
|
|
show_license("MIT")
|
2017-08-16 22:58:12 +00:00
|
|
|
mit = join(Char(c) for c in readavailable(out_read))
|
2017-08-15 02:40:04 +00:00
|
|
|
close(out_write)
|
|
|
|
close(out_read)
|
|
|
|
redirect_stdout(old_stdout)
|
|
|
|
|
|
|
|
for (short, long) in LICENSES
|
|
|
|
@test contains(licenses, "$short: $long")
|
2017-08-14 22:57:49 +00:00
|
|
|
end
|
2017-08-15 02:40:04 +00:00
|
|
|
@test strip(mit) == strip(read_license("MIT"))
|
|
|
|
@test strip(read_license("MIT")) == strip(readstring(joinpath(LICENSE_DIR, "MIT")))
|
2017-08-17 06:57:58 +00:00
|
|
|
@test_throws ArgumentError read_license(fake_path)
|
2017-08-14 22:57:49 +00:00
|
|
|
end
|
2017-08-16 22:58:12 +00:00
|
|
|
|
2017-10-02 01:43:03 +00:00
|
|
|
@testset "Plugins" begin
|
|
|
|
user = gitconfig["github.user"]
|
|
|
|
t = Template(; user=me)
|
|
|
|
temp_dir = mktempdir()
|
|
|
|
pkg_dir = joinpath(temp_dir, test_pkg)
|
|
|
|
|
|
|
|
badge = Badge("A", "B", "C")
|
|
|
|
@test badge.hover == "A"
|
|
|
|
@test badge.image == "B"
|
|
|
|
@test badge.link == "C"
|
|
|
|
@test format(badge) == "[](C)"
|
|
|
|
|
|
|
|
p = Bar()
|
|
|
|
@test isempty(badges(p, user, test_pkg))
|
|
|
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
|
|
|
|
|
|
|
p = Baz()
|
|
|
|
@test isempty(badges(p, user, test_pkg))
|
|
|
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
|
|
|
|
|
|
|
include(joinpath("plugins", "travisci.jl"))
|
|
|
|
include(joinpath("plugins", "appveyor.jl"))
|
|
|
|
include(joinpath("plugins", "codecov.jl"))
|
|
|
|
include(joinpath("plugins", "coveralls.jl"))
|
|
|
|
include(joinpath("plugins", "githubpages.jl"))
|
|
|
|
|
|
|
|
rm(temp_dir; recursive=true)
|
|
|
|
end
|
|
|
|
|
2017-08-16 22:58:12 +00:00
|
|
|
rm(test_file)
|