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
|
, spec
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Control.Exception (catch, SomeException)
|
||||||
import Control.Monad (forM_, unless, void)
|
import Control.Monad (forM_, unless, void)
|
||||||
import Control.Monad.Catch (MonadMask)
|
import Control.Monad.Catch (MonadMask)
|
||||||
import Control.Monad.Conc.Class (MonadConc)
|
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...
|
-- clear temp gc roots so the delete works. restarting the nix daemon should also do this...
|
||||||
storeDir <- getStoreDir
|
storeDir <- getStoreDir
|
||||||
let tempRootsDir = Data.Text.unpack $ mconcat [ Data.Text.Encoding.decodeUtf8 (unStoreDir storeDir), "/../var/nix/temproots/" ]
|
let tempRootsDir = Data.Text.unpack $ mconcat [ Data.Text.Encoding.decodeUtf8 (unStoreDir storeDir), "/../var/nix/temproots/" ]
|
||||||
tempRootList <-
|
liftIO $ do
|
||||||
liftIO
|
tempRootList <-
|
||||||
$ System.Directory.listDirectory
|
System.Directory.listDirectory tempRootsDir
|
||||||
tempRootsDir
|
forM_ tempRootList $ \entry -> do
|
||||||
liftIO $ forM_ tempRootList $ \entry -> do
|
System.Directory.removeFile
|
||||||
System.Directory.removeFile
|
$ mconcat [ tempRootsDir, "/", entry ]
|
||||||
$ 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{..} <-
|
GCResult{..} <-
|
||||||
collectGarbage
|
collectGarbage
|
||||||
|
Loading…
Reference in New Issue
Block a user