Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions rewatch-ocaml/tests/check_command_validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,14 @@ for implementation in rust ocaml; do
fi
normalize_project_path "$work/quiet-watch-$implementation.err" \
"$work/quiet-watch-$implementation.err.norm" "$quiet_watch_project"
# macOS and Windows can report one write as several change events, and each
# rebuild reports the parse error again. Compare the distinct reports only.
node -e '
const fs = require("fs");
const blocks = fs.readFileSync(process.argv[1], "utf8").split(/^(?=Error in )/m);
const distinct = blocks.filter((block, i) => block !== blocks[i - 1]);
fs.writeFileSync(process.argv[1], distinct.join(""));
' "$work/quiet-watch-$implementation.err.norm"
done
if ! cmp -s "$work/quiet-watch-rust.err.norm" \
"$work/quiet-watch-ocaml.err.norm"; then
Expand Down
19 changes: 17 additions & 2 deletions rewatch-ocaml/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1923,10 +1923,25 @@ background_pids="$background_pids $retained_parse_pid"
wait_for_initial_build "$retained_parse/watch.log"
printf 'let value =\n' >"$retained_parse/src/A.res"
wait_for_text "$retained_parse/watch.log" 'This let-binding misses an expression'
# Windows can report one write as several change events, and each one starts
# a rebuild that parses A and reports its error again. Wait until those
# rebuilds are over, so that the counts only grow from the edit of B.
failed_parses=$(grep -c '^parse.*A\.res' "$retained_parse/calls.log")
quiet_polls=0
while [ "$quiet_polls" -lt 10 ]; do
sleep 0.1
parses=$(grep -c '^parse.*A\.res' "$retained_parse/calls.log")
if [ "$parses" = "$failed_parses" ]; then
quiet_polls=$((quiet_polls + 1))
else
failed_parses=$parses
quiet_polls=0
fi
done
reported_errors=$(grep -c 'This let-binding misses an expression' "$retained_parse/watch.log")
printf 'let other = 2\n' >"$retained_parse/src/B.res"
wait_for_text "$retained_parse/watch.log" 'This let-binding misses an expression' 2
test "$(grep -c '^parse.*A\.res' "$retained_parse/calls.log")" -gt "$failed_parses"
wait_for_count "$retained_parse/calls.log" '^parse.*A\.res' $((failed_parses + 1))
wait_for_text "$retained_parse/watch.log" 'This let-binding misses an expression' $((reported_errors + 1))
grep 'value = 1' "$retained_parse/src/A.js" >/dev/null
printf 'let value = 2\n' >"$retained_parse/src/A.res"
wait_for_text "$retained_parse/src/A.js" 'value = 2'
Expand Down
Loading