2017-08-24 19:03:05 +00:00
|
|
|
# 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
|
2017-08-25 14:18:29 +00:00
|
|
|
# https://github.com/nick-paul/TerminalMenus.jl/issues/5
|
2018-09-19 19:19:16 +00:00
|
|
|
# This also affects any time we write to stdin.buffer, because
|
2017-10-06 13:08:35 +00:00
|
|
|
# IOStreams do not have that attribute.
|
|
|
|
# Therefore, we skip any interactive tests on OSX builds.
|
2017-08-24 19:03:05 +00:00
|
|
|
|
|
|
|
@testset "Interactive template creation" begin
|
2018-09-19 19:19:16 +00:00
|
|
|
write(stdin.buffer, "$me\n\n\r\n\n\n\n\nd")
|
2017-08-24 19:03:05 +00:00
|
|
|
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.years == string(Dates.year(Dates.today()))
|
2018-09-19 19:19:16 +00:00
|
|
|
@test t.dir == default_dir
|
2017-08-24 19:03:05 +00:00
|
|
|
@test t.julia_version == VERSION
|
|
|
|
@test isempty(t.requirements)
|
|
|
|
@test isempty(t.gitconfig)
|
|
|
|
@test isempty(t.plugins)
|
|
|
|
|
|
|
|
if isempty(LibGit2.getconfig("github.user", ""))
|
2018-09-19 19:19:16 +00:00
|
|
|
write(stdin.buffer, "\n")
|
2017-08-24 19:03:05 +00:00
|
|
|
@test_throws ArgumentError t = interactive_template()
|
|
|
|
end
|
|
|
|
|
2018-09-19 19:19:16 +00:00
|
|
|
write(stdin.buffer, "$me\ngitlab.com\n$('\x1b')[B\r$me\n2016\n$test_file\nno\n0.5\nX Y\nkey val val\nkey2 val2\n\n$('\x1b')[B\r$('\x1b')[B\rd\n\n")
|
2017-08-24 19:03:05 +00:00
|
|
|
t = interactive_template()
|
|
|
|
@test t.user == me
|
|
|
|
@test t.host == "gitlab.com"
|
2017-09-18 09:17:30 +00:00
|
|
|
# Not sure if the order the licenses are displayed in is consistent.
|
2017-08-24 19:03:05 +00:00
|
|
|
@test !isempty(t.license)
|
|
|
|
@test t.authors == me
|
|
|
|
@test t.years == "2016"
|
2017-08-25 04:50:44 +00:00
|
|
|
@test t.dir == abspath(test_file)
|
2017-10-06 13:04:51 +00:00
|
|
|
@test !t.precompile
|
2017-08-24 19:03:05 +00:00
|
|
|
@test t.julia_version == v"0.5.0"
|
|
|
|
@test Set(t.requirements) == Set(["X", "Y"])
|
2017-10-06 14:28:26 +00:00
|
|
|
@test t.gitconfig == Dict("key" => "val val", "key2" => "val2")
|
2017-08-24 19:03:05 +00:00
|
|
|
# Like above, not sure which plugins this will generate.
|
|
|
|
@test length(t.plugins) == 2
|
|
|
|
|
2018-09-19 19:19:16 +00:00
|
|
|
write(stdin.buffer, "$me\n\n\r\n\n\n\nA B\nA B\n\nd")
|
|
|
|
@test_logs (:warn, r".+") match_mode=:any interactive_template()
|
2017-10-02 03:21:35 +00:00
|
|
|
|
2018-09-19 19:19:16 +00:00
|
|
|
write(stdin.buffer, "$me\nd")
|
2017-08-24 19:03:05 +00:00
|
|
|
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", "")
|
|
|
|
# I guess this could technically break if it runs on New Year's Eve...
|
|
|
|
@test t.years == string(Dates.year(Dates.today()))
|
2018-09-19 19:19:16 +00:00
|
|
|
@test t.dir == default_dir
|
2017-08-24 19:03:05 +00:00
|
|
|
@test t.julia_version == VERSION
|
|
|
|
@test isempty(t.requirements)
|
|
|
|
@test isempty(t.gitconfig)
|
|
|
|
@test isempty(t.plugins)
|
|
|
|
println()
|
|
|
|
end
|
2017-10-02 03:21:35 +00:00
|
|
|
|
|
|
|
@testset "Interactive package generation" begin
|
2017-12-12 15:15:55 +00:00
|
|
|
cfg = join(("$k $v" for (k, v) in gitconfig), "\n")
|
2018-09-19 19:19:16 +00:00
|
|
|
write(stdin.buffer, "$me\n\n\r\n\n\n\n$cfg\n\nd")
|
2017-10-02 03:21:35 +00:00
|
|
|
generate_interactive(test_pkg)
|
2018-09-19 19:19:16 +00:00
|
|
|
@test isdir(joinpath(default_dir, test_pkg))
|
|
|
|
rm(joinpath(default_dir, test_pkg); force=true, recursive=true)
|
2017-10-02 03:21:35 +00:00
|
|
|
end
|