From bb386dd6f0127a92675312a8022cc7ac8aaa4cdc Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 13 Dec 2021 14:33:01 -0500 Subject: Factor out test function --- Biz/Bild.hs | 36 ++++++++++++++++++++++-------------- 1 file 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 -- cgit v1.2.3