Skip to content

Commit a4a65f3

Browse files
Fix watcher recovery test on Windows
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
1 parent 1e2469f commit a4a65f3

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

‎rewatch/tests/watch/07-watch-recovers-from-invalid-config.sh‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,27 @@ rewatch_bg watch > rewatch.log 2>&1 &
3434
if ! wait_for_file "./src/Test.mjs" 20 || ! wait_for_file "lib/watch.lock" 20; then
3535
error "Initial watch build did not complete"
3636
cat rewatch.log
37+
exit_watcher
3738
mv rescript.json.watch-recovery.bak rescript.json
39+
exit 1
40+
fi
41+
42+
if ! wait_for_pattern rewatch.log "Finished initial compilation" 60; then
43+
error "Initial watch build did not finish"
44+
cat rewatch.log
3845
exit_watcher
46+
mv rescript.json.watch-recovery.bak rescript.json
3947
exit 1
4048
fi
4149

4250
initial_completed=$(grep -c "Finished compilation" rewatch.log 2> /dev/null || true)
43-
printf '{"name":' > rescript.json
51+
printf '{"name":' > rescript.json.watch-recovery.next
52+
mv rescript.json.watch-recovery.next rescript.json
4453

4554
if ! wait_for_pattern rewatch.log "Could not initialize build" 30; then
4655
error "Watcher did not report the invalid config"
4756
cat rewatch.log
48-
mv rescript.json.watch-recovery.bak rescript.json
4957
exit_watcher
50-
exit 1
51-
fi
52-
53-
watcher_pid=$(cat lib/watch.lock)
54-
if ! kill -0 "$watcher_pid" 2> /dev/null; then
55-
error "Watcher exited after the invalid config"
56-
cat rewatch.log
5758
mv rescript.json.watch-recovery.bak rescript.json
5859
exit 1
5960
fi
@@ -63,24 +64,25 @@ node -e '
6364
const config = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
6465
config.suffix = ".recovered.mjs";
6566
fs.writeFileSync(process.argv[2], `${JSON.stringify(config, null, 2)}\n`);
66-
' rescript.json.watch-recovery.bak rescript.json
67+
' rescript.json.watch-recovery.bak rescript.json.watch-recovery.next
68+
mv rescript.json.watch-recovery.next rescript.json
6769

6870
expected_completed=$((initial_completed + 1))
6971
if ! wait_for_pattern_count rewatch.log "Finished compilation" "$expected_completed" 30; then
7072
error "Watcher did not recover after restoring a valid config"
7173
cat rewatch.log
72-
mv rescript.json.watch-recovery.bak rescript.json
7374
exit_watcher
75+
mv rescript.json.watch-recovery.bak rescript.json
7476
exit 1
7577
fi
7678

7779
echo '// watch-recovery-test' >> src/Test.res
7880
if ! wait_for_file "./src/Test.recovered.mjs" 20; then
7981
error "Recovered watcher did not compile with the restored config"
8082
cat rewatch.log
83+
exit_watcher
8184
mv rescript.json.watch-recovery.bak rescript.json
8285
git checkout -- src/Test.res
83-
exit_watcher
8486
exit 1
8587
fi
8688

0 commit comments

Comments
 (0)