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