-- | Run all tests using the supplied binary, and the directory to the test
-- files
runTests :: FilePath -> FilePath -> IO ()
runTests bin dirTests = do
  -- Get all files in the test directory
  files <- getDirectoryContents dirTests
  -- Filter out the scripts, and create their relative paths
  let scripts = map (dirTests ++) $ filter (".sh" `isSuffixOf`) files
  -- Test all the scripts
  passed <- foldM test True scripts
  if passed then return () else exitFailure
  where
    test :: Bool -> FilePath -> IO Bool
    test b path = do
      passed <- runTest bin path
      return $ b && passed

-- | Run a test scripts, and check if the output is the same as the expected
-- output
runTests :: FilePath -> FilePath -> IO ()
runTests bin dirTests = do
  -- Get all files in the test directory
  files <- getDirectoryContents dirTests
  -- Filter out the scripts, and create their relative paths
  let scripts = map (dirTests ++) $ filter (".sh" `isSuffixOf`) files
  -- Test all the scripts
  passed <- foldM test True scripts
  if passed then return () else exitFailure
  where
    test :: Bool -> FilePath -> IO Bool
    test b path = do
      passed <- runTest bin path
      return $ b && passed

-- | Run a test scripts, and check if the output is the same as the expected
-- output
runTests bin dirTests = do
  -- Get all files in the test directory
  files <- getDirectoryContents dirTests
  -- Filter out the scripts, and create their relative paths
  let scripts = map (dirTests ++) $ filter (".sh" `isSuffixOf`) files
  -- Test all the scripts
  passed <- foldM test True scripts
  if passed then return () else exitFailure
  where
    test :: Bool -> FilePath -> IO Bool
    test b path = do
      passed <- runTest bin path
      return $ b && passed

-- | Run a test scripts, and check if the output is the same as the expected
-- output