@@ -6,6 +6,7 @@ module Obelisk.SelfTest where
66import Control.Exception (Exception, throw, bracket)
77import Control.Monad
88import Control.Monad.IO.Class
9+import Data.Bool (bool)
910import Data.Function (fix)
1011import Data.Semigroup ((<>))
1112import qualified Data.Set as Set
@@ -18,7 +19,7 @@ import qualified Network.HTTP.Types as HTTP
1819import qualified Network.Socket as Socket
1920import Shelly
2021import System.Environment
21−import System.Exit (ExitCode (..))
22+import System.Exit (ExitCode (..), exitWith)
2223import System.Info
2324import System.IO (Handle, hClose)
2425import System.IO.Temp
@@ -35,11 +36,16 @@ data ObRunState
3536
3637main :: IO ()
3738main = do
39+ isVerbose <- getArgs >>= \case
40+ ["-v"] -> pure True
41+ [] -> putStrLn "Tests may take longer to run if there are unbuilt derivations: use -v for verbose output" *> pure False
42+ _ -> putStrLn "Usage: selftest [-v]" *> exitWith (ExitFailure 2)
43+ let verbosity = bool silently verbosely isVerbose
3844 obeliskImpl <- fromString <$> getEnv "OBELISK_IMPL"
3945 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
4046 withSystemTempDirectory "blank-project" $ \blankProject ->
4147 hspec $ do
42− let shelly_ = void . shelly . silently
48+ let shelly_ = void . shelly . verbosity
4349
4450 inProj :: Sh a -> IO ()
4551 inProj = shelly_ . chdir (fromString blankProject)
@@ -132,7 +138,7 @@ main = do
132138 assertRevNE e eu
133139
134140 it "can pack and unpack plain git repos" $ do
135− withSystemTempDirectory "git-repo" $ \dir -> shelly @IO $ silently $ do
141+ withSystemTempDirectory "git-repo" $ \dir -> shelly_ $ do
136142 let repo = toTextIgnore $ dir </> ("repo" :: String)
137143 run_ "git" ["clone", "https://git.haskell.org/packages/primitive.git", repo]
138144 origHash <- chdir (fromText repo) revParseHead