Skip to content

Commit ae6f361

Browse files
tryfix
1 parent 6f5fcfb commit ae6f361

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/api.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,19 @@ import .FakeTerminals.FakeTerminal
160160

161161
dep8_path = git_init_package(tmp, joinpath("packages", "Dep8"))
162162
dep8_srcfile = joinpath(dep8_path, "src", "Dep8.jl")
163+
change_dep8() = write(dep8_srcfile, read(dep8_srcfile, String) * " ") # Modify the source to ensure it is recompiled
163164
@testset "delayed precompilation with do-syntax" begin
164165
iob = IOBuffer()
165166
# Test that operations inside Pkg.precompile() do block don't trigger auto-precompilation
166167
Pkg.precompile(io=iob) do
167-
write(dep8_srcfile, read(dep8_srcfile, String) * " ") # Modify the source to ensure it is recompiled
168168
Pkg.add(Pkg.PackageSpec(path=dep8_path))
169169
Pkg.rm("Dep8")
170-
write(dep8_srcfile, read(dep8_srcfile, String) * " ") # Modify the source to ensure it is recompiled
170+
change_dep8()
171171
Pkg.add(Pkg.PackageSpec(path=dep8_path))
172172
end
173173

174174
# The precompile should happen once at the end
175-
str = String(take!(iob))
176-
@test occursin("Precompiling", str)
175+
@test count(r"Precompiling", String(take!(iob))) == 1 # should only precompile once
177176

178177
# Verify it was precompiled by checking a second call is a no-op
179178
Pkg.precompile(io=iob)
@@ -192,7 +191,7 @@ import .FakeTerminals.FakeTerminal
192191
@test Pkg._autoprecompilation_enabled == false
193192

194193
# Operations should not trigger autoprecompilation when globally disabled
195-
write(dep8_srcfile, read(dep8_srcfile, String) * " ") # Modify the source to ensure it is recompiled
194+
change_dep8()
196195
Pkg.add(Pkg.PackageSpec(path=dep8_path), io=iob)
197196
@test !occursin("Precompiling", String(take!(iob)))
198197

@@ -206,7 +205,7 @@ import .FakeTerminals.FakeTerminal
206205

207206
# Operations should now trigger autoprecompilation again
208207
Pkg.rm("Dep8", io=iob)
209-
write(dep8_srcfile, read(dep8_srcfile, String) * " ") # Modify the source to ensure it is recompiled
208+
change_dep8()
210209
Pkg.add(Pkg.PackageSpec(path=dep8_path), io=iob)
211210
@test occursin("Precompiling", String(take!(iob)))
212211

0 commit comments

Comments
 (0)