on master help sign in
Never sign commits
e934362Alexandre Esteves
lib/selftest/src/Obelisk/SelfTest.hs+15−5
@@ -9,7 +9,7 @@ import Control.Monad.IO.Class
9import Data.Bool (bool)
9import Data.Bool (bool)
10import Data.Function (fix)
10import Data.Function (fix)
11import Data.Maybe (isJust)
11import Data.Maybe (isJust)
12−import Data.Semigroup ((<>))
12+import Data.Semigroup (Semigroup, (<>))
13import qualified Data.Set as Set
13import qualified Data.Set as Set
14import Data.String
14import Data.String
15import Data.Text (Text)
15import Data.Text (Text)
@@ -38,6 +38,18 @@ data ObRunState
38 | ObRunState_BackendStarted Text -- Port of backend
38 | ObRunState_BackendStarted Text -- Port of backend
39 deriving (Eq, Show)
39 deriving (Eq, Show)
40
40
41+doubleQuotes :: (IsString a, Semigroup a) => a -> a
42+doubleQuotes s = "\"" <> s <> "\""
43+
44+commit :: Text -> Sh ()
45+commit msg = void $ run "git"
46+ [ "commit"
47+ , "--no-gpg-sign"
48+ , "--allow-empty"
49+ , "-m"
50+ , doubleQuotes msg
51+ ]
52+
41main :: IO ()
53main :: IO ()
42main = do
54main = do
43 isVerbose <- getArgs >>= \case
55 isVerbose <- getArgs >>= \case
@@ -60,13 +72,11 @@ main = do
60 assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
72 assertRevEQ a b = liftIO . assertEqual "" "" =<< diff a b
61 assertRevNE a b = liftIO . assertBool "" . (/= "") =<< diff a b
73 assertRevNE a b = liftIO . assertBool "" . (/= "") =<< diff a b
62
74
63− doubleQuotes s = "\"" <> s <> "\""
64−
65 revParseHead = T.strip <$> run "git" ["rev-parse", "HEAD"]
75 revParseHead = T.strip <$> run "git" ["rev-parse", "HEAD"]
66
76
67 commitAll = do
77 commitAll = do
68 run "git" ["add", "."]
78 run "git" ["add", "."]
69− run "git" ["commit", "--allow-empty", "-m", doubleQuotes "checkpoint"]
79+ commit "checkpoint"
70 revParseHead
80 revParseHead
71
81
72 thunk = ".obelisk/impl"
82 thunk = ".obelisk/impl"
@@ -200,7 +210,7 @@ testThunkPack path = withTempFile (T.unpack $ toTextIgnore path) "test-file" $ \
200 git ["add", T.pack file]
210 git ["add", T.pack file]
201 -- Uncommitted files (staged)
211 -- Uncommitted files (staged)
202 ensureThunkPackFails "unsaved modifications"
212 ensureThunkPackFails "unsaved modifications"
203− git ["commit", "-m", "test commit"]
213+ chdir path $ commit "test commit"
204 -- Non-pushed commits in any branch
214 -- Non-pushed commits in any branch
205 ensureThunkPackFails "not been pushed"
215 ensureThunkPackFails "not been pushed"
206 -- Uncommitted files (unstaged)
216 -- Uncommitted files (unstaged)