sed -i '' -E 's/contains\((.+), (.+)\)/occursin\(\2, \1\)/'

This commit is contained in:
Chris de Graaf 2018-09-19 14:30:23 -05:00
parent 3a2f3fcb71
commit bbd492a77d
5 changed files with 68 additions and 68 deletions

View File

@ -34,28 +34,28 @@ pkg_dir = joinpath(temp_dir, test_pkg)
@test gen_plugin(p, t, temp_dir, test_pkg) == [".appveyor.yml"] @test gen_plugin(p, t, temp_dir, test_pkg) == [".appveyor.yml"]
@test isfile(joinpath(pkg_dir, ".appveyor.yml")) @test isfile(joinpath(pkg_dir, ".appveyor.yml"))
appveyor = read(joinpath(pkg_dir, ".appveyor.yml"), String) appveyor = read(joinpath(pkg_dir, ".appveyor.yml"), String)
@test !contains(appveyor, "coverage=true") @test !occursin("coverage=true", appveyor)
@test !contains(appveyor, "after_test") @test !occursin("after_test", appveyor)
@test !contains(appveyor, "Codecov.submit") @test !occursin("Codecov.submit", appveyor)
@test !contains(appveyor, "Coveralls.submit") @test !occursin("Coveralls.submit", appveyor)
rm(joinpath(pkg_dir, ".appveyor.yml")) rm(joinpath(pkg_dir, ".appveyor.yml"))
t.plugins[CodeCov] = CodeCov() t.plugins[CodeCov] = CodeCov()
gen_plugin(p, t, temp_dir, test_pkg) gen_plugin(p, t, temp_dir, test_pkg)
delete!(t.plugins, CodeCov) delete!(t.plugins, CodeCov)
appveyor = read(joinpath(pkg_dir, ".appveyor.yml"), String) appveyor = read(joinpath(pkg_dir, ".appveyor.yml"), String)
@test contains(appveyor, "coverage=true") @test occursin("coverage=true", appveyor)
@test contains(appveyor, "after_test") @test occursin("after_test", appveyor)
@test contains(appveyor, "Codecov.submit") @test occursin("Codecov.submit", appveyor)
@test !contains(appveyor, "Coveralls.submit") @test !occursin("Coveralls.submit", appveyor)
rm(joinpath(pkg_dir, ".appveyor.yml")) rm(joinpath(pkg_dir, ".appveyor.yml"))
t.plugins[Coveralls] = Coveralls() t.plugins[Coveralls] = Coveralls()
gen_plugin(p, t, temp_dir, test_pkg) gen_plugin(p, t, temp_dir, test_pkg)
delete!(t.plugins, Coveralls) delete!(t.plugins, Coveralls)
appveyor = read(joinpath(pkg_dir, ".appveyor.yml"), String) appveyor = read(joinpath(pkg_dir, ".appveyor.yml"), String)
@test contains(appveyor, "coverage=true") @test occursin("coverage=true", appveyor)
@test contains(appveyor, "after_test") @test occursin("after_test", appveyor)
@test contains(appveyor, "Coveralls.submit") @test occursin("Coveralls.submit", appveyor)
@test !contains(appveyor, "Codecov.submit") @test !occursin("Codecov.submit", appveyor)
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, temp_dir, test_pkg)) @test isempty(gen_plugin(p, t, temp_dir, test_pkg))

View File

@ -27,8 +27,8 @@ pkg_dir = joinpath(temp_dir, test_pkg)
@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 occursin("assets=[]", make)
@test !contains(make, "deploydocs") @test !occursin("deploydocs", make)
@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"))
@ -50,7 +50,7 @@ pkg_dir = joinpath(temp_dir, test_pkg)
t.plugins[TravisCI] = TravisCI() t.plugins[TravisCI] = TravisCI()
@test gen_plugin(p, t, temp_dir, test_pkg) == ["docs/"] @test gen_plugin(p, t, temp_dir, test_pkg) == ["docs/"]
make = readchomp(joinpath(pkg_dir, "docs", "make.jl")) make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
@test contains(make, "deploydocs") @test occursin("deploydocs", make)
rm(joinpath(pkg_dir, "docs"); recursive=true) rm(joinpath(pkg_dir, "docs"); recursive=true)
end end
end end

View File

