Skip to content

Commit

Permalink
qualify test program output
Browse files Browse the repository at this point in the history
now it is easier to parse from output which test program has failed
when running tests in parallel with `make test -j7`
  • Loading branch information
rudymatela committed Jan 23, 2024
1 parent db3e5f8 commit 3012f3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ TO DO list for Express

* Improve pretty-printing (see TODO items in `test/show.hs`)

* replaced `Tests passed!` with `program: tests passed` as in Conjure

* use `enumFromTo` in `u-conjure.hs`?

* Release new version
Expand Down
15 changes: 8 additions & 7 deletions test/Test.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- |
-- Module : Test
-- Copyright : (c) 2019-2021 Rudy Matela
-- Copyright : (c) 2019-2024 Rudy Matela
-- License : 3-Clause BSD (see the file LICENSE)
-- Maintainer : Rudy Matela <[email protected]>
--
Expand Down Expand Up @@ -33,7 +33,7 @@ module Test
)
where

import System.Environment (getArgs)
import System.Environment (getArgs, getProgName)
import System.Exit (exitFailure)
import Data.List (elemIndices)
import Data.Typeable (TypeRep, typeOf)
Expand All @@ -49,11 +49,11 @@ import Data.Express.Fixtures
import Data.Express.Utils.List
import Data.Express.Utils.Typeable

reportTests :: [Bool] -> IO ()
reportTests tests =
reportTests :: String -> [Bool] -> IO ()
reportTests s tests =
case elemIndices False tests of
[] -> putStrLn "+++ Tests passed!"
is -> do putStrLn ("*** Failed tests:" ++ show is)
[] -> putStrLn $ s ++ ": tests passed"
is -> do putStrLn (s ++ ": failed tests:" ++ show is)
exitFailure

getMaxTestsFromArgs :: Int -> IO Int
Expand All @@ -65,8 +65,9 @@ getMaxTestsFromArgs n = do

mainTest :: (Int -> [Bool]) -> Int -> IO ()
mainTest tests n' = do
pn <- getProgName
n <- getMaxTestsFromArgs n'
reportTests (tests n)
reportTests pn (tests n)

tyBool :: TypeRep
tyBool = typeOf (undefined :: Bool)
Expand Down

0 comments on commit 3012f3b

Please sign in to comment.