temp: add hnix-store-temporary-live-test

This commit is contained in:
Richard Marko 2018-07-17 11:15:21 +02:00
parent b8354d8b42
commit cf51ba3b39
2 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,67 @@
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy as LBS
import qualified Data.HashSet as HS
import qualified System.Nix.GC as GC
import System.Nix.Store.Remote
import System.Nix.Store.Remote.Util
import Data.Maybe
import Control.Monad.Reader
import Text.Pretty.Simple
noSuchPath = fromJust $ mkPath "blah"
main = do
x <- runStore $ do
syncWithGC
verifyStore False False
(Just path) <- addTextToStore "hnix-store" "test" (HS.fromList []) False
valid <- isValidPathUncached path
case valid of
True -> do
info <- queryPathInfoUncached path
return (path, info)
_ -> error "shouldn't happen"
pPrint x
case x of
(Left err, log) -> putStrLn err >> print log
(Right (path, pathinfo), log) -> do
gcres <- runStore $ do
collectGarbage $ GC.Options
{ GC.operation = GC.DeleteSpecific
, GC.pathsToDelete = HS.fromList [path]
, GC.ignoreLiveness = False
-- XXX: this breaks stuff - we don't get Last,
-- only a message with limit reached, stopping..
--
-- gcDeleteSpecific and options.maxFreed
-- are two distinct branches in
-- nix/src/libstore.gc
-- so maybe this combination is not supported
--, GC.maxFreed = 1000
, GC.maxFreed = -1
}
pPrint gcres
-- test ExceptT
e <- runStore $ do
isValidPathUncached $ noSuchPath
pPrint e
{-
e <- runStore $ do
queryPathInfoUncached $ noSuchPath
pPrint e
-}
--res <- queryDerivationOutputs drvP
--liftIO $ print res
--res <- findRoots
--liftIO $ pPrint res

View File

@ -39,3 +39,14 @@ library
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
executable hnix-store-temporary-live-test
main-is: Main.hs
hs-source-dirs: app
build-depends: base
, mtl
, bytestring
, hnix-store-core
, hnix-store-remote
, unordered-containers
, pretty-simple