on master help sign in
selftest: Lint and style changes
commit8f961deaaf8c768377a9dea3e12cecbb84ca984c authorElliot Cameron <eacameron@gmail.com> dateWed 18 Dec 2019, 14:10 (7 years ago) parentc7f02b3
1 file changed+11−16
lib/selftest/src/Obelisk/SelfTest.hs+11−16
lib/selftest/src/Obelisk/SelfTest.hs+11−16
@@ -3,7 +3,6 @@
33{-# LANGUAGE OverloadedStrings #-}
44{-# LANGUAGE PatternGuards #-}
55{-# LANGUAGE ScopedTypeVariables #-}
6−{-# LANGUAGE TypeApplications #-}
76module Obelisk.SelfTest where
87
98import Control.Exception (bracket, throw)
@@ -71,7 +70,7 @@ shellyOb f obTest = shelly $ f obTest
7170main :: IO ()
7271main = do
7372 -- Note: you can pass hspec arguments as well, eg: `-m <pattern>`
74− isVerbose <- (elem "-v") <$> getArgs
73+ isVerbose <- elem "-v" <$> getArgs
7574 unless isVerbose $
7675 putStrLn "Tests may take longer to run if there are unbuilt derivations: use -v for verbose output"
7776 let verbosity = bool silently verbosely isVerbose
@@ -118,7 +117,7 @@ main = do
118117 it "works with master branch impl" $ inTmp $ \_ -> run "ob" ["init", "--branch", "master"]
119118 it "works with symlink" $ inTmp $ \_ -> run "ob" ["init", "--symlink", obeliskImpl]
120119 it "doesn't silently overwrite existing files" $ withSystemTempDirectory "ob-init" $ \dir -> do
121− let p force = (proc "ob" $ "--no-handoff" : "init" : if force then ["--force"] else []) { cwd = Just dir }
120+ let p force = (proc "ob" $ "--no-handoff" : "init" : ["--force"|force]) { cwd = Just dir }
122121 (ExitSuccess, _, _) <- readCreateProcessWithExitCode (p False) ""
123122 (ExitFailure _, _, _) <- readCreateProcessWithExitCode (p False) ""
124123 (ExitSuccess, _, _) <- readCreateProcessWithExitCode (p True) ""
@@ -128,7 +127,7 @@ main = do
128127 void $ errExit False $ run "ob" ["init", "--symlink", "/dev/null"]
129128 ls tmp >>= liftIO . assertEqual "" []
130129
131− it "produces a valid route config" $ inTmpObInit $ \tmp -> liftIO $ do
130+ it "produces a valid route config" $ inTmpObInit $ \tmp -> liftIO $
132131 withCurrentDirectory (T.unpack $ toTextIgnore tmp) $ do
133132 configs <- getConfigs
134133 return (either (const Nothing) Just $ getConfigRoute configs) `shouldNotReturn` Nothing
@@ -136,10 +135,8 @@ main = do
136135 -- These tests fail with "Could not find module 'Obelisk.Generated.Static'"
137136 -- when not run by 'nix-build --attr selftest'
138137 describe "ob run" $ parallel $ do
139− it "works in root directory" $ inTmpObInit $ \_ -> do
140− testObRunInDir p0 p1 Nothing httpManager
141− it "works in sub directory" $ inTmpObInit $ \_ -> do
142− testObRunInDir p2 p3 (Just "frontend") httpManager
138+ it "works in root directory" $ inTmpObInit $ \_ -> testObRunInDir p0 p1 Nothing httpManager
139+ it "works in sub directory" $ inTmpObInit $ \_ -> testObRunInDir p2 p3 (Just "frontend") httpManager
143140
144141 describe "obelisk project" $ parallel $ do
145142 it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , obeliskImpl]
@@ -149,13 +146,11 @@ main = do
149146
150147 describe "blank initialized project" $ parallel $ do
151148
152− it "can build ghc.backend" $ inTmpObInit $ \_ -> do
153− nixBuild ["-A", "ghc.backend"]
154− it "can build ghcjs.frontend" $ inTmpObInit $ \_ -> do
155− nixBuild ["-A", "ghcjs.frontend"]
149+ it "can build ghc.backend" $ inTmpObInit $ \_ -> nixBuild ["-A", "ghc.backend"]
150+ it "can build ghcjs.frontend" $ inTmpObInit $ \_ -> nixBuild ["-A", "ghcjs.frontend"]
156151
157152 if os == "darwin"
158− then it "can build ios" $ inTmpObInit $ \_ -> nixBuild ["-A", "ios.frontend"]
153+ then it "can build ios" $ inTmpObInit $ \_ -> nixBuild ["-A", "ios.frontend"]
159154 else it "can build android" $ inTmpObInit $ \_ -> nixBuild ["-A", "android.frontend"]
160155
161156 forM_ ["ghc", "ghcjs"] $ \compiler -> do
@@ -191,7 +186,7 @@ main = do
191186 branch' <- chdir dir $ run "git" ["rev-parse", "--abbrev-ref", "HEAD"]
192187 liftIO $ assertEqual "" branch (T.strip branch')
193188
194− it "can pack and unpack plain git repos" $ do
189+ it "can pack and unpack plain git repos" $
195190 shelly_ $ withSystemTempDirectory "git-repo" $ \dir -> do
196191 let repo = toTextIgnore $ dir </> ("repo" :: String)
197192 run_ "git" ["clone", "https://github.com/haskell/process.git", repo]
@@ -210,7 +205,7 @@ main = do
210205 testThunkPack $ fromText repo
211206
212207 it "aborts thunk pack when there are uncommitted files" $ inTmpObInit $ \dir -> do
213− void $ unpack
208+ void unpack
214209 testThunkPack (dir </> thunk)
215210
216211 describe "ob thunk update --branch" $ parallel $ do
@@ -289,7 +284,7 @@ alterRouteTo uri stdout = do
289284
290285-- | Handle stdout of `ob run`: check that the frontend and backend servers are started correctly
291286handleObRunStdout :: HTTP.Manager -> Handle -> Sh Text
292−handleObRunStdout httpManager stdout = flip fix (ObRunState_Init, []) $ \loop (state, msgs) -> do
287+handleObRunStdout httpManager stdout = flip fix (ObRunState_Init, []) $ \loop (state, msgs) ->
293288 liftIO (T.hGetLine stdout) >>= \t -> case state of
294289 ObRunState_Init
295290 | "Running test..." `T.isPrefixOf` t -> loop (ObRunState_BackendStarted, msgs)