@@ -42,144 +42,140 @@ end
4242 end
4343end
4444
45- @testset " Requires" begin
46- mktempdir () do pkgsdir
47- local rm_CachedIncludeTest_submod_file
48- cd (pkgsdir) do
49- npcdir = joinpath (" FooNPC" , " src" )
50- mkpath (npcdir)
51- cd (npcdir) do
52- writepkg (" FooNPC" , false , false )
53- end
54- npcdir = joinpath (" FooPC" , " src" )
55- mkpath (npcdir)
56- cd (npcdir) do
57- writepkg (" FooPC" , true , false )
58- end
59- npcdir = joinpath (" FooSubNPC" , " src" )
60- mkpath (npcdir)
61- cd (npcdir) do
62- writepkg (" FooSubNPC" , false , true )
63- end
64- npcdir = joinpath (" FooSubPC" , " src" )
65- mkpath (npcdir)
66- cd (npcdir) do
67- writepkg (" FooSubPC" , true , true )
68- end
69- npcdir = joinpath (" CachedIncludeTest" , " src" )
70- mkpath (npcdir)
71- cd (npcdir) do
72- writepkg (" CachedIncludeTest" , true , true )
73- submod_file = abspath (" CachedIncludeTest_submod.jl" )
74- @test isfile (submod_file)
75- rm_CachedIncludeTest_submod_file = ()-> rm (submod_file)
76- end
77- end
78- push! (LOAD_PATH , pkgsdir)
79-
80- @eval using FooNPC
81- @test ! FooNPC. flag
82- @eval using FooPC
83- @test ! FooPC. flag
84- @eval using FooSubNPC
85- @test ! (:SubModule in names (FooSubNPC))
86- @eval using FooSubPC
87- @test ! (:SubModule in names (FooSubPC))
88- @eval using CachedIncludeTest
89- # Test that the content of the file which defines
90- # CachedIncludeTest.SubModule is cached by `@require` so it can be used
91- # even when the file itself is removed.
92- rm_CachedIncludeTest_submod_file ()
93- @test ! (:SubModule in names (CachedIncludeTest))
94-
95- @eval using Colors
96-
97- @test FooNPC. flag
98- @test FooPC. flag
99- @test :SubModule in names (FooSubNPC)
100- @test FooSubNPC. SubModule. flag
101- @test :SubModule in names (FooSubPC)
102- @test FooSubPC. SubModule. flag
103- @test :SubModule in names (CachedIncludeTest)
104-
105- cd (pkgsdir) do
106- npcdir = joinpath (" FooAfterNPC" , " src" )
107- mkpath (npcdir)
108- cd (npcdir) do
109- writepkg (" FooAfterNPC" , false , false )
110- end
111- pcidr = joinpath (" FooAfterPC" , " src" )
112- mkpath (pcidr)
113- cd (pcidr) do
114- writepkg (" FooAfterPC" , true , false )
115- end
116- sanpcdir = joinpath (" FooSubAfterNPC" , " src" )
117- mkpath (sanpcdir)
118- cd (sanpcdir) do
119- writepkg (" FooSubAfterNPC" , false , true )
120- end
121- sapcdir = joinpath (" FooSubAfterPC" , " src" )
122- mkpath (sapcdir)
123- cd (sapcdir) do
124- writepkg (" FooSubAfterPC" , true , true )
125- end
126- end
45+ pkgsdir = mktempdir ()
46+ cd (pkgsdir) do
47+ npcdir = joinpath (" FooNPC" , " src" )
48+ mkpath (npcdir)
49+ cd (npcdir) do
50+ writepkg (" FooNPC" , false , false )
51+ end
52+ npcdir = joinpath (" FooPC" , " src" )
53+ mkpath (npcdir)
54+ cd (npcdir) do
55+ writepkg (" FooPC" , true , false )
56+ end
57+ npcdir = joinpath (" FooSubNPC" , " src" )
58+ mkpath (npcdir)
59+ cd (npcdir) do
60+ writepkg (" FooSubNPC" , false , true )
61+ end
62+ npcdir = joinpath (" FooSubPC" , " src" )
63+ mkpath (npcdir)
64+ cd (npcdir) do
65+ writepkg (" FooSubPC" , true , true )
66+ end
67+ npcdir = joinpath (" CachedIncludeTest" , " src" )
68+ mkpath (npcdir)
69+ cd (npcdir) do
70+ writepkg (" CachedIncludeTest" , true , true )
71+ submod_file = abspath (" CachedIncludeTest_submod.jl" )
72+ @test isfile (submod_file)
73+ global rm_CachedIncludeTest_submod_file = ()-> rm (submod_file)
74+ end
75+ end
76+ push! (LOAD_PATH , pkgsdir)
77+
78+ using FooNPC
79+ @test ! FooNPC. flag
80+ using FooPC
81+ @test ! FooPC. flag
82+ using FooSubNPC
83+ @test ! (:SubModule in names (FooSubNPC))
84+ using FooSubPC
85+ @test ! (:SubModule in names (FooSubPC))
86+ using CachedIncludeTest
87+ # Test that the content of the file which defines
88+ # CachedIncludeTest.SubModule is cached by `@require` so it can be used
89+ # even when the file itself is removed.
90+ rm_CachedIncludeTest_submod_file ()
91+ @test ! (:SubModule in names (CachedIncludeTest))
92+
93+ using Colors
94+
95+ @test FooNPC. flag
96+ @test FooPC. flag
97+ @test :SubModule in names (FooSubNPC)
98+ @test FooSubNPC. SubModule. flag
99+ @test :SubModule in names (FooSubPC)
100+ @test FooSubPC. SubModule. flag
101+ @test :SubModule in names (CachedIncludeTest)
102+
103+ cd (pkgsdir) do
104+ npcdir = joinpath (" FooAfterNPC" , " src" )
105+ mkpath (npcdir)
106+ cd (npcdir) do
107+ writepkg (" FooAfterNPC" , false , false )
108+ end
109+ pcidr = joinpath (" FooAfterPC" , " src" )
110+ mkpath (pcidr)
111+ cd (pcidr) do
112+ writepkg (" FooAfterPC" , true , false )
113+ end
114+ sanpcdir = joinpath (" FooSubAfterNPC" , " src" )
115+ mkpath (sanpcdir)
116+ cd (sanpcdir) do
117+ writepkg (" FooSubAfterNPC" , false , true )
118+ end
119+ sapcdir = joinpath (" FooSubAfterPC" , " src" )
120+ mkpath (sapcdir)
121+ cd (sapcdir) do
122+ writepkg (" FooSubAfterPC" , true , true )
123+ end
124+ end
127125
128- @eval using FooAfterNPC
129- @eval using FooAfterPC
130- @eval using FooSubAfterNPC
131- @eval using FooSubAfterPC
126+ using FooAfterNPC
127+ using FooAfterPC
128+ using FooSubAfterNPC
129+ using FooSubAfterPC
132130
133- pop! (LOAD_PATH )
131+ pop! (LOAD_PATH )
134132
135- @test FooAfterNPC. flag
136- @test FooAfterPC. flag
137- @test :SubModule in names (FooSubAfterNPC)
138- @test FooSubAfterNPC. SubModule. flag
139- @test :SubModule in names (FooSubAfterPC)
140- @test FooSubAfterPC. SubModule. flag
141- end
142- end
133+ @test FooAfterNPC. flag
134+ @test FooAfterPC. flag
135+ @test :SubModule in names (FooSubAfterNPC)
136+ @test FooSubAfterNPC. SubModule. flag
137+ @test :SubModule in names (FooSubAfterPC)
138+ @test FooSubAfterPC. SubModule. flag
143139
144140module EvalModule end
145141
146142@testset " Notifications" begin
147- push! (LOAD_PATH , joinpath (@__DIR__ , " pkgs" ))
148- @eval using NotifyMe
149-
150- mktempdir () do pkgsdir
151- ndir = joinpath (" NotifyTarget" , " src" )
152- cd (pkgsdir) do
153- mkpath (ndir)
154- cd (ndir) do
155- open (" NotifyTarget.jl" , " w" ) do io
156- println (io, """
157- module NotifyTarget
158- using Requires
159- function __init__()
160- @require Example="7876af07-990d-54b4-ab0e-23690620f79a" begin
161- f(x) = 2x
162- end
163- end
143+ push! (LOAD_PATH , joinpath (@__DIR__ , " pkgs" ))
144+ using NotifyMe
145+
146+ pkgdir = mktempdir ()
147+ ndir = joinpath (" NotifyTarget" , " src" )
148+ cd (pkgsdir) do
149+ mkpath (ndir)
150+ cd (ndir) do
151+ open (" NotifyTarget.jl" , " w" ) do io
152+ println (io, """
153+ module NotifyTarget
154+ using Requires
155+ function __init__()
156+ @require Example="7876af07-990d-54b4-ab0e-23690620f79a" begin
157+ f(x) = 2x
164158 end
165- """ )
166159 end
167160 end
161+ """ )
168162 end
169- push! (LOAD_PATH , pkgsdir)
170- @test isempty (NotifyMe. notified_args)
171- @eval using NotifyTarget
172- @test isempty (NotifyMe. notified_args)
173- @eval using Example
174- @test length (NotifyMe. notified_args) == 1
175- nargs = NotifyMe. notified_args[1 ]
176- @test nargs[1 ] == joinpath (pkgsdir, ndir, " NotifyTarget.jl" )
177- @test nargs[2 ] == NotifyTarget
178- @test nargs[3 ] == " 7876af07-990d-54b4-ab0e-23690620f79a"
179- @test nargs[4 ] == " Example"
180- Core. eval (EvalModule, nargs[5 ])
181- @test Base. invokelatest (EvalModule. f, 3 ) == 6
182163 end
164+ end
165+ push! (LOAD_PATH , pkgsdir)
166+ @test isempty (NotifyMe. notified_args)
167+ using NotifyTarget
168+ @test isempty (NotifyMe. notified_args)
169+ using Example
170+ @test length (NotifyMe. notified_args) == 1
171+ nargs = NotifyMe. notified_args[1 ]
172+ @test nargs[1 ] == joinpath (pkgsdir, ndir, " NotifyTarget.jl" )
173+ @test nargs[2 ] == NotifyTarget
174+ @test nargs[3 ] == " 7876af07-990d-54b4-ab0e-23690620f79a"
175+ @test nargs[4 ] == " Example"
176+ Core. eval (EvalModule, nargs[5 ])
177+ @test Base. invokelatest (EvalModule. f, 3 ) == 6
183178
184- pop! (LOAD_PATH )
185179end
180+
181+ pop! (LOAD_PATH )
0 commit comments