aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/src/Fpm.hs
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-07-25 13:12:22 -0700
committerBrad Richardson <brichardson@structint.com>2020-07-25 13:12:22 -0700
commitffbb910909e5339c976d9713dbaab98bf20cc077 (patch)
tree3e316087ac20834168cd873e1fb7258643a7afb8 /bootstrap/src/Fpm.hs
parent66e46f578b209eee42b9420a12550a8de0ca3e10 (diff)
downloadfpm-ffbb910909e5339c976d9713dbaab98bf20cc077.tar.gz
fpm-ffbb910909e5339c976d9713dbaab98bf20cc077.zip
Propogate exit codes from tests and executables
Diffstat (limited to 'bootstrap/src/Fpm.hs')
-rw-r--r--bootstrap/src/Fpm.hs51
1 files changed, 39 insertions, 12 deletions
diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs
index 60f4aac..fdd83d9 100644
--- a/bootstrap/src/Fpm.hs
+++ b/bootstrap/src/Fpm.hs
@@ -14,6 +14,7 @@ import Build ( buildLibrary
, buildWithScript
)
import Control.Monad.Extra ( concatMapM
+ , forM_
, when
)
import Data.List ( isSuffixOf
@@ -55,6 +56,9 @@ import System.Directory ( createDirectory
, makeAbsolute
, withCurrentDirectory
)
+import System.Exit ( ExitCode(..)
+ , exitWith
+ )
import System.Process ( runCommand
, system
)
@@ -144,15 +148,25 @@ app args settings = case command' args of
case canonicalExecutables of
[] -> putStrLn "No Executables Found"
_ -> case whichOne of
- "" -> mapM_
- system
- (map (++ " " ++ commandArguments args) canonicalExecutables)
+ "" -> do
+ exitCodes <- mapM
+ system
+ (map (++ " " ++ commandArguments args) canonicalExecutables)
+ forM_
+ exitCodes
+ (\exitCode -> when
+ (case exitCode of
+ ExitSuccess -> False
+ _ -> True
+ )
+ (exitWith exitCode)
+ )
name -> do
case find (name `isSuffixOf`) canonicalExecutables of
Nothing -> putStrLn "Executable Not Found"
Just specified -> do
- system (specified ++ " " ++ (commandArguments args))
- return ()
+ exitCode <- system (specified ++ " " ++ (commandArguments args))
+ exitWith exitCode
Test whichOne -> do
build settings
let buildPrefix = appSettingsBuildPrefix settings
@@ -168,15 +182,25 @@ app args settings = case command' args of
case canonicalExecutables of
[] -> putStrLn "No Tests Found"
_ -> case whichOne of
- "" -> mapM_
- system
- (map (++ " " ++ commandArguments args) canonicalExecutables)
+ "" -> do
+ exitCodes <- mapM
+ system
+ (map (++ " " ++ commandArguments args) canonicalExecutables)
+ forM_
+ exitCodes
+ (\exitCode -> when
+ (case exitCode of
+ ExitSuccess -> False
+ _ -> True
+ )
+ (exitWith exitCode)
+ )
name -> do
case find (name `isSuffixOf`) canonicalExecutables of
Nothing -> putStrLn "Test Not Found"
Just specified -> do
- system (specified ++ " " ++ (commandArguments args))
- return ()
+ exitCode <- system (specified ++ " " ++ (commandArguments args))
+ exitWith exitCode
build :: AppSettings -> IO ()
build settings = do
@@ -285,8 +309,11 @@ arguments =
<> command "test" (info testArguments (progDesc "Run the tests"))
<> command "build"
(info buildArguments (progDesc "Build the executable"))
- <> command "new"
- (info newArguments (progDesc "Create a new project in a new directory"))
+ <> command
+ "new"
+ (info newArguments
+ (progDesc "Create a new project in a new directory")
+ )
)
<*> switch (long "release" <> help "Build in release mode")
<*> strOption