@@ -40,9 +40,32 @@ main = do
4040 withSystemTempDirectory "blank-project" $ \blankProject ->
4141 hspec $ do
4242 let shelly_ = void . shelly . silently
43+
44+ inProj :: Sh a -> IO ()
45+ inProj = shelly_ . chdir (fromString blankProject)
46+
4347 inTmp :: (Shelly.FilePath -> Sh a) -> IO ()
4448 inTmp f = shelly_ . withSystemTempDirectory "ob-init" $ (chdir <*> f) . fromString
4549
50+ assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
51+ assertRevNE a b = liftIO . assertBool "" . (/= "") =<< diff a b
52+
53+ doubleQuotes s = "\"" <> s <> "\""
54+
55+ revParseHead = T.strip <$> run "git" ["rev-parse", "HEAD"]
56+
57+ commitAll = do
58+ run "git" ["add", "."]
59+ run "git" ["commit", "--allow-empty", "-m", doubleQuotes "checkpoint"]
60+ revParseHead
61+
62+ thunk = ".obelisk/impl"
63+ update = run "ob" ["thunk", "update", thunk] >> commitAll
64+ pack = run "ob" ["thunk", "pack", thunk] >> commitAll
65+ unpack = run "ob" ["thunk", "unpack", thunk] >> commitAll
66+
67+ diff a b = run "git" ["diff", a, b]
68+
4669 describe "ob init" $ do
4770 it "works with default impl" $ inTmp $ \_ -> run "ob" ["init"]
4871 it "works with master branch impl" $ inTmp $ \_ -> run "ob" ["init", "--branch", "master"]
@@ -67,21 +90,6 @@ main = do
6790 it "can build everything" $ shelly_ $ run "nix-build" [obeliskImpl]
6891
6992 describe "blank initialized project" $ do
70− let inProj :: Sh a -> IO ()
71− inProj = shelly_ . chdir (fromString blankProject)
72− thunk = ".obelisk/impl"
73−
74− doubleQuotes s = "\"" <> s <> "\""
75− revParseHead = T.strip <$> run "git" ["rev-parse", "HEAD"]
76− commitAll = do
77− run "git" ["add", "."]
78− run "git" ["commit", "--allow-empty", "-m", doubleQuotes "checkpoint"]
79− revParseHead
80−
81− diff a b = run "git" ["diff", a, b]
82− assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
83− assertRevNE a b = liftIO . assertBool "" . (/= "") =<< diff a b
84−
8593 it "can be created" $ inProj $ do
8694 run "ob" ["init"]
8795 run "git" ["init"]
@@ -107,15 +115,11 @@ main = do
107115 run "nix-build" []
108116
109117 it "has idempotent thunk update" $ inProj $ do
110− let update = run "ob" ["thunk", "update", thunk] >> commitAll
111118 u <- update
112119 uu <- update
113120 assertRevEQ u uu
114121
115122 describe "ob thunk pack/unpack" $ do
116− let pack = run "ob" ["thunk", "pack", thunk] >> commitAll
117− unpack = run "ob" ["thunk", "unpack", thunk] >> commitAll
118−
119123 it "has thunk pack and unpack inverses" $ inProj $ do
120124 e <- commitAll
121125 eu <- unpack