Skip to content

Commit 44018a2

Browse files
cknittclaude
andcommitted
Fix flaky retained-parse watch test on Windows
Windows can report one write as several change events, each rebuilding and re-reporting A. Wait for those rebuilds before counting, then poll for A's re-parse after the edit of B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193XhTJFgkaaGZTNw9Uqd5v Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent b53635a commit 44018a2

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎rewatch-ocaml/tests/run.sh‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,10 +1923,25 @@ background_pids="$background_pids $retained_parse_pid"
19231923
wait_for_initial_build "$retained_parse/watch.log"
19241924
printf 'let value =\n' >"$retained_parse/src/A.res"
19251925
wait_for_text "$retained_parse/watch.log" 'This let-binding misses an expression'
1926+
# Windows can report one write as several change events, and each one starts
1927+
# a rebuild that parses A and reports its error again. Wait until those
1928+
# rebuilds are over, so that the counts only grow from the edit of B.
19261929
failed_parses=$(grep -c '^parse.*A\.res' "$retained_parse/calls.log")
1930+
quiet_polls=0
1931+
while [ "$quiet_polls" -lt 10 ]; do
1932+
sleep 0.1
1933+
parses=$(grep -c '^parse.*A\.res' "$retained_parse/calls.log")
1934+
if [ "$parses" = "$failed_parses" ]; then
1935+
quiet_polls=$((quiet_polls + 1))
1936+
else
1937+
failed_parses=$parses
1938+
quiet_polls=0
1939+
fi
1940+
done
1941+
reported_errors=$(grep -c 'This let-binding misses an expression' "$retained_parse/watch.log")
19271942
printf 'let other = 2\n' >"$retained_parse/src/B.res"
1928-
wait_for_text "$retained_parse/watch.log" 'This let-binding misses an expression' 2
1929-
test "$(grep -c '^parse.*A\.res' "$retained_parse/calls.log")" -gt "$failed_parses"
1943+
wait_for_count "$retained_parse/calls.log" '^parse.*A\.res' $((failed_parses + 1))
1944+
wait_for_text "$retained_parse/watch.log" 'This let-binding misses an expression' $((reported_errors + 1))
19301945
grep 'value = 1' "$retained_parse/src/A.js" >/dev/null
19311946
printf 'let value = 2\n' >"$retained_parse/src/A.res"
19321947
wait_for_text "$retained_parse/src/A.js" 'value = 2'

0 commit comments

Comments
 (0)