Skip to content

Commit 7e5bbdc

Browse files
authored
Merge pull request #50 from jmert/test48
Add test for #48
2 parents fb4e8ee + 9930772 commit 7e5bbdc

File tree

2 files changed

+64
-8
lines changed

2 files changed

+64
-8
lines changed

test/REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
JSON
1+
Colors

test/runtests.jl

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
using Test
22

3-
function writepkg(name, precomp::Bool)
3+
function writepkg(name, precomp::Bool, submod::Bool)
4+
action = """
5+
global flag = true
6+
"""
7+
8+
if submod
9+
open("$(name)_submod.jl", "w") do io
10+
println(io, """
11+
export SubModule
12+
module SubModule
13+
using Colors
14+
flag = true
15+
end
16+
""")
17+
end
18+
19+
action *= """
20+
include("$(name)_submod.jl")
21+
"""
22+
end
23+
424
open("$name.jl", "w") do io
525
println(io, """
626
__precompile__($precomp)
@@ -12,7 +32,9 @@ using Requires
1232
flag = false
1333
1434
function __init__()
15-
@require JSON="682c06a0-de6a-54ab-a142-c8b1cf79cde6" global flag = true
35+
@require Colors="5ae59095-9a9b-59fe-a467-6f913c188581" begin
36+
$(action)
37+
end
1638
end
1739
1840
end
@@ -26,12 +48,22 @@ end
2648
npcdir = joinpath("FooNPC", "src")
2749
mkpath(npcdir)
2850
cd(npcdir) do
29-
writepkg("FooNPC", false)
51+
writepkg("FooNPC", false, false)
3052
end
3153
npcdir = joinpath("FooPC", "src")
3254
mkpath(npcdir)
3355
cd(npcdir) do
34-
writepkg("FooPC", true)
56+
writepkg("FooPC", true, false)
57+
end
58+
npcdir = joinpath("FooSubNPC", "src")
59+
mkpath(npcdir)
60+
cd(npcdir) do
61+
writepkg("FooSubNPC", false, true)
62+
end
63+
npcdir = joinpath("FooSubPC", "src")
64+
mkpath(npcdir)
65+
cd(npcdir) do
66+
writepkg("FooSubPC", true, true)
3567
end
3668
end
3769
push!(LOAD_PATH, pkgsdir)
@@ -40,28 +72,52 @@ end
4072
@test !FooNPC.flag
4173
@eval using FooPC
4274
@test !FooPC.flag
75+
@eval using FooSubNPC
76+
@test !(:SubModule in names(FooSubNPC))
77+
@eval using FooSubPC
78+
@test !(:SubModule in names(FooSubPC))
4379

44-
@eval using JSON
80+
@eval using Colors
4581

4682
@test FooNPC.flag
4783
@test FooPC.flag
84+
@test :SubModule in names(FooSubNPC)
85+
@test FooSubNPC.SubModule.flag
86+
@test :SubModule in names(FooSubPC)
87+
@test FooSubPC.SubModule.flag
4888

4989
cd(pkgsdir) do
5090
npcdir = joinpath("FooAfterNPC", "src")
5191
mkpath(npcdir)
5292
cd(npcdir) do
53-
writepkg("FooAfterNPC", false)
93+
writepkg("FooAfterNPC", false, false)
5494
end
5595
pcidr = joinpath("FooAfterPC", "src")
5696
mkpath(pcidr)
5797
cd(pcidr) do
58-
writepkg("FooAfterPC", true)
98+
writepkg("FooAfterPC", true, false)
99+
end
100+
sanpcdir = joinpath("FooSubAfterNPC", "src")
101+
mkpath(sanpcdir)
102+
cd(sanpcdir) do
103+
writepkg("FooSubAfterNPC", false, true)
104+
end
105+
sapcdir = joinpath("FooSubAfterPC", "src")
106+
mkpath(sapcdir)
107+
cd(sapcdir) do
108+
writepkg("FooSubAfterPC", true, true)
59109
end
60110
end
61111

62112
@eval using FooAfterNPC
63113
@eval using FooAfterPC
114+
@eval using FooSubAfterNPC
115+
@eval using FooSubAfterPC
64116
@test FooAfterNPC.flag
65117
@test FooAfterPC.flag
118+
@test :SubModule in names(FooSubAfterNPC)
119+
@test FooSubAfterNPC.SubModule.flag
120+
@test :SubModule in names(FooSubAfterPC)
121+
@test FooSubAfterPC.SubModule.flag
66122
end
67123
end

0 commit comments

Comments
 (0)