summaryrefslogtreecommitdiff
path: root/Omni/Bild.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-12-01 21:46:29 -0500
committerBen Sima <ben@bsima.me>2024-12-21 10:08:01 -0500
commitaafa73c47325185ed733da387c9649d934f6529c (patch)
treebc2e180afa7151b736a02a37701b731baf9ce795 /Omni/Bild.hs
parent2ed757bc8c60fad0f2bf9d07478e2a287b7e24aa (diff)
Test Python code with bild --test
I had forgotten to add this feature, apparently, so bild --test just didn't do the test part.
Diffstat (limited to 'Omni/Bild.hs')
-rw-r--r--Omni/Bild.hs44
1 files changed, 28 insertions, 16 deletions
diff --git a/Omni/Bild.hs b/Omni/Bild.hs
index 60253c0..e6c9152 100644
--- a/Omni/Bild.hs
+++ b/Omni/Bild.hs
@@ -882,22 +882,33 @@ isSuccess Exit.ExitSuccess = True
isSuccess _ = False
test :: Bool -> Target -> IO (Exit.ExitCode, ByteString)
-test loud Target {..} = case compiler of
- Ghc -> do
- root <- Env.getEnv "CODEROOT"
- run
- <| Proc
- { loud = loud,
- cmd = root </> outToPath out,
- args = ["test"],
- ns = namespace,
- onFailure = Log.fail ["test", nschunk namespace] >> Log.br,
- onSuccess = Log.pass ["test", nschunk namespace] >> Log.br
- }
- _ ->
- Log.warn ["test", nschunk namespace, "unavailable"]
- >> Log.br
- >> pure (Exit.ExitFailure 1, mempty)
+test loud Target {..} =
+ Env.getEnv "CODEROOT"
+ +> \root -> case compiler of
+ Ghc ->
+ Proc
+ { loud = loud,
+ cmd = root </> outToPath out,
+ args = ["test"],
+ ns = namespace,
+ onFailure = Log.fail ["test", nschunk namespace] >> Log.br,
+ onSuccess = Log.pass ["test", nschunk namespace] >> Log.br
+ }
+ |> run
+ CPython ->
+ Proc
+ { loud = loud,
+ cmd = root </> outToPath out,
+ args = ["test"],
+ ns = namespace,
+ onFailure = Log.fail ["test", nschunk namespace] >> Log.br,
+ onSuccess = Log.pass ["test", nschunk namespace] >> Log.br
+ }
+ |> run
+ _ ->
+ Log.warn ["test", nschunk namespace, "unavailable"]
+ >> Log.br
+ >> pure (Exit.ExitFailure 1, mempty)
build :: Bool -> Bool -> Int -> Int -> Analysis -> IO [Exit.ExitCode]
build andTest loud jobs cpus analysis =
@@ -908,6 +919,7 @@ build andTest loud jobs cpus analysis =
Meta.Bin _ ->
Log.info ["bild", "nix", "python", nschunk namespace]
>> nixBuild loud jobs cpus target
+ +> (\r -> (isSuccess (fst r) && andTest) ?: (test loud target, pure r))
_ ->
Log.info ["bild", "nix", "python", nschunk namespace, "cannot build library"]
>> pure (Exit.ExitSuccess, mempty)