1
1
using Test
2
2
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
+
4
24
open (" $name .jl" , " w" ) do io
5
25
println (io, """
6
26
__precompile__($precomp )
@@ -12,7 +32,9 @@ using Requires
12
32
flag = false
13
33
14
34
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
16
38
end
17
39
18
40
end
26
48
npcdir = joinpath (" FooNPC" , " src" )
27
49
mkpath (npcdir)
28
50
cd (npcdir) do
29
- writepkg (" FooNPC" , false )
51
+ writepkg (" FooNPC" , false , false )
30
52
end
31
53
npcdir = joinpath (" FooPC" , " src" )
32
54
mkpath (npcdir)
33
55
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 )
35
67
end
36
68
end
37
69
push! (LOAD_PATH , pkgsdir)
40
72
@test ! FooNPC. flag
41
73
@eval using FooPC
42
74
@test ! FooPC. flag
75
+ @eval using FooSubNPC
76
+ @test ! (:SubModule in names (FooSubNPC))
77
+ @eval using FooSubPC
78
+ @test ! (:SubModule in names (FooSubPC))
43
79
44
- @eval using JSON
80
+ @eval using Colors
45
81
46
82
@test FooNPC. flag
47
83
@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
48
88
49
89
cd (pkgsdir) do
50
90
npcdir = joinpath (" FooAfterNPC" , " src" )
51
91
mkpath (npcdir)
52
92
cd (npcdir) do
53
- writepkg (" FooAfterNPC" , false )
93
+ writepkg (" FooAfterNPC" , false , false )
54
94
end
55
95
pcidr = joinpath (" FooAfterPC" , " src" )
56
96
mkpath (pcidr)
57
97
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 )
59
109
end
60
110
end
61
111
62
112
@eval using FooAfterNPC
63
113
@eval using FooAfterPC
114
+ @eval using FooSubAfterNPC
115
+ @eval using FooSubAfterPC
64
116
@test FooAfterNPC. flag
65
117
@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
66
122
end
67
123
end
0 commit comments