Skip to content

Commit

Permalink
Close race condition in Filewatching tests (#46028)
Browse files Browse the repository at this point in the history
On some machines, we are able to delay starting our loop until more than
a second after we take the lock, which of course breaks the test.  Let's
use a synchronization barrier to ensure that we're testing what we
intend to.
  • Loading branch information
staticfloat authored Jul 15, 2022
1 parent fd70eab commit c7e2f9b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/FileWatching/test/pidfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ end

# Just for coverage's sake, run a test with do-block syntax
lock_times = Float64[]
synchronizer = Base.Event()
t_loop = @async begin
wait(synchronizer)
for idx in 1:100
t = @elapsed mkpidlock("do_block_pidfile") do
# nothing
Expand All @@ -283,6 +285,7 @@ end
end
isdefined(Base, :errormonitor) && Base.errormonitor(t_loop)
mkpidlock("do_block_pidfile") do
notify(synchronizer)
sleep(3)
end
wait(t_loop)
Expand Down

0 comments on commit c7e2f9b

Please sign in to comment.