GHC new build system megapatch
[ghc-hetmet.git] / utils / describe-unexpected / describe-unexpected.hs
1
2 module Main (main) where
3
4 import Data.List
5
6 main :: IO ()
7 main = do xs <- readFile "testlog"
8           let ls = lines xs
9               tests = breakTests ls
10               unexpectedTests = filter (any ("unexpected" `isInfixOf`)) tests
11           putStr $ unlines $ concat unexpectedTests
12
13 breakTests :: [String] -> [[String]]
14 breakTests xs = splitStarting ("=====> " `isPrefixOf`)
15                 -- Ignore lines telling us that we're running a .T file:
16               $ filter (not . ("====> Running " `isPrefixOf`)) xs
17
18 splitStarting :: (a -> Bool) -> [a] -> [[a]]
19 splitStarting f xs0 = case break f xs0 of
20                       (_, intro : xs) -> ss intro xs
21                       _ -> error "No data"
22     where ss intro xs = case break f xs of
23                         (this, intro' : rest) ->
24                             (intro : this) : ss intro' rest
25                         (this, []) -> [intro : this]