From 973147639f016da327052b3474fb5df4d947e2e7 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Wed, 7 Nov 2018 14:46:44 -0600 Subject: [PATCH] Add tests for manifest option --- test/interactive/interactive.jl | 8 +++++--- test/tests.jl | 36 +++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/test/interactive/interactive.jl b/test/interactive/interactive.jl index f520d0e..fea759f 100644 --- a/test/interactive/interactive.jl +++ b/test/interactive/interactive.jl @@ -1,6 +1,6 @@ @testset "Interactive mode" begin @testset "Template creation" begin - write(stdin.buffer, "$me\n\n\r\n\n\nd") + write(stdin.buffer, "$me\n\n\r\n\n\n\nd") t = interactive_template() @test t.user == me @test t.host == "github.com" @@ -17,7 +17,7 @@ end down = '\x1b' * "[B" # Down array key. - write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\n$down\r$down\rd\n\n") + write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\nyes\n$down\r$down\rd\n\n") t = interactive_template() @test t.user == me @test t.host == "gitlab.com" @@ -27,6 +27,7 @@ @test t.dir == abspath(test_file) @test t.julia_version == v"0.5.0" @test t.ssh + @test t.manifest # Like above, not sure which plugins this will generate. @test length(t.plugins) == 2 @@ -39,12 +40,13 @@ @test t.dir == default_dir @test t.julia_version == VERSION @test !t.ssh + @test !t.manifest @test isempty(t.plugins) println() end @testset "Package generation" begin - write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\nd") + write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\n\nd") generate_interactive(test_pkg; gitconfig=gitconfig) @test isdir(joinpath(default_dir, test_pkg)) rm(joinpath(default_dir, test_pkg); force=true, recursive=true) diff --git a/test/tests.jl b/test/tests.jl index 7d57041..8058e26 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -45,6 +45,8 @@ write(test_file, template_text) @test t.authors == LibGit2.getconfig("user.name", "") @test t.dir == default_dir @test t.julia_version == VERSION + @test !t.ssh + @test !t.manifest @test isempty(t.plugins) # Checking non-default field assignments. @@ -72,6 +74,12 @@ write(test_file, template_text) t = Template(; user=me, julia_version=v"0.1.2") @test t.julia_version == v"0.1.2" + t = Template(; user=me, ssh=true) + @test t.ssh + + t = Template(; user=me, manifest=true) + @test t.manifest + # The template should contain whatever plugins you give it. t = Template(; user=me, @@ -114,6 +122,7 @@ end → Package directory: $pkg_dir → Minimum Julia version: v$(PkgTemplates.version_floor()) → SSH remote: No + → Commit Manifest.toml: No → Plugins: None """ @test text == rstrip(expected) @@ -121,6 +130,7 @@ end user=me, license="", ssh=true, + manifest=true, plugins=[ TravisCI(), CodeCov(), @@ -137,6 +147,7 @@ end → Package directory: $pkg_dir → Minimum Julia version: v$(PkgTemplates.version_floor()) → SSH remote: Yes + → Commit Manifest.toml: Yes → Plugins: • CodeCov: → Config file: None @@ -186,10 +197,7 @@ end gen_readme(pkg_dir, t) readme = readchomp(joinpath(pkg_dir, "README.md")) rm(joinpath(pkg_dir, "README.md")) - @test <( - something(findfirst("coveralls", readme)).start, - something(findfirst("baz", readme)).start, - ) + @test findfirst("coveralls", readme).start < findfirst("baz", readme).start # Test the gitignore generation. @test gen_gitignore(pkg_dir, t) == [".gitignore"] @@ -285,6 +293,26 @@ end generate(test_pkg, t; gitconfig=gitconfig) @test isdir(joinpath(temp_dir, test_pkg)) rm(temp_dir; recursive=true) + + # Check that the Manifest.toml is not commited by default. + t = Template(; user=me) + generate(test_pkg, t; gitconfig=gitconfig) + @test occursin("Manifest.toml", read(joinpath(pkg_dir, ".gitignore"), String)) + # I'm not sure this is the "right" way to do this. + repo = GitRepo(pkg_dir) + idx = LibGit2.GitIndex(repo) + @test findall("Manifest.toml", idx) === nothing + rm(pkg_dir; recursive=true) + + # And that it is when you tell it to be. + t = Template(; user=me, manifest=true) + generate(test_pkg, t; gitconfig=gitconfig) + @test !occursin("Manifest.toml", read(joinpath(pkg_dir, ".gitignore"), String)) + # I'm not sure this is the "right" way to do this. + repo = GitRepo(pkg_dir) + idx = LibGit2.GitIndex(repo) + @test findall("Manifest.toml", idx) !== nothing + rm(pkg_dir; recursive=true) end @testset "Version floor" begin