30
30
function pfd_tst_reads (idx, intvl)
31
31
global ready += 1
32
32
wait (ready_c)
33
- t_elapsed = @elapsed begin
34
- start_evt2 = Condition ()
35
- evt2 = @async (notify (start_evt2); poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false ))
36
- wait (start_evt2); yield () # make sure the async poll_fd is pumping events
37
- evt = poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false )
38
- end
33
+ start_evt2 = Condition ()
34
+ evt2 = @async (notify (start_evt2); poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false ))
35
+ wait (start_evt2); yield () # make sure the async poll_fd is pumping events
36
+ evt = poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false )
39
37
@test ! evt. timedout
40
38
@test evt. readable
41
39
@test ! evt. writable
42
40
@test evt === fetch (evt2)
43
41
44
- # println("Expected ", intvl, ", actual ", t_elapsed, ", diff ", t_elapsed - intvl)
45
- # Disabled since this assertion fails randomly, notably on build VMs (issue #12824)
46
- # @test t_elapsed <= (intvl + 1)
47
-
48
42
dout = zeros (UInt8, 1 )
49
43
@static if Sys. iswindows ()
50
44
1 == ccall (:recv , stdcall, Cint, (Ptr{Cvoid}, Ptr{UInt8}, Cint, Cint), pipe_fds[idx][1 ], dout, 1 , 0 ) || error (Libc. FormatMessage ())
58
52
function pfd_tst_timeout (idx, intvl)
59
53
global ready += 1
60
54
wait (ready_c)
61
- t_elapsed = @elapsed begin
62
- start_evt2 = Condition ()
63
- evt2 = @async (notify (start_evt2); poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false ))
64
- wait (start_evt2); yield () # make sure the async poll_fd is pumping events
65
- evt = poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false )
66
- @test evt. timedout
67
- @test ! evt. readable
68
- @test ! evt. writable
69
- @test evt === fetch (evt2)
70
- end
71
-
72
- # Disabled since these assertions fail randomly, notably on build VMs (issue #12824)
73
- # @test intvl <= t_elapsed
74
- # @test t_elapsed <= (intvl + 1)
55
+ start_evt2 = Condition ()
56
+ evt2 = @async (notify (start_evt2); poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false ))
57
+ wait (start_evt2); yield () # make sure the async poll_fd is pumping events
58
+ evt = poll_fd (pipe_fds[idx][1 ], intvl; readable= true , writable= false )
59
+ @test evt. timedout
60
+ @test ! evt. readable
61
+ @test ! evt. writable
62
+ @test evt === fetch (evt2)
75
63
end
76
64
77
-
78
65
# Odd numbers trigger reads, even numbers timeout
79
66
for (i, intvl) in enumerate (intvls)
80
67
@sync begin
@@ -176,24 +163,24 @@ file = joinpath(dir, "afile.txt")
176
163
# initialize a watch_folder instance and create afile.txt
177
164
function test_init_afile ()
178
165
@test isempty (FileWatching. watched_folders)
179
- @test @elapsed ( @test ( watch_folder (dir, 0 ) == (" " => FileWatching. FileEvent ()))) <= 2
166
+ @test ( watch_folder (dir, 0 ) == (" " => FileWatching. FileEvent ()))
180
167
@test @elapsed (@test (watch_folder (dir, 0 ) == (" " => FileWatching. FileEvent ()))) <= 0.5
181
168
@test length (FileWatching. watched_folders) == 1
182
169
@test unwatch_folder (dir) === nothing
183
170
@test isempty (FileWatching. watched_folders)
184
- @test 0.001 <= @elapsed (@test (watch_folder (dir, 0.004 ) == (" " => FileWatching. FileEvent ()))) <= 2
185
- @test 0.001 <= @elapsed (@test (watch_folder (dir, 0.004 ) == (" " => FileWatching. FileEvent ()))) <= 0.5
171
+ @test 0.002 <= @elapsed (@test (watch_folder (dir, 0.004 ) == (" " => FileWatching. FileEvent ())))
172
+ @test 0.002 <= @elapsed (@test (watch_folder (dir, 0.004 ) == (" " => FileWatching. FileEvent ()))) <= 0.5
186
173
@test unwatch_folder (dir) === nothing
187
- @test 0.9 <= @elapsed (@test (watch_folder (dir, 1 ) == (" " => FileWatching. FileEvent ()))) <= 4
188
- @test 0.9 <= @elapsed (@test (watch_folder (dir, 1 ) == (" " => FileWatching. FileEvent ()))) <= 1.5
174
+ @test 0.99 <= @elapsed (@test (watch_folder (dir, 1 ) == (" " => FileWatching. FileEvent ())))
175
+ @test 0.99 <= @elapsed (@test (watch_folder (dir, 1 ) == (" " => FileWatching. FileEvent ())))
189
176
# like touch, but lets the operating system update the timestamp
190
177
# for greater precision on some platforms (windows)
191
178
@test close (open (file, " w" )) === nothing
192
- @test @elapsed ( @test ( watch_folder (dir) == (F_PATH => FileWatching. FileEvent (FileWatching. UV_RENAME)))) <= 0.5
179
+ @test ( watch_folder (dir) == (F_PATH => FileWatching. FileEvent (FileWatching. UV_RENAME)))
193
180
@test close (open (file, " w" )) === nothing
194
181
sleep (3 )
195
182
let c
196
- @test @elapsed ( c = watch_folder (dir, 0 )) <= 0.5
183
+ c = watch_folder (dir, 0 )
197
184
if F_GETPATH
198
185
@test c. first == F_PATH
199
186
@test c. second. changed ⊻ c. second. renamed
@@ -205,8 +192,8 @@ function test_init_afile()
205
192
end
206
193
end
207
194
@test unwatch_folder (dir) === nothing
208
- @test @elapsed ( @test ( watch_folder (dir, 0 ) == (" " => FileWatching. FileEvent ()))) <= 0.5
209
- @test 0.9 <= @elapsed (@test (watch_folder (dir, 1 ) == (" " => FileWatching. FileEvent ()))) <= 1.5
195
+ @test ( watch_folder (dir, 0 ) == (" " => FileWatching. FileEvent ()))
196
+ @test 0.9 <= @elapsed (@test (watch_folder (dir, 1 ) == (" " => FileWatching. FileEvent ())))
210
197
@test length (FileWatching. watched_folders) == 1
211
198
nothing
212
199
end
@@ -384,8 +371,8 @@ mv(file * "~", file)
384
371
let changes = []
385
372
while true
386
373
let c
387
- timeout = Sys. iswindows () ? 0.1 : 0.0
388
- @test @elapsed (c = watch_folder (dir, timeout )) < 0.5
374
+ Sys. iswindows () && sleep ( 0.1 )
375
+ @test @elapsed (c = watch_folder (dir, 0.0 )) < 0.5
389
376
push! (changes, c)
390
377
(c. second:: FileWatching.FileEvent ). timedout && break
391
378
end
0 commit comments