6import Control.Monad (foldM, unless, when)
7import qualified Data.Map as Map
8import qualified Data.Set as Set
12import System.Directory (createDirectory, removeFile, canonicalizePath)
13import System.Environment (getEnvironment)
14import System.Exit (ExitCode (ExitSuccess))
15import System.FilePath ((<.>), (</>))
16import System.IO (IOMode (WriteMode, AppendMode),
18import System.Process (runProcess, waitForProcess)
19import Distribution.Text
22runTestSuites :: InstallInfo -> IO ()
24 let testdir = "runtests"
26 createDirectory testdir
27 allPass <- foldM (runTestSuite testdir) True $ Map.toList $ iiPackages ii
28 unless allPass $ error $ "There were failures, please see the logs in " ++ testdir
30-- | Separate for the PATH environment variable
38fixEnv :: FilePath -> (String, String) -> (String, String)
39fixEnv bin (p@"PATH", x) = (p, bin ++ pathSep : x)
42runTestSuite :: FilePath -> Bool -> (PackageName, Version) -> IO Bool
43runTestSuite testdir prevPassed pair@(packageName, _) = do
44 -- Set up a new environment that includes the cabal-dev/bin folder in PATH.
45 env' <- getEnvironment
46 bin <- canonicalizePath "cabal-dev/bin"
47 let menv = Just $ map (fixEnv bin) env'
50 ph1 <- getHandle WriteMode $ \handle -> runProcess "cabal" ["unpack", package] (Just testdir) menv Nothing (Just handle) (Just handle)
51 ec1 <- waitForProcess ph1
52 if (ec1 /= ExitSuccess)
55 ph2 <- getHandle AppendMode $ \handle -> runProcess "cabal-dev" ["-s", "../../cabal-dev", "configure", "--enable-tests"] (Just dir) menv Nothing (Just handle) (Just handle)
56 ec2 <- waitForProcess ph2
57 if (ec2 /= ExitSuccess)
60 ph3 <- getHandle AppendMode $ \handle -> runProcess "cabal-dev" ["build"] (Just dir) menv Nothing (Just handle) (Just handle)
61 ec3 <- waitForProcess ph3
62 if (ec3 /= ExitSuccess)
65 ph4 <- getHandle AppendMode $ \handle -> runProcess "cabal-dev" ["test"] (Just dir) menv Nothing (Just handle) (Just handle)
66 ec4 <- waitForProcess ph4
67 if (ec4 /= ExitSuccess)
70 ph5 <- getHandle AppendMode $ \handle -> runProcess "cabal-dev" ["haddock"] (Just dir) menv Nothing (Just handle) (Just handle)
71 ec5 <- waitForProcess ph5
72 return $ ec5 == ExitSuccess
73 let expectedFailure = packageName `Set.member` expectedFailures
77 when expectedFailure $ putStrLn $ package ++ " passed, but I didn't think it would."
78 else unless expectedFailure $ putStrLn $ "Test suite failed: " ++ package
80 return $! prevPassed && (passed || expectedFailure)
82 logfile = testdir </> package <.> "log"
83 dir = testdir </> package
84 getHandle mode = withBinaryFile logfile mode
85 package = packageVersionString pair
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list