Commit 326bc86f authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Only check examples with a corresponding .out file

This allows files to exists in the examples directory that don't have
a ".out" file. These are now ignored in the test suite. Such files
could be documentation or ephemeral tests.
parent f0ecb444
......@@ -157,3 +157,4 @@ test-suite examples
, hspec
, directory
, text
, extra
......@@ -5,6 +5,7 @@ module Main (main) where
import Control.Monad.ST
import Data.List
import Data.List.Extra (dropSuffix)
import qualified Data.Text as T
import System.Directory
import Test.Hspec
......@@ -16,7 +17,7 @@ import MA.PartitionPrinter
main :: IO ()
main = do
let exampleDir = "examples/"
files <- filter (not . isOutput) <$> listDirectory exampleDir
files <- filter isOutput <$> listDirectory exampleDir
hspec $ testFiles (map (exampleDir ++) files)
outSuffix :: String
......@@ -29,9 +30,11 @@ testFiles :: [FilePath] -> Spec
testFiles = mapM_ testFile
testFile :: FilePath -> Spec
testFile file = specify file $ do
output <- readFile (file ++ outSuffix)
process file `shouldReturn` output
testFile outfile =
let file = dropSuffix outSuffix outfile
in specify file $ do
output <- readFile (file ++ outSuffix)
process file `shouldReturn` output
process :: FilePath -> IO String
process file = readCoalgebraFromFile file >>= \case
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment