Skip to content

Commit 19bf531

Browse files
Fix possible race condition in rewatch test
1 parent be17a60 commit 19bf531

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

rewatch/tests/watch/06-watch-missing-source-folder.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,23 @@ git checkout "$DEP01_CONFIG"
6565

6666
# Rebuild to regenerate any artifacts that were removed by `rewatch clean`
6767
# but not rebuilt due to the modified config (e.g. Dep01.mjs).
68-
rewatch build > /dev/null 2>&1
68+
if ! rewatch build > /dev/null 2>&1; then
69+
error "Rebuild after restoring config failed"
70+
rm -f rewatch.log
71+
exit 1
72+
fi
73+
74+
# Slow CI runners can still be catching up on file restoration when the build
75+
# command returns. Wait until git no longer sees tracked deletions before doing
76+
# the final cleanliness check.
77+
timeout=20
78+
while [ "$timeout" -gt 0 ]; do
79+
if [ -z "$(git diff --name-only --diff-filter=D .)" ]; then
80+
break
81+
fi
82+
sleep 1
83+
timeout=$((timeout - 1))
84+
done
6985
rm -f rewatch.log
7086

7187
if git diff --exit-code . > /dev/null 2>&1 && [ -z "$(git ls-files --others --exclude-standard .)" ];

0 commit comments

Comments
 (0)