@@ -145,6 +145,7 @@ replPkg copts fp = do
145145 case mergeOptions copts (idris_opts pkgdesc) of
146146 Left emsg -> ifail emsg
147147 Right opts -> do
148+
148149 putIState orig
149150 dir <- runIO getCurrentDirectory
150151 runIO $ setCurrentDirectory $ dir </> sourcedir pkgdesc
@@ -237,42 +238,44 @@ documentPkg copts (install,fp) = do
237238-- | Build a package with a sythesized main function that runs the tests
238239testPkg :: [Opt] -- ^ Command line options.
239240 -> FilePath -- ^ Path to ipkg file.
240− -> IO ()
241+ -> IO ExitCode
241242testPkg copts fp = do
242243 pkgdesc <- parseDesc fp
243244 ok <- mapM (testLib True (pkgname pkgdesc)) (libdeps pkgdesc)
244− when (and ok) $ do
245− m_ist <- inPkgDir pkgdesc $ do
246− make (makefile pkgdesc)
247− -- Get a temporary file to save the tests' source in
248− (tmpn, tmph) <- tempfile ".idr"
249− hPutStrLn tmph $
250− "module Test_______\n" ++
251− concat ["import " ++ show m ++ "\n" | m <- modules pkgdesc]
252− ++ "namespace Main\n"
253− ++ " main : IO ()\n"
254− ++ " main = do "
255− ++ concat [ show t ++ "\n "
256− | t <- idris_tests pkgdesc]
257− hClose tmph
258− (tmpn', tmph') <- tempfile ""
259− hClose tmph'
260− let popts = (Filename tmpn : NoREPL : Verbose : Output tmpn' : idris_opts pkgdesc)
261− case mergeOptions copts popts of
262− Left emsg -> do
263− putStrLn emsg
264− exitWith (ExitFailure 1)
265− Right opts -> do
266− m_ist <- idris opts
267− rawSystem tmpn' []
268− return m_ist
269− case m_ist of
270− Nothing -> exitWith (ExitFailure 1)
271− Just ist -> do
272− -- Quit with error code if problem building
273− case errSpan ist of
274− Just _ -> exitWith (ExitFailure 1)
275− _ -> return ()
245+ if and ok
246+ then do
247+ (m_ist, exitCode) <- inPkgDir pkgdesc $ do
248+ make (makefile pkgdesc)
249+ -- Get a temporary file to save the tests' source in
250+ (tmpn, tmph) <- tempfile ".idr"
251+ hPutStrLn tmph $
252+ "module Test_______\n" ++
253+ concat ["import " ++ show m ++ "\n" | m <- modules pkgdesc]
254+ ++ "namespace Main\n"
255+ ++ " main : IO ()\n"
256+ ++ " main = do "
257+ ++ concat [ show t ++ "\n "
258+ | t <- idris_tests pkgdesc]
259+ hClose tmph
260+ (tmpn', tmph') <- tempfile ""
261+ hClose tmph'
262+ let popts = (Filename tmpn : NoREPL : Verbose : Output tmpn' : idris_opts pkgdesc)
263+ case mergeOptions copts popts of
264+ Left emsg -> do
265+ putStrLn emsg
266+ exitWith (ExitFailure 1)
267+ Right opts -> do
268+ m_ist <- idris opts
269+ exitCode <- rawSystem tmpn' []
270+ return (m_ist, exitCode)
271+ case m_ist of
272+ Nothing -> exitWith (ExitFailure 1)
273+ Just ist -> do
274+ -- Quit with error code if problem building
275+ case errSpan ist of
276+ Just _ -> exitWith (ExitFailure 1)
277+ _ -> return exitCode
278+ else return (ExitFailure 1)
276279
277280-- ----------------------------------------------------------- [ Installation ]
278281