From f3b96caa65499489ec0dd334755600a69ad1fe53 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Mon, 5 Nov 2018 14:21:02 -0600 Subject: [PATCH] Run interactive tests on MacOS --- test/interactive/interactive.jl | 102 ++++++++++++++++---------------- test/tests.jl | 23 +++---- 2 files changed, 57 insertions(+), 68 deletions(-) diff --git a/test/interactive/interactive.jl b/test/interactive/interactive.jl index e0a121d..f520d0e 100644 --- a/test/interactive/interactive.jl +++ b/test/interactive/interactive.jl @@ -1,58 +1,56 @@ -# TerminalMenus.jl has issues in environments without a TTY, -# which seems to be the case in Travis CI OSX builds. -# https://travis-ci.org/invenia/PkgTemplates.jl/jobs/267682403#L115 -# https://github.com/nick-paul/TerminalMenus.jl/issues/5 -# This also affects any time we write to stdin.buffer, because -# IOStreams do not have that attribute. -# Therefore, we skip any interactive tests on OSX builds. +@testset "Interactive mode" begin + @testset "Template creation" begin + write(stdin.buffer, "$me\n\n\r\n\n\nd") + t = interactive_template() + @test t.user == me + @test t.host == "github.com" + @test isempty(t.license) + @test t.authors == LibGit2.getconfig("user.name", "") + @test t.dir == default_dir + @test t.julia_version == VERSION + @test !t.ssh + @test isempty(t.plugins) -@testset "Interactive template creation" begin - write(stdin.buffer, "$me\n\n\r\n\n\nd") - t = interactive_template() - @test t.user == me - @test t.host == "github.com" - @test isempty(t.license) - @test t.authors == LibGit2.getconfig("user.name", "") - @test t.dir == default_dir - @test t.julia_version == VERSION - @test !t.ssh - @test isempty(t.plugins) + if isempty(LibGit2.getconfig("github.user", "")) + write(stdin.buffer, "\n") + @test_throws ArgumentError t = interactive_template() + end - if isempty(LibGit2.getconfig("github.user", "")) - write(stdin.buffer, "\n") - @test_throws ArgumentError t = interactive_template() + 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") + t = interactive_template() + @test t.user == me + @test t.host == "gitlab.com" + # Not sure if the order the licenses are displayed in is consistent. + @test !isempty(t.license) + @test t.authors == me + @test t.dir == abspath(test_file) + @test t.julia_version == v"0.5.0" + @test t.ssh + # Like above, not sure which plugins this will generate. + @test length(t.plugins) == 2 + + write(stdin.buffer, "$me\nd") + t = interactive_template(; fast=true) + @test t.user == me + @test t.host == "github.com" + @test t.license == "MIT" + @test t.authors == LibGit2.getconfig("user.name", "") + @test t.dir == default_dir + @test t.julia_version == VERSION + @test !t.ssh + @test isempty(t.plugins) + println() 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") - t = interactive_template() - @test t.user == me - @test t.host == "gitlab.com" - # Not sure if the order the licenses are displayed in is consistent. - @test !isempty(t.license) - @test t.authors == me - @test t.dir == abspath(test_file) - @test t.julia_version == v"0.5.0" - @test t.ssh - # Like above, not sure which plugins this will generate. - @test length(t.plugins) == 2 + @testset "Package generation" begin + write(stdin.buffer, "$me\n\n\r\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) + end - write(stdin.buffer, "$me\nd") - t = interactive_template(; fast=true) - @test t.user == me - @test t.host == "github.com" - @test t.license == "MIT" - @test t.authors == LibGit2.getconfig("user.name", "") - @test t.dir == default_dir - @test t.julia_version == VERSION - @test !t.ssh - @test isempty(t.plugins) - println() -end - -@testset "Interactive package generation" begin - write(stdin.buffer, "$me\n\n\r\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) + @testset "Plugins" begin + include("plugins.jl") + end end diff --git a/test/tests.jl b/test/tests.jl index f702fea..7d57041 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -13,6 +13,11 @@ end struct Bar <: CustomPlugin end # A dummy Plugin subtype. struct Baz <: Plugin end +# A Documenter with extra kwargs +struct Qux <: Documenter + assets::Vector{AbstractString} + additional_kwargs::Union{AbstractDict, NamedTuple} +end # Various options to be passed into templates. const me = "christopher-dG" @@ -95,16 +100,6 @@ write(test_file, template_text) @test_throws ArgumentError Template(; user=me, license="FakeLicense") end -# TerminalMenus doesn't work quite right on Travis OSX. -if get(ENV, "TRAVIS_OS_NAME", "") != "osx" - include(joinpath("interactive", "interactive.jl")) - @testset "Interactive plugin creation" begin - include(joinpath("interactive", "plugins.jl")) - end -else - @info "Skipping tests that require TerminalMenus on OSX" -end - @testset "Show methods" begin pkg_dir = replace(default_dir, homedir() => "~") buf = IOBuffer() @@ -397,12 +392,6 @@ end include(joinpath("plugins", "githubpages.jl")) end -# A Documenter with extra kwargs -struct Qux <: Documenter - assets::Vector{AbstractString} - additional_kwargs::Union{AbstractDict, NamedTuple} -end - @testset "Documenter add kwargs" begin t = Template(; user=me) pkg_dir = joinpath(t.dir, test_pkg) @@ -442,4 +431,6 @@ end check_kwargs(kwargs, warn_str) end +include(joinpath("interactive", "interactive.jl")) + rm(test_file)