aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/src/Fpm.hs161
-rw-r--r--bootstrap/test/Spec.hs5
2 files changed, 95 insertions, 71 deletions
diff --git a/bootstrap/src/Fpm.hs b/bootstrap/src/Fpm.hs
index cfb67df..64b8fac 100644
--- a/bootstrap/src/Fpm.hs
+++ b/bootstrap/src/Fpm.hs
@@ -88,6 +88,7 @@ data Arguments =
{ runRelease :: Bool
, runCompiler :: FilePath
, runFlags :: [String]
+ , runRunner :: Maybe String
, runTarget :: Maybe String
, runArgs :: Maybe String
}
@@ -95,6 +96,7 @@ data Arguments =
{ testRelease :: Bool
, testCompiler :: FilePath
, testFlags :: [String]
+ , testRunner :: Maybe String
, testTarget :: Maybe String
, testArgs :: Maybe String
}
@@ -161,7 +163,7 @@ start args = case args of
app :: Arguments -> AppSettings -> IO ()
app args settings = case args of
Build{} -> build settings
- Run { runTarget = whichOne, runArgs = runArgs } -> do
+ Run { runTarget = whichOne, runArgs = runArgs, runRunner = runner } -> do
build settings
let buildPrefix = appSettingsBuildPrefix settings
let
@@ -175,76 +177,81 @@ app args settings = case args of
canonicalExecutables <- mapM makeAbsolute executables
case canonicalExecutables of
[] -> putStrLn "No Executables Found"
- _ -> case whichOne of
- Nothing -> do
- exitCodes <- mapM
- system
- (map
- (++ case runArgs of
- Nothing -> ""
- Just theArgs -> " " ++ theArgs
- )
- canonicalExecutables
- )
- forM_
- exitCodes
- (\exitCode -> when
- (case exitCode of
- ExitSuccess -> False
- _ -> True
- )
- (exitWith exitCode)
- )
- Just name -> do
- case find (name `isSuffixOf`) canonicalExecutables of
- Nothing -> putStrLn "Executable Not Found"
- Just specified -> do
- exitCode <- case runArgs of
- Nothing -> system specified
- Just theArgs -> system (specified ++ " " ++ theArgs)
- exitWith exitCode
- Test { testTarget = whichOne, testArgs = testArgs } -> do
- build settings
- let buildPrefix = appSettingsBuildPrefix settings
- let
- executableNames = map
- (\Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
- sourceDir </> name
- )
- (appSettingsTests settings)
- let executables =
- map (buildPrefix </>) $ map (flip (<.>) exe) executableNames
- canonicalExecutables <- mapM makeAbsolute executables
- case canonicalExecutables of
- [] -> putStrLn "No Tests Found"
- _ -> case whichOne of
- Nothing -> do
- exitCodes <- mapM
- system
- (map
- (++ case testArgs of
- Nothing -> ""
- Just theArgs -> " " ++ theArgs
- )
- canonicalExecutables
- )
- forM_
- exitCodes
- (\exitCode -> when
- (case exitCode of
- ExitSuccess -> False
- _ -> True
- )
- (exitWith exitCode)
- )
- Just name -> do
- case find (name `isSuffixOf`) canonicalExecutables of
- Nothing -> putStrLn "Test Not Found"
- Just specified -> do
- exitCode <- case testArgs of
- Nothing -> system specified
- Just theArgs -> system (specified ++ " " ++ theArgs)
- exitWith exitCode
+ _ ->
+ let commandPrefix = case runner of
+ Nothing -> ""
+ Just r -> r ++ " "
+ commandSufix = case runArgs of
+ Nothing -> ""
+ Just a -> " " ++ a
+ in case whichOne of
+ Nothing -> do
+ exitCodes <- mapM
+ system
+ (map (\exe -> commandPrefix ++ exe ++ commandSufix)
+ canonicalExecutables
+ )
+ forM_
+ exitCodes
+ (\exitCode -> when
+ (case exitCode of
+ ExitSuccess -> False
+ _ -> True
+ )
+ (exitWith exitCode)
+ )
+ Just name -> do
+ case find (name `isSuffixOf`) canonicalExecutables of
+ Nothing -> putStrLn "Executable Not Found"
+ Just specified -> do
+ exitCode <- system
+ (commandPrefix ++ specified ++ commandSufix)
+ exitWith exitCode
+ Test { testTarget = whichOne, testArgs = testArgs, testRunner = runner } ->
+ do
+ build settings
+ let buildPrefix = appSettingsBuildPrefix settings
+ let
+ executableNames = map
+ (\Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
+ sourceDir </> name
+ )
+ (appSettingsTests settings)
+ let executables =
+ map (buildPrefix </>) $ map (flip (<.>) exe) executableNames
+ canonicalExecutables <- mapM makeAbsolute executables
+ case canonicalExecutables of
+ [] -> putStrLn "No Tests Found"
+ _ ->
+ let commandPrefix = case runner of
+ Nothing -> ""
+ Just r -> r ++ " "
+ commandSufix = case testArgs of
+ Nothing -> ""
+ Just a -> " " ++ a
+ in case whichOne of
+ Nothing -> do
+ exitCodes <- mapM
+ system
+ (map (\exe -> commandPrefix ++ exe ++ commandSufix)
+ canonicalExecutables
+ )
+ forM_
+ exitCodes
+ (\exitCode -> when
+ (case exitCode of
+ ExitSuccess -> False
+ _ -> True
+ )
+ (exitWith exitCode)
+ )
+ Just name -> do
+ case find (name `isSuffixOf`) canonicalExecutables of
+ Nothing -> putStrLn "Test Not Found"
+ Just specified -> do
+ exitCode <- system
+ (commandPrefix ++ specified ++ commandSufix)
+ exitWith exitCode
_ -> putStrLn "Shouldn't be able to get here"
build :: AppSettings -> IO ()
@@ -420,6 +427,12 @@ runArguments =
)
)
<*> optional
+ (strOption
+ (long "runner" <> metavar "RUNNER" <> help
+ "specify a command to be used to run the executable(s)"
+ )
+ )
+ <*> optional
(strArgument
(metavar "TARGET" <> help "Name of the executable to run")
)
@@ -449,6 +462,12 @@ testArguments =
)
)
<*> optional
+ (strOption
+ (long "runner" <> metavar "RUNNER" <> help
+ "specify a command to be used to run the test(s)"
+ )
+ )
+ <*> optional
(strArgument (metavar "TARGET" <> help "Name of the test to run"))
<*> optional (strArgument (metavar "ARGS" <> help "Arguments to the test"))
diff --git a/bootstrap/test/Spec.hs b/bootstrap/test/Spec.hs
index dfa73df..215024d 100644
--- a/bootstrap/test/Spec.hs
+++ b/bootstrap/test/Spec.hs
@@ -22,6 +22,7 @@ testHelloWorld =
{ runRelease = False
, runCompiler = "gfortran"
, runFlags = []
+ , runRunner = Nothing
, runTarget = Nothing
, runArgs = Nothing
}
@@ -32,6 +33,7 @@ testHelloComplex =
{ testRelease = False
, testCompiler = "gfortran"
, testFlags = []
+ , testRunner = Nothing
, testTarget = Nothing
, testArgs = Nothing
}
@@ -42,6 +44,7 @@ testHelloFpm =
{ runRelease = False
, runCompiler = "gfortran"
, runFlags = []
+ , runRunner = Nothing
, runTarget = Nothing
, runArgs = Nothing
}
@@ -52,6 +55,7 @@ testCircular =
{ testRelease = False
, testCompiler = "gfortran"
, testFlags = []
+ , testRunner = Nothing
, testTarget = Nothing
, testArgs = Nothing
}
@@ -70,6 +74,7 @@ testMakefileComplex =
{ runRelease = False
, runCompiler = "gfortran"
, runFlags = []
+ , runRunner = Nothing
, runTarget = Nothing
, runArgs = Nothing
}