@@ -94,13 +94,15 @@ data Arguments =
94
94
{ runRelease :: Bool
95
95
, runCompiler :: FilePath
96
96
, runFlags :: [String ]
97
+ , runRunner :: Maybe String
97
98
, runTarget :: Maybe String
98
99
, runArgs :: Maybe [String ]
99
100
}
100
101
| Test
101
102
{ testRelease :: Bool
102
103
, testCompiler :: FilePath
103
104
, testFlags :: [String ]
105
+ , testRunner :: Maybe String
104
106
, testTarget :: Maybe String
105
107
, testArgs :: Maybe [String ]
106
108
}
@@ -166,7 +168,7 @@ start args = case args of
166
168
app :: Arguments -> AppSettings -> IO ()
167
169
app args settings = case args of
168
170
Build {} -> build settings
169
- Run { runTarget = whichOne, runArgs = runArgs } -> do
171
+ Run { runTarget = whichOne, runArgs = runArgs, runRunner = runner } -> do
170
172
build settings
171
173
let buildPrefix = appSettingsBuildPrefix settings
172
174
let
@@ -180,78 +182,81 @@ app args settings = case args of
180
182
canonicalExecutables <- mapM makeAbsolute executables
181
183
case canonicalExecutables of
182
184
[] -> putStrLn " No Executables Found"
183
- _ -> case whichOne of
184
- Nothing -> do
185
- exitCodes <- mapM
186
- system
187
- (map
188
- (++ case runArgs of
189
- Nothing -> " "
190
- Just theArgs -> " " ++ (intercalate " " theArgs)
191
- )
192
- canonicalExecutables
193
- )
194
- forM_
195
- exitCodes
196
- (\ exitCode -> when
197
- (case exitCode of
198
- ExitSuccess -> False
199
- _ -> True
200
- )
201
- (exitWith exitCode)
202
- )
203
- Just name -> do
204
- case find (name `isSuffixOf` ) canonicalExecutables of
205
- Nothing -> putStrLn " Executable Not Found"
206
- Just specified -> do
207
- exitCode <- case runArgs of
208
- Nothing -> system specified
209
- Just theArgs ->
210
- system (specified ++ " " ++ (intercalate " " theArgs))
211
- exitWith exitCode
212
- Test { testTarget = whichOne, testArgs = testArgs } -> do
213
- build settings
214
- let buildPrefix = appSettingsBuildPrefix settings
215
- let
216
- executableNames = map
217
- (\ Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
218
- sourceDir </> name
219
- )
220
- (appSettingsTests settings)
221
- let executables =
222
- map (buildPrefix </> ) $ map (flip (<.>) exe) executableNames
223
- canonicalExecutables <- mapM makeAbsolute executables
224
- case canonicalExecutables of
225
- [] -> putStrLn " No Tests Found"
226
- _ -> case whichOne of
227
- Nothing -> do
228
- exitCodes <- mapM
229
- system
230
- (map
231
- (++ case testArgs of
232
- Nothing -> " "
233
- Just theArgs -> " " ++ (intercalate " " theArgs)
234
- )
235
- canonicalExecutables
236
- )
237
- forM_
238
- exitCodes
239
- (\ exitCode -> when
240
- (case exitCode of
241
- ExitSuccess -> False
242
- _ -> True
243
- )
244
- (exitWith exitCode)
245
- )
246
- Just name -> do
247
- case find (name `isSuffixOf` ) canonicalExecutables of
248
- Nothing -> putStrLn " Test Not Found"
249
- Just specified -> do
250
- exitCode <- case testArgs of
251
- Nothing -> system specified
252
- Just theArgs ->
253
- system (specified ++ " " ++ (intercalate " " theArgs))
254
- exitWith exitCode
185
+ _ ->
186
+ let commandPrefix = case runner of
187
+ Nothing -> " "
188
+ Just r -> r ++ " "
189
+ commandSufix = case runArgs of
190
+ Nothing -> " "
191
+ Just a -> " " ++ (intercalate " " a)
192
+ in case whichOne of
193
+ Nothing -> do
194
+ exitCodes <- mapM
195
+ system
196
+ (map (\ exe -> commandPrefix ++ exe ++ commandSufix)
197
+ canonicalExecutables
198
+ )
199
+ forM_
200
+ exitCodes
201
+ (\ exitCode -> when
202
+ (case exitCode of
203
+ ExitSuccess -> False
204
+ _ -> True
205
+ )
206
+ (exitWith exitCode)
207
+ )
208
+ Just name -> do
209
+ case find (name `isSuffixOf` ) canonicalExecutables of
210
+ Nothing -> putStrLn " Executable Not Found"
211
+ Just specified -> do
212
+ exitCode <- system
213
+ (commandPrefix ++ specified ++ commandSufix)
214
+ exitWith exitCode
215
+ Test { testTarget = whichOne, testArgs = testArgs, testRunner = runner } ->
216
+ do
217
+ build settings
218
+ let buildPrefix = appSettingsBuildPrefix settings
219
+ let
220
+ executableNames = map
221
+ (\ Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
222
+ sourceDir </> name
223
+ )
224
+ (appSettingsTests settings)
225
+ let executables =
226
+ map (buildPrefix </> ) $ map (flip (<.>) exe) executableNames
227
+ canonicalExecutables <- mapM makeAbsolute executables
228
+ case canonicalExecutables of
229
+ [] -> putStrLn " No Tests Found"
230
+ _ ->
231
+ let commandPrefix = case runner of
232
+ Nothing -> " "
233
+ Just r -> r ++ " "
234
+ commandSufix = case testArgs of
235
+ Nothing -> " "
236
+ Just a -> " " ++ (intercalate " " a)
237
+ in case whichOne of
238
+ Nothing -> do
239
+ exitCodes <- mapM
240
+ system
241
+ (map (\ exe -> commandPrefix ++ exe ++ commandSufix)
242
+ canonicalExecutables
243
+ )
244
+ forM_
245
+ exitCodes
246
+ (\ exitCode -> when
247
+ (case exitCode of
248
+ ExitSuccess -> False
249
+ _ -> True
250
+ )
251
+ (exitWith exitCode)
252
+ )
253
+ Just name -> do
254
+ case find (name `isSuffixOf` ) canonicalExecutables of
255
+ Nothing -> putStrLn " Test Not Found"
256
+ Just specified -> do
257
+ exitCode <- system
258
+ (commandPrefix ++ specified ++ commandSufix)
259
+ exitWith exitCode
255
260
_ -> putStrLn " Shouldn't be able to get here"
256
261
257
262
build :: AppSettings -> IO ()
@@ -420,6 +425,12 @@ runArguments =
420
425
" specify an addional argument to pass to the compiler (can appear multiple times)"
421
426
)
422
427
)
428
+ <*> optional
429
+ (strOption
430
+ (long " runner" <> metavar " RUNNER" <> help
431
+ " specify a command to be used to run the executable(s)"
432
+ )
433
+ )
423
434
<*> optional
424
435
(strOption
425
436
(long " target" <> metavar " TARGET" <> help
@@ -457,6 +468,12 @@ testArguments =
457
468
" specify an addional argument to pass to the compiler (can appear multiple times)"
458
469
)
459
470
)
471
+ <*> optional
472
+ (strOption
473
+ (long " runner" <> metavar " RUNNER" <> help
474
+ " specify a command to be used to run the test(s)"
475
+ )
476
+ )
460
477
<*> optional
461
478
(strOption
462
479
(long " target" <> metavar " TARGET" <> help " Name of the test to run"
0 commit comments