@@ -88,13 +88,15 @@ data Arguments =
88
88
{ runRelease :: Bool
89
89
, runCompiler :: FilePath
90
90
, runFlags :: [String ]
91
+ , runRunner :: Maybe String
91
92
, runTarget :: Maybe String
92
93
, runArgs :: Maybe String
93
94
}
94
95
| Test
95
96
{ testRelease :: Bool
96
97
, testCompiler :: FilePath
97
98
, testFlags :: [String ]
99
+ , testRunner :: Maybe String
98
100
, testTarget :: Maybe String
99
101
, testArgs :: Maybe String
100
102
}
@@ -161,7 +163,7 @@ start args = case args of
161
163
app :: Arguments -> AppSettings -> IO ()
162
164
app args settings = case args of
163
165
Build {} -> build settings
164
- Run { runTarget = whichOne, runArgs = runArgs } -> do
166
+ Run { runTarget = whichOne, runArgs = runArgs, runRunner = runner } -> do
165
167
build settings
166
168
let buildPrefix = appSettingsBuildPrefix settings
167
169
let
@@ -175,76 +177,81 @@ app args settings = case args of
175
177
canonicalExecutables <- mapM makeAbsolute executables
176
178
case canonicalExecutables of
177
179
[] -> putStrLn " No Executables Found"
178
- _ -> case whichOne of
179
- Nothing -> do
180
- exitCodes <- mapM
181
- system
182
- (map
183
- (++ case runArgs of
184
- Nothing -> " "
185
- Just theArgs -> " " ++ theArgs
186
- )
187
- canonicalExecutables
188
- )
189
- forM_
190
- exitCodes
191
- (\ exitCode -> when
192
- (case exitCode of
193
- ExitSuccess -> False
194
- _ -> True
195
- )
196
- (exitWith exitCode)
197
- )
198
- Just name -> do
199
- case find (name `isSuffixOf` ) canonicalExecutables of
200
- Nothing -> putStrLn " Executable Not Found"
201
- Just specified -> do
202
- exitCode <- case runArgs of
203
- Nothing -> system specified
204
- Just theArgs -> system (specified ++ " " ++ theArgs)
205
- exitWith exitCode
206
- Test { testTarget = whichOne, testArgs = testArgs } -> do
207
- build settings
208
- let buildPrefix = appSettingsBuildPrefix settings
209
- let
210
- executableNames = map
211
- (\ Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
212
- sourceDir </> name
213
- )
214
- (appSettingsTests settings)
215
- let executables =
216
- map (buildPrefix </> ) $ map (flip (<.>) exe) executableNames
217
- canonicalExecutables <- mapM makeAbsolute executables
218
- case canonicalExecutables of
219
- [] -> putStrLn " No Tests Found"
220
- _ -> case whichOne of
221
- Nothing -> do
222
- exitCodes <- mapM
223
- system
224
- (map
225
- (++ case testArgs of
226
- Nothing -> " "
227
- Just theArgs -> " " ++ theArgs
228
- )
229
- canonicalExecutables
230
- )
231
- forM_
232
- exitCodes
233
- (\ exitCode -> when
234
- (case exitCode of
235
- ExitSuccess -> False
236
- _ -> True
237
- )
238
- (exitWith exitCode)
239
- )
240
- Just name -> do
241
- case find (name `isSuffixOf` ) canonicalExecutables of
242
- Nothing -> putStrLn " Test Not Found"
243
- Just specified -> do
244
- exitCode <- case testArgs of
245
- Nothing -> system specified
246
- Just theArgs -> system (specified ++ " " ++ theArgs)
247
- exitWith exitCode
180
+ _ ->
181
+ let commandPrefix = case runner of
182
+ Nothing -> " "
183
+ Just r -> r ++ " "
184
+ commandSufix = case runArgs of
185
+ Nothing -> " "
186
+ Just a -> " " ++ a
187
+ in case whichOne of
188
+ Nothing -> do
189
+ exitCodes <- mapM
190
+ system
191
+ (map (\ exe -> commandPrefix ++ exe ++ commandSufix)
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 <- system
208
+ (commandPrefix ++ specified ++ commandSufix)
209
+ exitWith exitCode
210
+ Test { testTarget = whichOne, testArgs = testArgs, testRunner = runner } ->
211
+ do
212
+ build settings
213
+ let buildPrefix = appSettingsBuildPrefix settings
214
+ let
215
+ executableNames = map
216
+ (\ Executable { executableSourceDir = sourceDir, executableMainFile = mainFile, executableName = name } ->
217
+ sourceDir </> name
218
+ )
219
+ (appSettingsTests settings)
220
+ let executables =
221
+ map (buildPrefix </> ) $ map (flip (<.>) exe) executableNames
222
+ canonicalExecutables <- mapM makeAbsolute executables
223
+ case canonicalExecutables of
224
+ [] -> putStrLn " No Tests Found"
225
+ _ ->
226
+ let commandPrefix = case runner of
227
+ Nothing -> " "
228
+ Just r -> r ++ " "
229
+ commandSufix = case testArgs of
230
+ Nothing -> " "
231
+ Just a -> " " ++ a
232
+ in case whichOne of
233
+ Nothing -> do
234
+ exitCodes <- mapM
235
+ system
236
+ (map (\ exe -> commandPrefix ++ exe ++ commandSufix)
237
+ canonicalExecutables
238
+ )
239
+ forM_
240
+ exitCodes
241
+ (\ exitCode -> when
242
+ (case exitCode of
243
+ ExitSuccess -> False
244
+ _ -> True
245
+ )
246
+ (exitWith exitCode)
247
+ )
248
+ Just name -> do
249
+ case find (name `isSuffixOf` ) canonicalExecutables of
250
+ Nothing -> putStrLn " Test Not Found"
251
+ Just specified -> do
252
+ exitCode <- system
253
+ (commandPrefix ++ specified ++ commandSufix)
254
+ exitWith exitCode
248
255
_ -> putStrLn " Shouldn't be able to get here"
249
256
250
257
build :: AppSettings -> IO ()
@@ -419,6 +426,12 @@ runArguments =
419
426
" specify an addional argument to pass to the compiler (can appear multiple times)"
420
427
)
421
428
)
429
+ <*> optional
430
+ (strOption
431
+ (long " runner" <> metavar " RUNNER" <> help
432
+ " specify a command to be used to run the executable(s)"
433
+ )
434
+ )
422
435
<*> optional
423
436
(strArgument
424
437
(metavar " TARGET" <> help " Name of the executable to run" )
@@ -448,6 +461,12 @@ testArguments =
448
461
" specify an addional argument to pass to the compiler (can appear multiple times)"
449
462
)
450
463
)
464
+ <*> optional
465
+ (strOption
466
+ (long " runner" <> metavar " RUNNER" <> help
467
+ " specify a command to be used to run the test(s)"
468
+ )
469
+ )
451
470
<*> optional
452
471
(strArgument (metavar " TARGET" <> help " Name of the test to run" ))
453
472
<*> optional (strArgument (metavar " ARGS" <> help " Arguments to the test" ))
0 commit comments