@@ -1073,6 +1073,39 @@ let c, r, res
1073
1073
@test res === false
1074
1074
end
1075
1075
1076
+ # A pair of utility function for the REPL completions test to test PATH_cache
1077
+ # dependent completions, which ordinarily happen asynchronously.
1078
+ # Only to be used from the test suite
1079
+ function test_only_arm_cache_refresh ()
1080
+ @lock REPL. REPLCompletions. PATH_cache_lock begin
1081
+ @assert REPL. REPLCompletions. PATH_cache_condition === nothing
1082
+
1083
+ # Arm a condition we can wait on
1084
+ REPL. REPLCompletions. PATH_cache_condition = Threads. Condition (REPL. REPLCompletions. PATH_cache_lock)
1085
+
1086
+ # Check if the previous update is still running - if so, wait for it to finish
1087
+ while REPL. REPLCompletions. PATH_cache_task != = nothing
1088
+ @assert ! istaskdone (REPL. REPLCompletions. PATH_cache_task)
1089
+ wait (REPL. REPLCompletions. PATH_cache_condition)
1090
+ end
1091
+
1092
+ # force the next cache update to happen immediately
1093
+ REPL. REPLCompletions. next_cache_update = 0
1094
+ end
1095
+ return REPL. REPLCompletions. PATH_cache_condition
1096
+ end
1097
+
1098
+ function test_only_wait_cache_path_done ()
1099
+ @lock REPL. REPLCompletions. PATH_cache_lock begin
1100
+ @assert REPL. REPLCompletions. PATH_cache_condition != = nothing
1101
+
1102
+ while REPL. REPLCompletions. next_cache_update == 0.
1103
+ wait (REPL. REPLCompletions. PATH_cache_condition)
1104
+ end
1105
+ REPL. REPLCompletions. PATH_cache_condition = nothing
1106
+ end
1107
+ end
1108
+
1076
1109
if Sys. isunix ()
1077
1110
let s, c, r
1078
1111
# Assume that we can rely on the existence and accessibility of /tmp
@@ -1204,12 +1237,9 @@ let s, c, r
1204
1237
# Files reachable by PATH are cached async when PATH is seen to have been changed by `complete_path`
1205
1238
# so changes are unlikely to appear in the first complete. For testing purposes we can wait for
1206
1239
# caching to finish
1207
- @lock REPL. REPLCompletions. PATH_cache_lock begin
1208
- # force the next cache update to happen immediately
1209
- REPL. REPLCompletions. next_cache_update = 0
1210
- end
1240
+ test_only_arm_cache_refresh ()
1211
1241
c,r = test_scomplete (s)
1212
- timedwait (() -> REPL . REPLCompletions . next_cache_update != 0 , 5 ) # wait for caching to complete
1242
+ test_only_wait_cache_path_done ()
1213
1243
c,r = test_scomplete (s)
1214
1244
@test " tmp-executable" in c
1215
1245
@test r == 1 : 9
@@ -1238,12 +1268,9 @@ let s, c, r
1238
1268
1239
1269
withenv (" PATH" => string (tempdir (), " :" , dir)) do
1240
1270
s = string (" repl-completio" )
1241
- @lock REPL. REPLCompletions. PATH_cache_lock begin
1242
- # force the next cache update to happen immediately
1243
- REPL. REPLCompletions. next_cache_update = 0
1244
- end
1271
+ test_only_arm_cache_refresh ()
1245
1272
c,r = test_scomplete (s)
1246
- timedwait (() -> REPL . REPLCompletions . next_cache_update != 0 , 5 ) # wait for caching to complete
1273
+ test_only_wait_cache_path_done ()
1247
1274
c,r = test_scomplete (s)
1248
1275
@test [" repl-completion" ] == c
1249
1276
@test s[r] == " repl-completio"
0 commit comments