@ -51,13 +51,13 @@ pkg_dir = joinpath(temp_dir, test_pkg)
@test gen_plugin(p, t, temp_dir, test_pkg) == [".gitlab-ci.yml"] @test gen_plugin(p, t, temp_dir, test_pkg) == [".gitlab-ci.yml"]
@test isfile(joinpath(pkg_dir, ".gitlab-ci.yml")) @test isfile(joinpath(pkg_dir, ".gitlab-ci.yml"))
gitlab = read(joinpath(pkg_dir, ".gitlab-ci.yml"), String) gitlab = read(joinpath(pkg_dir, ".gitlab-ci.yml"), String)
@test contains(gitlab, "test_template") @test occursin("test_template", gitlab)
@test contains(gitlab, "using Coverage") @test occursin("using Coverage", gitlab)
rm(joinpath(pkg_dir, ".gitlab-ci.yml")) rm(joinpath(pkg_dir, ".gitlab-ci.yml"))
p = GitLabCI(; coverage=false) p = GitLabCI(; coverage=false)
gen_plugin(p, t, temp_dir, test_pkg) gen_plugin(p, t, temp_dir, test_pkg)
gitlab = read(joinpath(pkg_dir, ".gitlab-ci.yml"), String) gitlab = read(joinpath(pkg_dir, ".gitlab-ci.yml"), String)
@test !contains(gitlab, "using Coverage") @test !occursin("using Coverage", gitlab)
rm(joinpath(pkg_dir, ".gitlab-ci.yml")) rm(joinpath(pkg_dir, ".gitlab-ci.yml"))
p = GitLabCI(; config_file=nothing) p = GitLabCI(; config_file=nothing)
@test isempty(gen_plugin(p, t, temp_dir, test_pkg)) @test isempty(gen_plugin(p, t, temp_dir, test_pkg))

View File

@ -34,37 +34,37 @@ pkg_dir = joinpath(temp_dir, test_pkg)
@test gen_plugin(p, t, temp_dir, test_pkg) == [".travis.yml"] @test gen_plugin(p, t, temp_dir, test_pkg) == [".travis.yml"]
@test isfile(joinpath(pkg_dir, ".travis.yml")) @test isfile(joinpath(pkg_dir, ".travis.yml"))
travis = read(joinpath(pkg_dir, ".travis.yml"), String) travis = read(joinpath(pkg_dir, ".travis.yml"), String)
@test !contains(travis, "after_success") @test !occursin("after_success", travis)
@test !contains(travis, "Codecov.submit") @test !occursin("Codecov.submit", travis)
@test !contains(travis, "Coveralls.submit") @test !occursin("Coveralls.submit", travis)
@test !contains(travis, "Pkg.add(\"Documenter\")") @test !occursin("Pkg.add(\"Documenter\")", travis)
rm(joinpath(pkg_dir, ".travis.yml")) rm(joinpath(pkg_dir, ".travis.yml"))
t.plugins[CodeCov] = CodeCov() t.plugins[CodeCov] = CodeCov()
gen_plugin(p, t, temp_dir, test_pkg) gen_plugin(p, t, temp_dir, test_pkg)
delete!(t.plugins, CodeCov) delete!(t.plugins, CodeCov)
travis = read(joinpath(pkg_dir, ".travis.yml"), String) travis = read(joinpath(pkg_dir, ".travis.yml"), String)
@test contains(travis, "after_success") @test occursin("after_success", travis)
@test contains(travis, "Codecov.submit") @test occursin("Codecov.submit", travis)
@test !contains(travis, "Coveralls.submit") @test !occursin("Coveralls.submit", travis)
@test !contains(travis, "Pkg.add(\"Documenter\")") @test !occursin("Pkg.add(\"Documenter\")", travis)
rm(joinpath(pkg_dir, ".travis.yml")) rm(joinpath(pkg_dir, ".travis.yml"))
t.plugins[Coveralls] = Coveralls() t.plugins[Coveralls] = Coveralls()
gen_plugin(p, t, temp_dir, test_pkg) gen_plugin(p, t, temp_dir, test_pkg)
delete!(t.plugins, Coveralls) delete!(t.plugins, Coveralls)
travis = read(joinpath(pkg_dir, ".travis.yml"), String) travis = read(joinpath(pkg_dir, ".travis.yml"), String)
@test contains(travis, "after_success") @test occursin("after_success", travis)
@test contains(travis, "Coveralls.submit") @test occursin("Coveralls.submit", travis)
@test !contains(travis, "Codecov.submit") @test !occursin("Codecov.submit", travis)
@test !contains(travis, "Pkg.add(\"Documenter\")") @test !occursin("Pkg.add(\"Documenter\")", travis)
rm(joinpath(pkg_dir, ".travis.yml")) rm(joinpath(pkg_dir, ".travis.yml"))
t.plugins[GitHubPages] = GitHubPages() t.plugins[GitHubPages] = GitHubPages()
gen_plugin(p, t, temp_dir, test_pkg) gen_plugin(p, t, temp_dir, test_pkg)
delete!(t.plugins, GitHubPages) delete!(t.plugins, GitHubPages)
travis = read(joinpath(pkg_dir, ".travis.yml"), String) travis = read(joinpath(pkg_dir, ".travis.yml"), String)
@test contains(travis, "after_success") @test occursin("after_success", travis)
@test contains(travis, "Pkg.add(\"Documenter\")") @test occursin("Pkg.add(\"Documenter\")", travis)
@test !contains(travis, "Codecov.submit") @test !occursin("Codecov.submit", travis)
@test !contains(travis, "Coveralls.submit") @test !occursin("Coveralls.submit", travis)
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, temp_dir, test_pkg)) @test isempty(gen_plugin(p, t, temp_dir, test_pkg))

