@@ -20,6 +20,7 @@ import System.IO (Handle)
2020import System.IO.Temp
2121import System.Timeout
2222import Test.Hspec
23+import Test.HUnit.Base
2324
2425data ObRunState
2526 = ObRunState_Init
@@ -36,8 +37,14 @@ main = do
3637 describe "blank initialized project" $ do
3738 let inProj :: Sh a -> IO ()
3839 inProj = void . shelly . silently . chdir (fromString blankProject)
40+ thunk = ".obelisk/impl"
41+
42+ -- See https://github.com/obsidiansystems/obelisk/pull/92#issuecomment-390226735
43+ hash = silently $ run "sh" ["-c", "cd " <> thunk <> " && find . | grep -v '^./.git' | grep -v '/.attr-cache' | grep -v '^.$' | xargs -n 1 -I % -- sh -c 'echo `nix-hash %` %'"]
44+
3945 it "can be created" $ inProj $ do
40− run "ob" ["init", "--symlink", T.pack obeliskImpl]
46+ run "ob" ["init"]
47+
4148 it "can build ghc.backend" $ inProj $ do
4249 run "nix-build" ["--no-out-link", "-A", "ghc.backend"]
4350 it "can build ghcjs.frontend" $ inProj $ do
@@ -50,6 +57,27 @@ main = do
5057 it ("can enter " <> shell) $ inProj $ inShell "exit"
5158 it ("can build in " <> shell) $ inProj $ inShell $ "cabal new-build --" <> fromString compiler <> " all"
5259
60+ it "has idempotent thunk update" $ inProj $ do
61+ let update = run "ob" ["thunk", "update", thunk] *> hash
62+ u <- update
63+ uu <- update
64+ liftIO $ assertEqual "" u uu
65+
66+ it "has thunk pack and unpack inverses" $ inProj $ do
67+ let pack = run "ob" ["thunk", "pack", thunk] *> hash
68+ unpack = run "ob" ["thunk", "unpack", thunk] *> hash
69+
70+ e <- hash
71+ eu <- unpack
72+ eup <- pack
73+ eupu <- unpack
74+ _ <- pack
75+
76+ liftIO $ do
77+ assertEqual "" e eup
78+ assertEqual "" eu eupu
79+ assertBool "" (e /= eu)
80+
5381 it "can use ob run" $ inProj $ handle_sh (\case ExitSuccess -> pure (); e -> throw e) $ do
5482 runHandle "ob" ["run"] $ \stdout -> do
5583 (_, firstUri) <- obRun httpManager stdout