Skip to content
Merged
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
10 changes: 10 additions & 0 deletions tests/LifecycleTests.lean
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,22 @@ def withFixture (test : Fixture → IO Unit) : IO Unit := do
try test f
finally
let sessions := root / "data" / "sessions"
let mut managers : List Nat := []
if ← sessions.isDir then
for entry in ← sessions.readDir do
try
let endpoint ← IO.ofExcept (fromJson? (← readObject (entry.path / "daemon.json")) : Except String Daemon.Endpoint)
managers := endpoint.pid :: managers
let _ ← Daemon.exchange endpoint "shutdown" .null
catch _ => pure ()
-- A shutdown reply acknowledges the request before the manager has removed
-- its endpoint and stopped writing. Wait for process exit before traversing
-- the fixture tree; otherwise removeDirAll can race daemon.json removal.
for pid in managers do
awaitCondition (do
let result ← IO.Process.output { cmd := "ps", args := #["-o", "stat=", "-p", toString pid] }
let status := result.stdout.trimAscii.toString
return status.isEmpty || status.startsWith "Z") "fixture manager shutdown"
IO.FS.removeDirAll root

def main (args : List String) : IO UInt32 := do
Expand Down