mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
temp: add hnix-store-temporary-live-test
This commit is contained in:
parent
b8354d8b42
commit
cf51ba3b39
67
hnix-store-remote/app/Main.hs
Normal file
67
hnix-store-remote/app/Main.hs
Normal 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user