mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
remote: fix flaky collectGarbage for MITM test
This commit is contained in:
parent
e374687467
commit
619687b446
@ -5,6 +5,7 @@ module NixDaemonSpec
|
||||
, spec
|
||||
) where
|
||||
|
||||
import Control.Exception (catch, SomeException)
|
||||
import Control.Monad (forM_, unless, void)
|
||||
import Control.Monad.Catch (MonadMask)
|
||||
import Control.Monad.Conc.Class (MonadConc)
|
||||
@ -465,13 +466,17 @@ makeProtoSpec f flavor = around f $ do
|
||||
-- clear temp gc roots so the delete works. restarting the nix daemon should also do this...
|
||||
storeDir <- getStoreDir
|
||||
let tempRootsDir = Data.Text.unpack $ mconcat [ Data.Text.Encoding.decodeUtf8 (unStoreDir storeDir), "/../var/nix/temproots/" ]
|
||||
tempRootList <-
|
||||
liftIO
|
||||
$ System.Directory.listDirectory
|
||||
tempRootsDir
|
||||
liftIO $ forM_ tempRootList $ \entry -> do
|
||||
System.Directory.removeFile
|
||||
$ mconcat [ tempRootsDir, "/", entry ]
|
||||
liftIO $ do
|
||||
tempRootList <-
|
||||
System.Directory.listDirectory tempRootsDir
|
||||
forM_ tempRootList $ \entry -> do
|
||||
System.Directory.removeFile
|
||||
$ mconcat [ tempRootsDir, "/", entry ]
|
||||
-- for MITM, the temp root will get deleted
|
||||
-- by the daemon as our nested client exists
|
||||
-- but the listDirectory might still see it
|
||||
-- causing TOC/TOU flakiness
|
||||
`catch` (\(_e :: SomeException) -> pure ())
|
||||
|
||||
GCResult{..} <-
|
||||
collectGarbage
|
||||
|
Loading…
Reference in New Issue
Block a user