packages feed

pathtype-0.5.5: test/Test.hs

module Main (main) where

import TestResult (results)

import System.Path (rootDir, asRelDir, asRelFile, (</>), (<.>))
import System.Random (newStdGen, random)
import System.Exit (exitFailure)
import Control.Monad (void)
import Text.Printf (printf)


main :: IO ()
main = do
  g <- newStdGen
  let (a,_g') = random g
      -- TODO - integrate with QuickCheck
      x = rootDir </> asRelDir "tmp" </> asRelFile "someFile" <.> "ext"

  let allResults = results a x
  void $ printf "Running %d tests...\n" $ length allResults

  let fails = map fst $ filter (not . snd) allResults
  if null fails
    then do
      putStrLn "Passed."
    else do
      putStrLn "Failed tests:"
      mapM_ putStrLn fails
      exitFailure