@@ -34,26 +34,27 @@ rewatch_bg watch > rewatch.log 2>&1 &
3434if ! 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
4048fi
4149
4250initial_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
4554if ! 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
5960fi
@@ -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
6870expected_completed=$(( initial_completed + 1 ))
6971if ! 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
7577fi
7678
7779echo ' // watch-recovery-test' >> src/Test.res
7880if ! 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
8587fi
8688
0 commit comments