Skip to content

Commit

Permalink
Merge pull request #50 from jmert/test48
Browse files Browse the repository at this point in the history
Add test for #48
  • Loading branch information
MikeInnes authored Jul 16, 2018
2 parents fb4e8ee + 9930772 commit 7e5bbdc
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JSON
Colors
70 changes: 63 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
using Test

function writepkg(name, precomp::Bool)
function writepkg(name, precomp::Bool, submod::Bool)
action = """
global flag = true
"""

if submod
open("$(name)_submod.jl", "w") do io
println(io, """
export SubModule
module SubModule
using Colors
flag = true
end
""")
end

action *= """
include("$(name)_submod.jl")
"""
end

open("$name.jl", "w") do io
println(io, """
__precompile__($precomp)
Expand All @@ -12,7 +32,9 @@ using Requires
flag = false
function __init__()
@require JSON="682c06a0-de6a-54ab-a142-c8b1cf79cde6" global flag = true
@require Colors="5ae59095-9a9b-59fe-a467-6f913c188581" begin
$(action)
end
end
end
Expand All @@ -26,12 +48,22 @@ end
npcdir = joinpath("FooNPC", "src")
mkpath(npcdir)
cd(npcdir) do
writepkg("FooNPC", false)
writepkg("FooNPC", false, false)
end
npcdir = joinpath("FooPC", "src")
mkpath(npcdir)
cd(npcdir) do
writepkg("FooPC", true)
writepkg("FooPC", true, false)
end
npcdir = joinpath("FooSubNPC", "src")
mkpath(npcdir)
cd(npcdir) do
writepkg("FooSubNPC", false, true)
end
npcdir = joinpath("FooSubPC", "src")
mkpath(npcdir)
cd(npcdir) do
writepkg("FooSubPC", true, true)
end
end
push!(LOAD_PATH, pkgsdir)
Expand All @@ -40,28 +72,52 @@ end
@test !FooNPC.flag
@eval using FooPC
@test !FooPC.flag
@eval using FooSubNPC
@test !(:SubModule in names(FooSubNPC))
@eval using FooSubPC
@test !(:SubModule in names(FooSubPC))

@eval using JSON
@eval using Colors

@test FooNPC.flag
@test FooPC.flag
@test :SubModule in names(FooSubNPC)
@test FooSubNPC.SubModule.flag
@test :SubModule in names(FooSubPC)
@test FooSubPC.SubModule.flag

cd(pkgsdir) do
npcdir = joinpath("FooAfterNPC", "src")
mkpath(npcdir)
cd(npcdir) do
writepkg("FooAfterNPC", false)
writepkg("FooAfterNPC", false, false)
end
pcidr = joinpath("FooAfterPC", "src")
mkpath(pcidr)
cd(pcidr) do
writepkg("FooAfterPC", true)
writepkg("FooAfterPC", true, false)
end
sanpcdir = joinpath("FooSubAfterNPC", "src")
mkpath(sanpcdir)
cd(sanpcdir) do
writepkg("FooSubAfterNPC", false, true)
end
sapcdir = joinpath("FooSubAfterPC", "src")
mkpath(sapcdir)
cd(sapcdir) do
writepkg("FooSubAfterPC", true, true)
end
end

@eval using FooAfterNPC
@eval using FooAfterPC
@eval using FooSubAfterNPC
@eval using FooSubAfterPC
@test FooAfterNPC.flag
@test FooAfterPC.flag
@test :SubModule in names(FooSubAfterNPC)
@test FooSubAfterNPC.SubModule.flag
@test :SubModule in names(FooSubAfterPC)
@test FooSubAfterPC.SubModule.flag
end
end

0 comments on commit 7e5bbdc

Please sign in to comment.