Skip to content

Commit cf51ba3

Browse files
committed
temp: add hnix-store-temporary-live-test
1 parent b8354d8 commit cf51ba3

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

hnix-store-remote/app/Main.hs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
import qualified Data.ByteString.Lazy as LBS
3+
import qualified Data.HashSet as HS
4+
import qualified System.Nix.GC as GC
5+
import System.Nix.Store.Remote
6+
import System.Nix.Store.Remote.Util
7+
import Data.Maybe
8+
import Control.Monad.Reader
9+
10+
import Text.Pretty.Simple
11+
12+
noSuchPath = fromJust $ mkPath "blah"
13+
14+
main = do
15+
x <- runStore $ do
16+
syncWithGC
17+
18+
verifyStore False False
19+
20+
(Just path) <- addTextToStore "hnix-store" "test" (HS.fromList []) False
21+
22+
valid <- isValidPathUncached path
23+
case valid of
24+
True -> do
25+
info <- queryPathInfoUncached path
26+
return (path, info)
27+
_ -> error "shouldn't happen"
28+
29+
pPrint x
30+
case x of
31+
(Left err, log) -> putStrLn err >> print log
32+
(Right (path, pathinfo), log) -> do
33+
gcres <- runStore $ do
34+
collectGarbage $ GC.Options
35+
{ GC.operation = GC.DeleteSpecific
36+
, GC.pathsToDelete = HS.fromList [path]
37+
, GC.ignoreLiveness = False
38+
-- XXX: this breaks stuff - we don't get Last,
39+
-- only a message with limit reached, stopping..
40+
--
41+
-- gcDeleteSpecific and options.maxFreed
42+
-- are two distinct branches in
43+
-- nix/src/libstore.gc
44+
-- so maybe this combination is not supported
45+
--, GC.maxFreed = 1000
46+
, GC.maxFreed = -1
47+
}
48+
49+
pPrint gcres
50+
51+
-- test ExceptT
52+
e <- runStore $ do
53+
isValidPathUncached $ noSuchPath
54+
55+
pPrint e
56+
57+
{-
58+
e <- runStore $ do
59+
queryPathInfoUncached $ noSuchPath
60+
61+
pPrint e
62+
-}
63+
64+
--res <- queryDerivationOutputs drvP
65+
--liftIO $ print res
66+
--res <- findRoots
67+
--liftIO $ pPrint res

hnix-store-remote/hnix-store-remote.cabal

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ library
3939
hs-source-dirs: src
4040
default-language: Haskell2010
4141
ghc-options: -Wall
42+
43+
executable hnix-store-temporary-live-test
44+
main-is: Main.hs
45+
hs-source-dirs: app
46+
build-depends: base
47+
, mtl
48+
, bytestring
49+
, hnix-store-core
50+
, hnix-store-remote
51+
, unordered-containers
52+
, pretty-simple

0 commit comments

Comments
 (0)