diff options
author | Ben Sima <ben@bsima.me> | 2021-12-13 14:33:01 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-12-13 14:33:01 -0500 |
commit | bb386dd6f0127a92675312a8022cc7ac8aaa4cdc (patch) | |
tree | e85ff6853de098b2a143e9e6b5fb2821325fe368 | |
parent | 7868cc248e01a36827338d8fca6b57f8999a1ba1 (diff) |
Factor out test function
-rw-r--r-- | Biz/Bild.hs | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 2eaf840..007bda8 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -150,9 +150,9 @@ import qualified System.Process as Process import qualified Text.Regex.Applicative as Regex main :: IO () -main = Cli.main <| Cli.Plan help move test pure +main = Cli.main <| Cli.Plan help move test_ pure where - test = + test_ = Test.group "Biz.Bild" [ Test.unit "can bild bild" <| do @@ -450,8 +450,25 @@ isSuccess :: Exit.ExitCode -> Bool isSuccess Exit.ExitSuccess = True isSuccess _ = False +test :: Bool -> Target -> IO Exit.ExitCode +test loud Target {..} = case compiler of + GhcExe -> do + root <- Env.getEnv "BIZ_ROOT" + run + <| Proc + { loud = loud, + cmd = root </> bindir </> Maybe.fromJust out, + args = ["test"], + ns = namespace, + onFailure = Log.fail ["test", nschunk namespace] >> Log.br, + onSuccess = Log.pass ["test", nschunk namespace] >> Log.br + } + _ -> do + Log.warn ["test", nschunk namespace, "unavailable"] >> Log.br + pure Exit.ExitSuccess + build :: Bool -> Bool -> Target -> IO Exit.ExitCode -build andTest loud Target {..} = do +build andTest loud target@Target {..} = do root <- Env.getEnv "BIZ_ROOT" case compiler of GhcExe -> do @@ -475,16 +492,7 @@ build andTest loud Target {..} = do root </> bindir </> Maybe.fromJust out ] if andTest && isSuccess exitcode - then - run - <| Proc - { loud = loud, - cmd = root </> bindir </> Maybe.fromJust out, - args = ["test"], - ns = namespace, - onFailure = Log.fail ["test", nschunk namespace] >> Log.br, - onSuccess = Log.pass ["test", nschunk namespace] >> Log.br - } + then test loud target else pure exitcode GhcLib -> do Log.info ["bild", "dev", "ghc-lib", nschunk namespace] @@ -582,7 +590,7 @@ build andTest loud Target {..} = do namespace "nix-build" [ path, - "-o", + "--out-link", root </> nixdir </> Namespace.toPath namespace, "--builders", Text.unpack builder |