View File

@ -209,9 +209,9 @@ end
@test isfile(joinpath(pkg_dir, "README.md")) @test isfile(joinpath(pkg_dir, "README.md"))
readme = readchomp(joinpath(pkg_dir, "README.md")) readme = readchomp(joinpath(pkg_dir, "README.md"))
rm(joinpath(pkg_dir, "README.md")) rm(joinpath(pkg_dir, "README.md"))
@test contains(readme, "# $test_pkg") @test occursin("# $test_pkg", readme)
for p in values(t.plugins) for p in values(t.plugins)
@test contains(readme, join(badges(p, t.user, test_pkg), "\n")) @test occursin("\n"), readme, join(badges(p, t.user, test_pkg))
end end
# Check the order of the badges. # Check the order of the badges.
@test search(readme, "github.io").start < @test search(readme, "github.io").start <
@ -230,10 +230,10 @@ end
@test isfile(joinpath(pkg_dir, ".gitignore")) @test isfile(joinpath(pkg_dir, ".gitignore"))
gitignore = read(joinpath(pkg_dir, ".gitignore"), String) gitignore = read(joinpath(pkg_dir, ".gitignore"), String)
rm(joinpath(pkg_dir, ".gitignore")) rm(joinpath(pkg_dir, ".gitignore"))
@test contains(gitignore, ".DS_Store") @test occursin(".DS_Store", gitignore)
for p in values(t.plugins) for p in values(t.plugins)
for entry in p.gitignore for entry in p.gitignore
@test contains(gitignore, entry) @test occursin(entry, gitignore)
end end
end end
@ -241,22 +241,22 @@ end
@test isfile(joinpath(pkg_dir, "LICENSE")) @test isfile(joinpath(pkg_dir, "LICENSE"))
license = readchomp(joinpath(pkg_dir, "LICENSE")) license = readchomp(joinpath(pkg_dir, "LICENSE"))
rm(joinpath(pkg_dir, "LICENSE")) rm(joinpath(pkg_dir, "LICENSE"))
@test contains(license, t.authors) @test occursin(t.authors, license)
@test contains(license, t.years) @test occursin(t.years, license)
@test contains(license, read_license(t.license)) @test occursin(read_license(t.license), license)
@test gen_entrypoint(temp_dir, test_pkg, t) == ["src/"] @test gen_entrypoint(temp_dir, test_pkg, t) == ["src/"]
@test isdir(joinpath(pkg_dir, "src")) @test isdir(joinpath(pkg_dir, "src"))
@test isfile(joinpath(pkg_dir, "src", "$test_pkg.jl")) @test isfile(joinpath(pkg_dir, "src", "$test_pkg.jl"))
entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl")) entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl"))
rm(joinpath(pkg_dir, "src"); recursive=true) rm(joinpath(pkg_dir, "src"); recursive=true)
@test contains(entrypoint, "__precompile__()") @test occursin("__precompile__()", entrypoint)
@test contains(entrypoint, "module $test_pkg") @test occursin("module $test_pkg", entrypoint)
t2 = Template(; user=me, precompile=false) t2 = Template(; user=me, precompile=false)
gen_entrypoint(temp_dir, test_pkg, t2) gen_entrypoint(temp_dir, test_pkg, t2)
entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl")) entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl"))
@test !contains(entrypoint, "__precompile__()") @test !occursin("__precompile__()", entrypoint)
@test contains(entrypoint, "module $test_pkg") @test occursin("module $test_pkg", entrypoint)
rm(joinpath(pkg_dir, "src"); recursive=true) rm(joinpath(pkg_dir, "src"); recursive=true)
@test gen_require(temp_dir, test_pkg, t) == ["REQUIRE"] @test gen_require(temp_dir, test_pkg, t) == ["REQUIRE"]
@ -270,8 +270,8 @@ end
@test isfile(joinpath(pkg_dir, "test", "runtests.jl")) @test isfile(joinpath(pkg_dir, "test", "runtests.jl"))
runtests = readchomp(joinpath(pkg_dir, "test", "runtests.jl")) runtests = readchomp(joinpath(pkg_dir, "test", "runtests.jl"))
rm(joinpath(pkg_dir, "test"); recursive=true) rm(joinpath(pkg_dir, "test"); recursive=true)
@test contains(runtests, "using $test_pkg") @test occursin("using $test_pkg", runtests)
@test contains(runtests, "using Base.Test") @test occursin("using Base.Test", runtests)
rm(temp_dir; recursive=true) rm(temp_dir; recursive=true)
end end
@ -378,49 +378,49 @@ end
@testset "Mustache substitution" begin @testset "Mustache substitution" begin
view = Dict{String, Any}() view = Dict{String, Any}()
text = substitute(template_text, view) text = substitute(template_text, view)
@test !contains(text, "PKGNAME: $test_pkg") @test !occursin("PKGNAME: $test_pkg", text)
@test !contains(text, "Documenter") @test !occursin("Documenter", text)
@test !contains(text, "CodeCov") @test !occursin("CodeCov", text)
@test !contains(text, "Coveralls") @test !occursin("Coveralls", text)
@test !contains(text, "After") @test !occursin("After", text)
@test !contains(text, "Other") @test !occursin("Other", text)
view["PKGNAME"] = test_pkg view["PKGNAME"] = test_pkg
view["OTHER"] = true view["OTHER"] = true
text = substitute(template_text, view) text = substitute(template_text, view)
@test contains(text, "PKGNAME: $test_pkg") @test occursin("PKGNAME: $test_pkg", text)
@test contains(text, "Other") @test occursin("Other", text)
t = Template(; user=me) t = Template(; user=me)
view["OTHER"] = false view["OTHER"] = false
text = substitute(template_text, t; view=view) text = substitute(template_text, t; view=view)
@test contains(text, "PKGNAME: $test_pkg") @test occursin("PKGNAME: $test_pkg", text)
@test contains(text, "VERSION: $(t.julia_version.major).$(t.julia_version.minor)") @test occursin("VERSION: $(t.julia_version.major).$(t.julia_version.minor)", text)
@test !contains(text, "Documenter") @test !occursin("Documenter", text)
@test !contains(text, "After") @test !occursin("After", text)
@test !contains(text, "Other") @test !occursin("Other", text)
t.plugins[GitHubPages] = GitHubPages() t.plugins[GitHubPages] = GitHubPages()
text = substitute(template_text, t; view=view) text = substitute(template_text, t; view=view)
@test contains(text, "Documenter") @test occursin("Documenter", text)
@test contains(text, "After") @test occursin("After", text)
empty!(t.plugins) empty!(t.plugins)
t.plugins[CodeCov] = CodeCov() t.plugins[CodeCov] = CodeCov()
text = substitute(template_text, t; view=view) text = substitute(template_text, t; view=view)
@test contains(text, "CodeCov") @test occursin("CodeCov", text)
@test contains(text, "After") @test occursin("After", text)
empty!(t.plugins) empty!(t.plugins)
t.plugins[Coveralls] = Coveralls() t.plugins[Coveralls] = Coveralls()
text = substitute(template_text, t; view=view) text = substitute(template_text, t; view=view)
@test contains(text, "Coveralls") @test occursin("Coveralls", text)
@test contains(text, "After") @test occursin("After", text)
empty!(t.plugins) empty!(t.plugins)
view["OTHER"] = true view["OTHER"] = true
text = substitute(template_text, t; view=view) text = substitute(template_text, t; view=view)
@test contains(text, "Other") @test occursin("Other", text)
end end
@testset "License display" begin @testset "License display" begin
@ -435,7 +435,7 @@ end
redirect_stdout(old_stdout) redirect_stdout(old_stdout)
for (short, long) in LICENSES for (short, long) in LICENSES
@test contains(licenses, "$short: $long") @test occursin("$short: $long", licenses)
end end
@test strip(mit) == strip(read_license("MIT")) @test strip(mit) == strip(read_license("MIT"))
@test strip(read_license("MIT")) == strip(read(joinpath(LICENSE_DIR, "MIT"), String)) @test strip(read_license("MIT")) == strip(read(joinpath(LICENSE_DIR, "MIT"), String))