Build package in a temp directory, refactor code
This commit is contained in:
parent
9824d1a61a
commit
a14131ae15
170
src/generate.jl
170
src/generate.jl
@ -22,21 +22,19 @@ function generate(
|
|||||||
force::Bool=false,
|
force::Bool=false,
|
||||||
ssh::Bool=false,
|
ssh::Bool=false,
|
||||||
)
|
)
|
||||||
|
|
||||||
pkg_name = Pkg.splitjl(pkg_name)
|
pkg_name = Pkg.splitjl(pkg_name)
|
||||||
pkg_dir = joinpath(t.path, pkg_name)
|
pkg_dir = joinpath(t.dir, pkg_name)
|
||||||
|
temp_pkg_dir = joinpath(t.temp_dir, pkg_name)
|
||||||
|
|
||||||
if force && ispath(pkg_dir)
|
if !force && ispath(pkg_dir)
|
||||||
rm(pkg_dir; recursive=true)
|
|
||||||
elseif ispath(pkg_dir)
|
|
||||||
throw(ArgumentError(
|
throw(ArgumentError(
|
||||||
"A directory already exists at $pkg_dir, use force=true to overwrite it."
|
"Something already exists at $pkg_dir, use force=true to overwrite it."
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Initialize the repo and configure it.
|
# Initialize the repo and configure it.
|
||||||
repo = LibGit2.init(pkg_dir)
|
repo = LibGit2.init(temp_pkg_dir)
|
||||||
info("Initialized git repo at $pkg_dir")
|
info("Initialized git repo at $temp_pkg_dir")
|
||||||
cfg = LibGit2.GitConfig(repo)
|
cfg = LibGit2.GitConfig(repo)
|
||||||
info("Configuring git")
|
info("Configuring git")
|
||||||
for (key, val) in t.git_config
|
for (key, val) in t.git_config
|
||||||
@ -59,124 +57,115 @@ function generate(
|
|||||||
LibGit2.branch!(repo, "master")
|
LibGit2.branch!(repo, "master")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate plugin files and common stuff like tests/entrypoint/readme.
|
# Generate the files.
|
||||||
# File generation functions that fail should return nothing.
|
files = vcat(
|
||||||
files = filter(x -> x != nothing, [
|
gen_license(pkg_name, t),
|
||||||
gen_license(pkg_dir, t.license, t.authors, t.years),
|
gen_entrypoint(pkg_name, t),
|
||||||
gen_entrypoint(pkg_dir),
|
gen_require(temp_pkg_dir, t),
|
||||||
gen_require(pkg_dir, t.julia_version),
|
gen_tests(pkg_name, t),
|
||||||
gen_tests(pkg_dir),
|
gen_readme(pkg_name, t),
|
||||||
gen_readme(pkg_dir, t),
|
gen_gitignore(pkg_name, t),
|
||||||
gen_gitignore(pkg_dir, t.plugins),
|
vcat(collect(gen_plugin(plugin, t, pkg_name) for plugin in values(t.plugins))...),
|
||||||
])
|
)
|
||||||
|
|
||||||
for plugin in values(t.plugins)
|
|
||||||
plugin_files = gen_plugin(plugin, t, pkg_name)
|
|
||||||
append!(files, plugin_files)
|
|
||||||
info("Generated files/directories: $(join(plugin_files, ", "))")
|
|
||||||
end
|
|
||||||
|
|
||||||
LibGit2.add!(repo, files...)
|
LibGit2.add!(repo, files...)
|
||||||
info("Staged $(length(files)) files/directories: $(join(files, ", "))")
|
info("Staged $(length(files)) files/directories: $(join(files, ", "))")
|
||||||
LibGit2.commit(repo, "Files generated by PkgTemplates")
|
LibGit2.commit(repo, "Files generated by PkgTemplates")
|
||||||
info("Committed files generated by PkgTemplates")
|
info("Committed files generated by PkgTemplates")
|
||||||
|
info("Copying temporary package directory into $(t.dir)")
|
||||||
|
cp(temp_pkg_dir, pkg_dir; remove_destination=force)
|
||||||
|
rm(temp_pkg_dir; recursive=true)
|
||||||
info("Finished")
|
info("Finished")
|
||||||
warn("Remember to push all created branches to your remote: git push --all -u")
|
warn("Remember to push all created branches to your remote: git push --all -u")
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_readme(pkg_dir::AbstractString, t::Template) -> String
|
gen_readme(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||||
|
|
||||||
Generate a README with badges for each enabled plugin.
|
Create a README in the temp package directory with badges for each enabled plugin.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `pkg_dir::AbstractString`: The package directory.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `t::Template`: The template whose README we are generating.
|
* `template::Template`: The template whose README we are generating.
|
||||||
|
|
||||||
Returns the name of the generated file.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_readme(pkg_dir::AbstractString, t::Template)
|
function gen_readme(pkg_name::AbstractString, template::Template)
|
||||||
pkg_name = basename(pkg_dir)
|
|
||||||
text = "# $pkg_name\n"
|
text = "# $pkg_name\n"
|
||||||
|
|
||||||
# We want badges to be laid out: docs -> CI -> coverage.
|
# We want badges to be laid out: docs -> CI -> coverage.
|
||||||
ordering = [GitHubPages, TravisCI, AppVeyor, CodeCov]
|
ordering = [GitHubPages, TravisCI, AppVeyor, CodeCov]
|
||||||
for plugin_type in ordering
|
for plugin_type in ordering
|
||||||
if haskey(t.plugins, plugin_type)
|
if haskey(template.plugins, plugin_type)
|
||||||
text *= "\n" * join(badges(t.plugins[plugin_type], t.user, pkg_name), "\n")
|
text *= "\n"
|
||||||
|
text *= join(
|
||||||
|
badges(template.plugins[plugin_type], template.user, pkg_name),
|
||||||
|
"\n",
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, "README.md"), text)
|
gen_file(joinpath(template.temp_dir, pkg_name, "README.md"), text)
|
||||||
return "README.md"
|
return ["README.md"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_gitignore(pkg_dir, plugins) -> Union{String,Void}
|
gen_gitignore(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||||
|
|
||||||
Generate a .gitignore from the list of enabled `plugins`.
|
Create a .gitignore in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `pkg_dir::AbstractString`: The package directory.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `plugins::Dict{DataType, Plugin}`: The enabled plugins.
|
* `template::Template`: The template whose .gitignore we are generating.
|
||||||
|
|
||||||
Returns the name of the generated file.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_gitignore(pkg_dir::AbstractString, plugins::Dict{DataType,Plugin})
|
function gen_gitignore(pkg_name::AbstractString, template::Template)
|
||||||
text = ".DS_Store\n"
|
text = ".DS_Store\n"
|
||||||
for plugin in values(plugins)
|
for plugin in values(template.plugins)
|
||||||
if !isempty(plugin.gitignore_files)
|
if !isempty(plugin.gitignore_files)
|
||||||
text *= join(plugin.gitignore_files, "\n") * "\n"
|
text *= join(plugin.gitignore_files, "\n") * "\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, ".gitignore"), text)
|
gen_file(joinpath(template.temp_dir, pkg_name, ".gitignore"), text)
|
||||||
return ".gitignore"
|
return [".gitignore"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_license(pkg_dir, license, authors, years) -> Union{String, Void}
|
gen_license(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||||
|
|
||||||
Creates a license file for the package.
|
Create a LICENSE in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `pkg_dir::AbstractString`: The package directory.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `license::Union{AbstractString, Void}`: Name of the license, `nothing` if no license.
|
* `template::Template`: The template whose LICENSE we are generating.
|
||||||
* `authors::AbstractString`: Author, or comma-delimited list of authors, of the package.
|
|
||||||
* `years::AbstractString`: Copyright year or range of copyright years.
|
|
||||||
|
|
||||||
Returns the name of the generated file, or `nothing` in the case that
|
Returns an array of generated file/directory names.
|
||||||
no license is generated.
|
|
||||||
"""
|
"""
|
||||||
function gen_license(
|
function gen_license(pkg_name::AbstractString, template::Template)
|
||||||
pkg_dir::AbstractString,
|
if template.license == nothing
|
||||||
license::Union{AbstractString, Void},
|
return String[]
|
||||||
authors::AbstractString,
|
|
||||||
years::AbstractString
|
|
||||||
)
|
|
||||||
if license == nothing
|
|
||||||
return nothing
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pkg_name = basename(pkg_dir)
|
text = "Copyright (c) $(template.years) $(template.authors)\n"
|
||||||
text = "Copyright (c) $years $authors\n" * read_license(license)
|
text *= read_license(template.license)
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, "LICENSE"), text)
|
gen_file(joinpath(template.temp_dir, pkg_name, "LICENSE"), text)
|
||||||
return "LICENSE"
|
return ["LICENSE"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_entrypoint(pkg_dir::AbstractString) -> String
|
gen_entrypoint(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||||
|
|
||||||
Creates the module entrypoint ("src/\$pkg_name.jl") in `pkg_dir`.
|
Create the module entrypoint in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `pkg_dir::AbstractString`: The package directory.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
* `template::Template`: The template whose entrypoint we are generating.
|
||||||
|
|
||||||
Returns the name of the generated directory.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_entrypoint(pkg_dir::AbstractString)
|
function gen_entrypoint(pkg_name::AbstractString, template::Template)
|
||||||
pkg_name = basename(pkg_dir)
|
|
||||||
text = """
|
text = """
|
||||||
module $pkg_name
|
module $pkg_name
|
||||||
|
|
||||||
@ -185,49 +174,50 @@ function gen_entrypoint(pkg_dir::AbstractString)
|
|||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, "src", "$pkg_name.jl"), text)
|
gen_file(joinpath(template.temp_dir, pkg_name, "src", "$pkg_name.jl"), text)
|
||||||
return "src/"
|
return ["src/"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_require(pkg_dir::AbstractString, julia_version::VersionNumber) -> String
|
gen_require(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||||
|
|
||||||
Create the requirements file in the package directory.
|
Create the REQUIRE file in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `pkg_dir::AbstractString`: The package directory.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `julia_version::VersionNumber`: The minimum Julia version to support.
|
* `template::Template`: The template whose REQUIRE we are generating.
|
||||||
|
|
||||||
Returns the name of the generated file.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_require(pkg_dir::AbstractString, julia_version::VersionNumber)
|
function gen_require(pkg_name::AbstractString, template::Template)
|
||||||
text = "julia $(version_floor(julia_version))\n"
|
text = "julia $(version_floor(template.julia_version))\n"
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, "REQUIRE"), text)
|
gen_file(joinpath(template.temp_dir, pkg_name, "REQUIRE"), text)
|
||||||
return "REQUIRE"
|
return ["REQUIRE"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_tests(pkg_dir::AbstractString) -> String
|
gen_tests(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||||
|
|
||||||
Creates the test file "test/runtests.jl" in the package directory.
|
Create the test directory and entrypoint in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `pkg_dir::AbstractString`: The package directory.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
* `template::Template`: The template whose tests we are generating.
|
||||||
|
|
||||||
Returns the name of the generated directory.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_tests(pkg_dir::AbstractString)
|
function gen_tests(pkg_name::AbstractString, template::Template)
|
||||||
text = """
|
text = """
|
||||||
using $(basename(pkg_dir))
|
using $pkg_name
|
||||||
using Base.Test
|
using Base.Test
|
||||||
|
|
||||||
# Write your own tests here.
|
# Write your own tests here.
|
||||||
@test 1 == 2
|
@test 1 == 2
|
||||||
"""
|
"""
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, "test", "runtests.jl"), text)
|
gen_file(joinpath(template.temp_dir, pkg_name, "test", "runtests.jl"), text)
|
||||||
return "test/"
|
return ["test/"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -52,14 +52,13 @@ Generate a .appveyor.yml.
|
|||||||
* `template::Template`: Template configuration and plugins.
|
* `template::Template`: Template configuration and plugins.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
|
||||||
Returns an array of generated files.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_plugin(plugin::AppVeyor, template::Template, pkg_name::AbstractString)
|
function gen_plugin(plugin::AppVeyor, template::Template, pkg_name::AbstractString)
|
||||||
if plugin.config_file == nothing
|
if plugin.config_file == nothing
|
||||||
return String[]
|
return String[]
|
||||||
end
|
end
|
||||||
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
||||||
pkg_dir = joinpath(template.path, pkg_name)
|
gen_file(joinpath(template.temp_dir, pkg_name, ".appveyor.yml"), text)
|
||||||
gen_file(joinpath(pkg_dir, ".appveyor.yml"), text)
|
|
||||||
return [".appveyor.yml"]
|
return [".appveyor.yml"]
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ Add CodeCov to a template's plugins to enable CodeCov coverage reports.
|
|||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
badges(\_::CodeCov, pkg_name::AbstractString, t::Template) -> Vector{String}
|
badges(\_::CodeCov, user::AbstractString, pkg_name::AbstractString) -> Vector{String}
|
||||||
|
|
||||||
Generate Markdown badges for the current package.
|
Generate Markdown badges for the current package.
|
||||||
|
|
||||||
@ -52,14 +52,13 @@ Generate a .codecov.yml.
|
|||||||
* `template::Template`: Template configuration and plugins.
|
* `template::Template`: Template configuration and plugins.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
|
||||||
Returns an array of generated files.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_plugin(plugin::CodeCov, template::Template, pkg_name::AbstractString)
|
function gen_plugin(plugin::CodeCov, template::Template, pkg_name::AbstractString)
|
||||||
if plugin.config_file == nothing
|
if plugin.config_file == nothing
|
||||||
return String[]
|
return String[]
|
||||||
end
|
end
|
||||||
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
||||||
pkg_dir = joinpath(template.path, pkg_name)
|
gen_file(joinpath(template.temp_dir, pkg_name, ".codecov.yml"), text)
|
||||||
gen_file(joinpath(pkg_dir, ".codecov.yml"), text)
|
|
||||||
return [".codecov.yml"]
|
return [".codecov.yml"]
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractSt
|
|||||||
info("Adding Documenter.jl")
|
info("Adding Documenter.jl")
|
||||||
Pkg.add("Documenter")
|
Pkg.add("Documenter")
|
||||||
end
|
end
|
||||||
path = joinpath(template.path, pkg_name)
|
path = joinpath(template.temp_dir, pkg_name)
|
||||||
docs_dir = joinpath(path, "docs", "src")
|
docs_dir = joinpath(path, "docs", "src")
|
||||||
mkpath(docs_dir)
|
mkpath(docs_dir)
|
||||||
if !isempty(plugin.assets)
|
if !isempty(plugin.assets)
|
||||||
@ -62,11 +62,7 @@ function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractSt
|
|||||||
open(joinpath(docs_dir, "index.md"), "w") do fp
|
open(joinpath(docs_dir, "index.md"), "w") do fp
|
||||||
write(fp, "# $pkg_name")
|
write(fp, "# $pkg_name")
|
||||||
end
|
end
|
||||||
readme_path = ""
|
readme_path = joinpath(template.temp_dir, pkg_name, "README.md")
|
||||||
try
|
|
||||||
readme_path = joinpath(template.path, pkg_name, "README.md")
|
|
||||||
catch
|
|
||||||
end
|
|
||||||
if isfile(readme_path)
|
if isfile(readme_path)
|
||||||
cp(readme_path, joinpath(docs_dir, "index.md"), remove_destination=true)
|
cp(readme_path, joinpath(docs_dir, "index.md"), remove_destination=true)
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,7 @@ to GitHub Pages.
|
|||||||
* `template::Template`: Template configuration and plugins.
|
* `template::Template`: Template configuration and plugins.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
|
||||||
Returns an array of generated directories.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_plugin(plugin::GitHubPages, template::Template, pkg_name::AbstractString)
|
function gen_plugin(plugin::GitHubPages, template::Template, pkg_name::AbstractString)
|
||||||
invoke(
|
invoke(
|
||||||
@ -59,7 +59,7 @@ function gen_plugin(plugin::GitHubPages, template::Template, pkg_name::AbstractS
|
|||||||
plugin, template, pkg_name
|
plugin, template, pkg_name
|
||||||
)
|
)
|
||||||
if haskey(template.plugins, TravisCI)
|
if haskey(template.plugins, TravisCI)
|
||||||
docs_src = joinpath(template.path, pkg_name, "docs", "src")
|
docs_src = joinpath(template.temp_dir, pkg_name, "docs", "src")
|
||||||
open(joinpath(dirname(docs_src), "make.jl"), "a") do file
|
open(joinpath(dirname(docs_src), "make.jl"), "a") do file
|
||||||
write(
|
write(
|
||||||
file,
|
file,
|
||||||
|
@ -52,14 +52,13 @@ Generate a .travis.yml.
|
|||||||
* `template::Template`: Template configuration and plugins.
|
* `template::Template`: Template configuration and plugins.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
|
||||||
Returns an array of generated files.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_plugin(plugin::TravisCI, template::Template, pkg_name::AbstractString)
|
function gen_plugin(plugin::TravisCI, template::Template, pkg_name::AbstractString)
|
||||||
if plugin.config_file == nothing
|
if plugin.config_file == nothing
|
||||||
return String[]
|
return String[]
|
||||||
end
|
end
|
||||||
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
||||||
pkg_dir = joinpath(template.path, pkg_name)
|
gen_file(joinpath(template.temp_dir, pkg_name, ".travis.yml"), text)
|
||||||
gen_file(joinpath(pkg_dir, ".travis.yml"), text)
|
|
||||||
return [".travis.yml"]
|
return [".travis.yml"]
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ Records common information used to generate a package.
|
|||||||
appear on the license. Supply a string for one author, and an array for multiple.
|
appear on the license. Supply a string for one author, and an array for multiple.
|
||||||
* `years::Union{Int, AbstractString}=string(Dates.year(Dates.today()))`: Copyright years
|
* `years::Union{Int, AbstractString}=string(Dates.year(Dates.today()))`: Copyright years
|
||||||
on the license. Can be supplied by a number, or a string such as "2016 - 2017".
|
on the license. Can be supplied by a number, or a string such as "2016 - 2017".
|
||||||
* `path::AbstractString=Pkg.dir()`: Directory in which the package will go.
|
* `dir::AbstractString=Pkg.dir()`: Directory in which the package will go.
|
||||||
* `julia_version::VersionNumber=VERSION`: Minimum allowed Julia version.
|
* `julia_version::VersionNumber=VERSION`: Minimum allowed Julia version.
|
||||||
* `git_config::Dict{String, String}=Dict{String, String}()`: Git configuration options.
|
* `git_config::Dict{String, String}=Dict{String, String}()`: Git configuration options.
|
||||||
* `plugins::Vector{Plugin}`: A list of `Plugin`s that the package will include.
|
* `plugins::Vector{Plugin}`: A list of `Plugin`s that the package will include.
|
||||||
@ -27,7 +27,8 @@ Records common information used to generate a package.
|
|||||||
license::Union{AbstractString, Void}
|
license::Union{AbstractString, Void}
|
||||||
authors::Union{AbstractString, Array}
|
authors::Union{AbstractString, Array}
|
||||||
years::AbstractString
|
years::AbstractString
|
||||||
path::AbstractString
|
dir::AbstractString
|
||||||
|
temp_dir::AbstractString
|
||||||
julia_version::VersionNumber
|
julia_version::VersionNumber
|
||||||
git_config::Dict{String, String}
|
git_config::Dict{String, String}
|
||||||
plugins::Dict{DataType, Plugin}
|
plugins::Dict{DataType, Plugin}
|
||||||
@ -38,7 +39,7 @@ Records common information used to generate a package.
|
|||||||
license::Union{AbstractString, Void}=nothing,
|
license::Union{AbstractString, Void}=nothing,
|
||||||
authors::Union{AbstractString, Array}=LibGit2.getconfig("user.name", ""),
|
authors::Union{AbstractString, Array}=LibGit2.getconfig("user.name", ""),
|
||||||
years::Union{Int, AbstractString}=string(Dates.year(Dates.today())),
|
years::Union{Int, AbstractString}=string(Dates.year(Dates.today())),
|
||||||
path::AbstractString=Pkg.dir(),
|
dir::AbstractString=Pkg.dir(),
|
||||||
julia_version::VersionNumber=VERSION,
|
julia_version::VersionNumber=VERSION,
|
||||||
git_config::Dict{String, String}=Dict{String, String}(),
|
git_config::Dict{String, String}=Dict{String, String}(),
|
||||||
plugins::Vector{P}=Vector{Plugin}(),
|
plugins::Vector{P}=Vector{Plugin}(),
|
||||||
@ -67,13 +68,15 @@ Records common information used to generate a package.
|
|||||||
|
|
||||||
years = string(years)
|
years = string(years)
|
||||||
|
|
||||||
|
temp_dir = mktempdir()
|
||||||
|
|
||||||
plugin_dict = Dict{DataType, Plugin}(typeof(p) => p for p in plugins)
|
plugin_dict = Dict{DataType, Plugin}(typeof(p) => p for p in plugins)
|
||||||
if (length(plugins) != length(plugin_dict))
|
if (length(plugins) != length(plugin_dict))
|
||||||
warn("Plugin list contained duplicates, only the last of each type was kept")
|
warn("Plugin list contained duplicates, only the last of each type was kept")
|
||||||
end
|
end
|
||||||
|
|
||||||
new(
|
new(
|
||||||
user, host, license, authors, years, path,
|
user, host, license, authors, years, dir, temp_dir,
|
||||||
julia_version, git_config, plugin_dict
|
julia_version, git_config, plugin_dict
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
295
test/tests.jl
295
test/tests.jl
@ -3,8 +3,8 @@ const git_config = Dict(
|
|||||||
"user.email" => "email@web.site",
|
"user.email" => "email@web.site",
|
||||||
"github.username" => "TesterMcTestFace",
|
"github.username" => "TesterMcTestFace",
|
||||||
)
|
)
|
||||||
|
const test_pkg = "TestPkg"
|
||||||
const fake_path = joinpath(tempdir(), tempdir())
|
const fake_path = bin(hash("/this/file/does/not/exist"))
|
||||||
const test_file = tempname()
|
const test_file = tempname()
|
||||||
template_text = """
|
template_text = """
|
||||||
PKGNAME: {{PKGNAME}}
|
PKGNAME: {{PKGNAME}}
|
||||||
@ -22,7 +22,7 @@ write(test_file, template_text)
|
|||||||
@test t.license == nothing
|
@test t.license == nothing
|
||||||
@test t.years == string(Dates.year(Dates.today()))
|
@test t.years == string(Dates.year(Dates.today()))
|
||||||
@test t.authors == LibGit2.getconfig("user.name", "")
|
@test t.authors == LibGit2.getconfig("user.name", "")
|
||||||
@test t.path == Pkg.dir()
|
@test t.dir == Pkg.dir()
|
||||||
@test t.julia_version == VERSION
|
@test t.julia_version == VERSION
|
||||||
@test isempty(t.git_config)
|
@test isempty(t.git_config)
|
||||||
@test isempty(t.plugins)
|
@test isempty(t.plugins)
|
||||||
@ -40,8 +40,8 @@ write(test_file, template_text)
|
|||||||
t = Template(; user="invenia", authors=["Guy", "Gal"])
|
t = Template(; user="invenia", authors=["Guy", "Gal"])
|
||||||
@test t.authors == "Guy, Gal"
|
@test t.authors == "Guy, Gal"
|
||||||
|
|
||||||
t = Template(; user="invenia", path=test_file)
|
t = Template(; user="invenia", dir=test_file)
|
||||||
@test t.path == test_file
|
@test t.dir == test_file
|
||||||
|
|
||||||
t = Template(; user="invenia", julia_version=v"0.1.2")
|
t = Template(; user="invenia", julia_version=v"0.1.2")
|
||||||
@test t.julia_version == v"0.1.2"
|
@test t.julia_version == v"0.1.2"
|
||||||
@ -106,6 +106,7 @@ end
|
|||||||
git_config=git_config,
|
git_config=git_config,
|
||||||
plugins=[TravisCI(), CodeCov(), GitHubPages(), AppVeyor()],
|
plugins=[TravisCI(), CodeCov(), GitHubPages(), AppVeyor()],
|
||||||
)
|
)
|
||||||
|
pkg_dir = joinpath(t.temp_dir, test_pkg)
|
||||||
|
|
||||||
temp_file = tempname()
|
temp_file = tempname()
|
||||||
gen_file(temp_file, "Hello, world")
|
gen_file(temp_file, "Hello, world")
|
||||||
@ -113,79 +114,73 @@ end
|
|||||||
@test readstring(temp_file) == "Hello, world\n"
|
@test readstring(temp_file) == "Hello, world\n"
|
||||||
rm(temp_file)
|
rm(temp_file)
|
||||||
|
|
||||||
mktempdir() do temp_dir
|
@test gen_readme(test_pkg, t) == ["README.md"]
|
||||||
@test gen_readme(temp_dir, t) == "README.md"
|
@test isfile(joinpath(pkg_dir, "README.md"))
|
||||||
@test isfile(joinpath(temp_dir, "README.md"))
|
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
||||||
readme = readchomp(joinpath(temp_dir, "README.md"))
|
rm(joinpath(pkg_dir, "README.md"))
|
||||||
@test contains(readme, "# $(basename(temp_dir))")
|
@test contains(readme, "# $test_pkg")
|
||||||
for p in values(t.plugins)
|
for p in values(t.plugins)
|
||||||
@test contains(readme, join(badges(p, t.user, basename(temp_dir)), "\n"))
|
@test contains(readme, join(badges(p, t.user, test_pkg), "\n"))
|
||||||
end
|
|
||||||
# Check the order of the badges.
|
|
||||||
@test search(readme, "github.io").start <
|
|
||||||
search(readme, "travis").start <
|
|
||||||
search(readme, "appveyor").start <
|
|
||||||
search(readme, "codecov").start
|
|
||||||
end
|
end
|
||||||
|
# Check the order of the badges.
|
||||||
|
@test search(readme, "github.io").start <
|
||||||
|
search(readme, "travis").start <
|
||||||
|
search(readme, "appveyor").start <
|
||||||
|
search(readme, "codecov").start
|
||||||
|
|
||||||
mktempdir() do temp_dir
|
@test gen_gitignore(test_pkg, t) == [".gitignore"]
|
||||||
@test gen_gitignore(temp_dir, t.plugins) == ".gitignore"
|
@test isfile(joinpath(pkg_dir, ".gitignore"))
|
||||||
@test isfile(joinpath(temp_dir, ".gitignore"))
|
gitignore = readstring(joinpath(pkg_dir, ".gitignore"))
|
||||||
gitignore = readstring(joinpath(temp_dir, ".gitignore"))
|
rm(joinpath(pkg_dir, ".gitignore"))
|
||||||
@test contains(gitignore, ".DS_Store")
|
@test contains(gitignore, ".DS_Store")
|
||||||
for p in values(t.plugins)
|
for p in values(t.plugins)
|
||||||
for entry in p.gitignore_files
|
for entry in p.gitignore_files
|
||||||
@test contains(gitignore, entry)
|
@test contains(gitignore, entry)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mktempdir() do temp_dir
|
@test gen_license(test_pkg, t) == ["LICENSE"]
|
||||||
@test gen_license(temp_dir, t.license, t.authors, t.years) == "LICENSE"
|
@test isfile(joinpath(pkg_dir, "LICENSE"))
|
||||||
@test isfile(joinpath(temp_dir, "LICENSE"))
|
license = readchomp(joinpath(pkg_dir, "LICENSE"))
|
||||||
license = readchomp(joinpath(temp_dir, "LICENSE"))
|
rm(joinpath(pkg_dir, "LICENSE"))
|
||||||
@test contains(license, t.authors)
|
@test contains(license, t.authors)
|
||||||
@test contains(license, t.years)
|
@test contains(license, t.years)
|
||||||
@test contains(license, read_license(t.license))
|
@test contains(license, read_license(t.license))
|
||||||
end
|
|
||||||
|
|
||||||
mktempdir() do temp_dir
|
@test gen_entrypoint(test_pkg, t) == ["src/"]
|
||||||
@test gen_entrypoint(temp_dir) == "src/"
|
@test isdir(joinpath(pkg_dir, "src"))
|
||||||
@test isdir(joinpath(temp_dir, "src"))
|
@test isfile(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
||||||
@test isfile(joinpath(temp_dir, "src", "$(basename(temp_dir)).jl"))
|
entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
||||||
entrypoint = readchomp(joinpath(temp_dir, "src", "$(basename(temp_dir)).jl"))
|
rm(joinpath(pkg_dir, "src"); recursive=true)
|
||||||
@test contains(entrypoint, "module $(basename(temp_dir))")
|
@test contains(entrypoint, "module $test_pkg")
|
||||||
end
|
|
||||||
|
|
||||||
mktempdir() do temp_dir
|
@test gen_require(test_pkg, t) == ["REQUIRE"]
|
||||||
@test gen_require(temp_dir, t.julia_version) == "REQUIRE"
|
@test isfile(joinpath(pkg_dir, "REQUIRE"))
|
||||||
@test isfile(joinpath(temp_dir, "REQUIRE"))
|
vf = version_floor(t.julia_version)
|
||||||
vf = version_floor(t.julia_version)
|
@test readchomp(joinpath(pkg_dir, "REQUIRE")) == "julia $vf"
|
||||||
@test readchomp(joinpath(temp_dir, "REQUIRE")) == "julia $vf"
|
rm(joinpath(pkg_dir, "REQUIRE"))
|
||||||
end
|
|
||||||
|
|
||||||
mktempdir() do temp_dir
|
@test gen_tests(test_pkg, t) == ["test/"]
|
||||||
@test gen_tests(temp_dir) == "test/"
|
@test isdir(joinpath(pkg_dir, "test"))
|
||||||
@test isdir(joinpath(temp_dir, "test"))
|
@test isfile(joinpath(pkg_dir, "test", "runtests.jl"))
|
||||||
@test isfile(joinpath(temp_dir, "test", "runtests.jl"))
|
runtests = readchomp(joinpath(pkg_dir, "test", "runtests.jl"))
|
||||||
runtests = readchomp(joinpath(temp_dir, "test", "runtests.jl"))
|
rm(joinpath(pkg_dir, "test"); recursive=true)
|
||||||
@test contains(runtests, "using $(basename(temp_dir))")
|
@test contains(runtests, "using $test_pkg")
|
||||||
@test contains(runtests, "using Base.Test")
|
@test contains(runtests, "using Base.Test")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Package generation" begin
|
@testset "Package generation" begin
|
||||||
t = Template(; user="invenia")
|
t = Template(; user="invenia")
|
||||||
generate("TestPkg", t)
|
generate(test_pkg, t)
|
||||||
@test !isfile(Pkg.dir("TestPkg", "LICENSE"))
|
@test !isfile(Pkg.dir(test_pkg, "LICENSE"))
|
||||||
@test isfile(Pkg.dir("TestPkg", "README.md"))
|
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
||||||
@test isfile(Pkg.dir("TestPkg", "REQUIRE"))
|
@test isfile(Pkg.dir(test_pkg, "REQUIRE"))
|
||||||
@test isfile(Pkg.dir("TestPkg", ".gitignore"))
|
@test isfile(Pkg.dir(test_pkg, ".gitignore"))
|
||||||
@test isdir(Pkg.dir("TestPkg", "src"))
|
@test isdir(Pkg.dir(test_pkg, "src"))
|
||||||
@test isfile(Pkg.dir("TestPkg", "src", "TestPkg.jl"))
|
@test isfile(Pkg.dir(test_pkg, "src", "TestPkg.jl"))
|
||||||
@test isdir(Pkg.dir("TestPkg", "test"))
|
@test isdir(Pkg.dir(test_pkg, "test"))
|
||||||
@test isfile(Pkg.dir("TestPkg", "test", "runtests.jl"))
|
@test isfile(Pkg.dir(test_pkg, "test", "runtests.jl"))
|
||||||
repo = LibGit2.GitRepo(Pkg.dir("TestPkg"))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
||||||
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
||||||
@test LibGit2.getconfig(repo, "user.name", "") == LibGit2.getconfig("user.name", "")
|
@test LibGit2.getconfig(repo, "user.name", "") == LibGit2.getconfig("user.name", "")
|
||||||
@ -193,20 +188,20 @@ end
|
|||||||
@test in("master", branches)
|
@test in("master", branches)
|
||||||
@test !in("gh-pages", branches)
|
@test !in("gh-pages", branches)
|
||||||
@test !LibGit2.isdirty(repo)
|
@test !LibGit2.isdirty(repo)
|
||||||
rm(Pkg.dir("TestPkg"); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
generate("TestPkg", t; ssh=true)
|
generate(test_pkg, t; ssh=true)
|
||||||
repo = LibGit2.GitRepo(Pkg.dir("TestPkg"))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
||||||
@test LibGit2.url(remote) == "git@github.com:invenia/TestPkg.jl.git"
|
@test LibGit2.url(remote) == "git@github.com:invenia/TestPkg.jl.git"
|
||||||
rm(Pkg.dir("TestPkg"); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
t = Template(; user="invenia", host="gitlab.com")
|
t = Template(; user="invenia", host="gitlab.com")
|
||||||
generate("TestPkg", t)
|
generate(test_pkg, t)
|
||||||
repo = LibGit2.GitRepo(Pkg.dir("TestPkg"))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
||||||
@test LibGit2.url(remote) == "https://gitlab.com/invenia/TestPkg.jl"
|
@test LibGit2.url(remote) == "https://gitlab.com/invenia/TestPkg.jl"
|
||||||
rm(Pkg.dir("TestPkg"); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
t = Template(;
|
t = Template(;
|
||||||
user="invenia",
|
user="invenia",
|
||||||
@ -215,92 +210,90 @@ end
|
|||||||
plugins=[AppVeyor(), GitHubPages(), CodeCov(), TravisCI()],
|
plugins=[AppVeyor(), GitHubPages(), CodeCov(), TravisCI()],
|
||||||
)
|
)
|
||||||
|
|
||||||
generate("TestPkg", t)
|
generate(test_pkg, t)
|
||||||
@test isfile(Pkg.dir("TestPkg", "LICENSE"))
|
@test isfile(Pkg.dir(test_pkg, "LICENSE"))
|
||||||
@test isfile(Pkg.dir("TestPkg", ".travis.yml"))
|
@test isfile(Pkg.dir(test_pkg, ".travis.yml"))
|
||||||
@test isfile(Pkg.dir("TestPkg", ".appveyor.yml"))
|
@test isfile(Pkg.dir(test_pkg, ".appveyor.yml"))
|
||||||
@test isfile(Pkg.dir("TestPkg", ".codecov.yml"))
|
@test isfile(Pkg.dir(test_pkg, ".codecov.yml"))
|
||||||
@test isdir(Pkg.dir("TestPkg", "docs"))
|
@test isdir(Pkg.dir(test_pkg, "docs"))
|
||||||
@test isfile(Pkg.dir("TestPkg", "docs", "make.jl"))
|
@test isfile(Pkg.dir(test_pkg, "docs", "make.jl"))
|
||||||
@test isdir(Pkg.dir("TestPkg", "docs", "src"))
|
@test isdir(Pkg.dir(test_pkg, "docs", "src"))
|
||||||
@test isfile(Pkg.dir("TestPkg", "docs", "src", "index.md"))
|
@test isfile(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
||||||
repo = LibGit2.GitRepo(Pkg.dir("TestPkg"))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
@test LibGit2.getconfig(repo, "user.name", "") == git_config["user.name"]
|
@test LibGit2.getconfig(repo, "user.name", "") == git_config["user.name"]
|
||||||
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
||||||
@test in("gh-pages", branches)
|
@test in("gh-pages", branches)
|
||||||
@test !LibGit2.isdirty(repo)
|
@test !LibGit2.isdirty(repo)
|
||||||
rm(Pkg.dir("TestPkg"); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
mkdir(Pkg.dir("TestPkg"))
|
mkdir(Pkg.dir(test_pkg))
|
||||||
@test_throws ArgumentError generate("TestPkg", t)
|
@test_throws ArgumentError generate(test_pkg, t)
|
||||||
generate("TestPkg", t; force=true)
|
generate(test_pkg, t; force=true)
|
||||||
@test isfile(Pkg.dir("TestPkg", "README.md"))
|
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Plugin generation" begin
|
@testset "Plugin generation" begin
|
||||||
mktempdir() do temp_dir
|
t = Template(; user="invenia")
|
||||||
pkg_dir = joinpath(temp_dir, "TestPkg")
|
pkg_dir = joinpath(t.temp_dir, test_pkg)
|
||||||
t = Template(; user="invenia", path=temp_dir)
|
|
||||||
|
|
||||||
p = TravisCI()
|
p = TravisCI()
|
||||||
@test gen_plugin(p, t, "TestPkg") == [".travis.yml"]
|
@test gen_plugin(p, t, test_pkg) == [".travis.yml"]
|
||||||
@test isfile(joinpath(pkg_dir, ".travis.yml"))
|
@test isfile(joinpath(pkg_dir, ".travis.yml"))
|
||||||
rm(joinpath(pkg_dir, ".travis.yml"))
|
rm(joinpath(pkg_dir, ".travis.yml"))
|
||||||
p = TravisCI(; config_file=nothing)
|
p = TravisCI(; config_file=nothing)
|
||||||
@test isempty(gen_plugin(p, t, "TestPkg"))
|
@test isempty(gen_plugin(p, t, test_pkg))
|
||||||
@test !isfile(joinpath(pkg_dir, ".travis.yml"))
|
@test !isfile(joinpath(pkg_dir, ".travis.yml"))
|
||||||
@test_throws ArgumentError TravisCI(; config_file=fake_path)
|
@test_throws ArgumentError TravisCI(; config_file=fake_path)
|
||||||
|
|
||||||
p = AppVeyor()
|
p = AppVeyor()
|
||||||
@test gen_plugin(p, t, "TestPkg") == [".appveyor.yml"]
|
@test gen_plugin(p, t, test_pkg) == [".appveyor.yml"]
|
||||||
@test isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
@test isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
p = AppVeyor(; config_file=nothing)
|
p = AppVeyor(; config_file=nothing)
|
||||||
@test isempty(gen_plugin(p, t, "TestPkg"))
|
@test isempty(gen_plugin(p, t, test_pkg))
|
||||||
@test !isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
@test !isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
@test_throws ArgumentError AppVeyor(; config_file=fake_path)
|
@test_throws ArgumentError AppVeyor(; config_file=fake_path)
|
||||||
|
|
||||||
p = CodeCov()
|
p = CodeCov()
|
||||||
@test gen_plugin(p, t, "TestPkg") == [".codecov.yml"]
|
@test gen_plugin(p, t, test_pkg) == [".codecov.yml"]
|
||||||
@test isfile(joinpath(pkg_dir, ".codecov.yml"))
|
@test isfile(joinpath(pkg_dir, ".codecov.yml"))
|
||||||
rm(joinpath(pkg_dir, ".codecov.yml"))
|
rm(joinpath(pkg_dir, ".codecov.yml"))
|
||||||
p = CodeCov(; config_file=nothing)
|
p = CodeCov(; config_file=nothing)
|
||||||
@test isempty(gen_plugin(p, t, "TestPkg"))
|
@test isempty(gen_plugin(p, t, test_pkg))
|
||||||
@test !isfile(joinpath(pkg_dir, ".codecov.yml"))
|
@test !isfile(joinpath(pkg_dir, ".codecov.yml"))
|
||||||
@test_throws ArgumentError CodeCov(; config_file=fake_path)
|
@test_throws ArgumentError CodeCov(; config_file=fake_path)
|
||||||
|
|
||||||
p = GitHubPages()
|
p = GitHubPages()
|
||||||
@test gen_plugin(p, t, "TestPkg") == ["docs/"]
|
@test gen_plugin(p, t, test_pkg) == ["docs/"]
|
||||||
@test isdir(joinpath(pkg_dir, "docs"))
|
@test isdir(joinpath(pkg_dir, "docs"))
|
||||||
@test isfile(joinpath(pkg_dir, "docs", "make.jl"))
|
@test isfile(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
@test contains(make, "assets=[]")
|
@test contains(make, "assets=[]")
|
||||||
@test !contains(make, "deploydocs")
|
@test !contains(make, "deploydocs")
|
||||||
@test isdir(joinpath(pkg_dir, "docs", "src"))
|
@test isdir(joinpath(pkg_dir, "docs", "src"))
|
||||||
@test isfile(joinpath(pkg_dir, "docs", "src", "index.md"))
|
@test isfile(joinpath(pkg_dir, "docs", "src", "index.md"))
|
||||||
index = readchomp(joinpath(pkg_dir, "docs", "src", "index.md"))
|
index = readchomp(joinpath(pkg_dir, "docs", "src", "index.md"))
|
||||||
@test index == "# TestPkg"
|
@test index == "# TestPkg"
|
||||||
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
||||||
p = GitHubPages(; assets=[test_file])
|
p = GitHubPages(; assets=[test_file])
|
||||||
@test gen_plugin(p, t, "TestPkg") == ["docs/"]
|
@test gen_plugin(p, t, test_pkg) == ["docs/"]
|
||||||
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
@test contains(
|
@test contains(
|
||||||
make,
|
make,
|
||||||
strip("""
|
strip("""
|
||||||
assets=[
|
assets=[
|
||||||
"assets/$(basename(test_file))",
|
"assets/$(basename(test_file))",
|
||||||
]
|
]
|
||||||
""")
|
""")
|
||||||
)
|
)
|
||||||
@test isfile(joinpath(pkg_dir, "docs", "src", "assets", basename(test_file)))
|
@test isfile(joinpath(pkg_dir, "docs", "src", "assets", basename(test_file)))
|
||||||
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
||||||
t.plugins[TravisCI] = TravisCI()
|
t.plugins[TravisCI] = TravisCI()
|
||||||
@test gen_plugin(p, t, "TestPkg") == ["docs/"]
|
@test gen_plugin(p, t, test_pkg) == ["docs/"]
|
||||||
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
@test contains(make, "deploydocs")
|
@test contains(make, "deploydocs")
|
||||||
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
||||||
@test_throws ArgumentError GitHubPages(; assets=[fake_path])
|
@test_throws ArgumentError GitHubPages(; assets=[fake_path])
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Version floor" begin
|
@testset "Version floor" begin
|
||||||
@ -314,7 +307,7 @@ end
|
|||||||
t = Template(; user="invenia")
|
t = Template(; user="invenia")
|
||||||
view = Dict{String, Any}("OTHER" => false)
|
view = Dict{String, Any}("OTHER" => false)
|
||||||
|
|
||||||
text = substitute(template_text, "TestPkg", t; view=view)
|
text = substitute(template_text, test_pkg, t; view=view)
|
||||||
@test contains(text, "PKGNAME: TestPkg")
|
@test contains(text, "PKGNAME: TestPkg")
|
||||||
@test contains(text, "VERSION: $(t.julia_version.major).$(t.julia_version.minor)")
|
@test contains(text, "VERSION: $(t.julia_version.major).$(t.julia_version.minor)")
|
||||||
@test !contains(text, "Documenter")
|
@test !contains(text, "Documenter")
|
||||||
@ -322,19 +315,19 @@ end
|
|||||||
@test !contains(text, "Other")
|
@test !contains(text, "Other")
|
||||||
|
|
||||||
t.plugins[GitHubPages] = GitHubPages()
|
t.plugins[GitHubPages] = GitHubPages()
|
||||||
text = substitute(template_text, "TestPkg", t; view=view)
|
text = substitute(template_text, test_pkg, t; view=view)
|
||||||
@test contains(text, "Documenter")
|
@test contains(text, "Documenter")
|
||||||
@test contains(text, "After")
|
@test contains(text, "After")
|
||||||
empty!(t.plugins)
|
empty!(t.plugins)
|
||||||
|
|
||||||
t.plugins[CodeCov] = CodeCov()
|
t.plugins[CodeCov] = CodeCov()
|
||||||
text = substitute(template_text, "TestPkg", t; view=view)
|
text = substitute(template_text, test_pkg, t; view=view)
|
||||||
@test contains(text, "CodeCov")
|
@test contains(text, "CodeCov")
|
||||||
@test contains(text, "After")
|
@test contains(text, "After")
|
||||||
empty!(t.plugins)
|
empty!(t.plugins)
|
||||||
|
|
||||||
view["OTHER"] = true
|
view["OTHER"] = true
|
||||||
text = substitute(template_text, "TestPkg", t; view=view)
|
text = substitute(template_text, test_pkg, t; view=view)
|
||||||
@test contains(text, "Other")
|
@test contains(text, "Other")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user