2module Tests.Compiler (compilerTests) where
4import Data.Traversable (traverse)
7import System.FilePath ((</>))
8import System.FilePath.Find (find, (==?), extension)
9import System.Process (readProcessWithExitCode)
12import Test.Framework.Providers.HUnit (testCase)
13import Test.HUnit (Assertion, assertFailure, assertBool)
18 goods <- testIf isSuccess =<< getElms "good"
19 bads <- testIf isFailure =<< getElms "bad"
20 return $ testGroup "Compile Tests"
21 [ testGroup "Good Tests" goods
22 , testGroup "Bad Tests" bads
27getElms :: FilePath -> IO [FilePath]
29 find (return True) (extension ==? ".elm") (testsDir </> filePath)
32testsDir = "tests" </> "compiler" </> "test-files"
37testIf :: (ExitCode -> String -> Assertion) -> [FilePath] -> IO [Test]
38testIf handler filePaths =
39 traverse setupTest filePaths
41 setupTest filePath = do
42 let args = [ "--make", "--src-dir=" ++ testsDir, filePath ]
43 (exitCode, stdout, stderr) <- readProcessWithExitCode compiler args ""
44 return (testCase filePath (handler exitCode (stdout ++ stderr)))
47compiler = "dist" </> "build" </> "elm" </> "elm"
52isSuccess :: ExitCode -> String -> Assertion
53isSuccess exitCode stderr =
55 ExitSuccess -> assertBool "" True
56 ExitFailure _ -> assertFailure stderr
58isFailure :: ExitCode -> String -> Assertion
59isFailure exitCode _stderr =
61 ExitSuccess -> assertFailure "Compilation succeeded but should have failed"
62 ExitFailure _ -> assertBool "" True
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list