@@ -3,6 +3,7 @@ module Tests.Compiler (compilerTests)
33
44import Data.Functor ((<$>))
55import Data.Traversable (traverse)
6+import System.FilePath ((</>))
67import System.FilePath.Find (find, (==?), extension)
78import Test.Framework
89import Test.Framework.Providers.HUnit (testCase)
@@ -12,9 +13,8 @@ import Elm.Internal.Utils as Elm
1213
1314compilerTests :: Test
1415compilerTests = buildTest $ do
15− goods <- getElms "tests/data/good" >>= mkTests True
16− bads <- getElms "tests/data/bad" >>= mkTests False
17−
16+ goods <- mkTests True =<< getElms "good"
17+ bads <- mkTests False =<< getElms "bad"
1818 return $ testGroup "Compile Tests"
1919 [
2020 testGroup "Good Tests" goods
@@ -22,12 +22,14 @@ compilerTests = buildTest $ do
2222 ]
2323
2424 where getElms :: FilePath -> IO [FilePath]
25− getElms = find (return True) (extension ==? ".elm")
25+ getElms fname = find (return True) (extension ==? ".elm") (testsDir </> fname)
2626
2727 mkTests :: Bool -> [FilePath] -> IO [Test]
2828 mkTests b = traverse setupTest
2929 where setupTest f = testCase f . mkCompileTest b <$> readFile f
3030
31+ testsDir = "tests" </> "data"
32+
3133mkCompileTest :: Bool -- ^ Expect success?
3234 -> String -- ^ File Contents
3335 -> Assertion