Refuse to clean while a watcher of the project runs
Why
rescript clean took only the build lock, which a watcher holds only while it builds, so a clean during rescript watch removed the artifacts the watcher kept reading, and every later rebuild failed (#9241).
addedDiagnostic rescript clean while rescript watch runs
text
Before
After
Cleaning x, exit 0; the watcher then fails with Sys_error("<root>/lib/rescript/A.ast: No such file or directory")exit 1; the artifacts and the watcher are left as they were
diagnostic
Could not clean while rescript watch or another clean is running. The process ID (PID) is 4242Clean now takes the watch lock of the folder it cleans, as rescript watch does, before the build lock.
Review
- Does a clean of a workspace see a watcher of one of its members? No: each takes the watch lock of the folder it was given, and a watcher takes it before it reads the configuration, which a test requires.