diff options
author | PhilFreeman <> | 2015-04-15 17:17:00 (GMT) |
---|---|---|
committer | hdiff <hdiff@hdiff.luite.com> | 2015-04-15 17:17:00 (GMT) |
commit | 15e7e9fc274765b27b339cdf6e3757f3f7490e0f (patch) | |
tree | ddb92ad2cab26ee61e3d442ee654d05b996f8e38 /tests | |
parent | 1631e68f891ac05afd312f1d4d65a50a65922820 (diff) |
version 0.6.9.40.6.9.4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Main.hs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/Main.hs b/tests/Main.hs index e7ac794..5c998ee 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -35,21 +35,21 @@ readInput inputFiles = forM inputFiles $ \inputFile -> do text <- readFile inputFile return (inputFile, text) -loadPrelude :: Either String (String, String, P.Environment) +loadPrelude :: Either P.MultipleErrors (String, String, P.Environment) loadPrelude = case P.parseModulesFromFiles id [("", P.prelude)] of - Left parseError -> Left (show parseError) + Left parseError -> Left . P.errorMessage . P.ErrorParsingPrelude $ parseError Right ms -> runReaderT (P.compile (map snd ms) []) $ P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] } -compile :: P.Options P.Compile -> [FilePath] -> IO (Either String (String, String, P.Environment)) +compile :: P.Options P.Compile -> [FilePath] -> IO (Either P.MultipleErrors (String, String, P.Environment)) compile opts inputFiles = do modules <- P.parseModulesFromFiles id <$> readInput inputFiles case modules of Left parseError -> - return (Left $ show parseError) + return . Left . P.errorMessage . P.ErrorParsingPrelude $ parseError Right ms -> return $ runReaderT (P.compile (map snd ms) []) opts -assert :: FilePath -> P.Options P.Compile -> FilePath -> (Either String (String, String, P.Environment) -> IO (Maybe String)) -> IO () +assert :: FilePath -> P.Options P.Compile -> FilePath -> (Either P.MultipleErrors (String, String, P.Environment) -> IO (Maybe String)) -> IO () assert preludeExterns opts inputFile f = do e <- compile opts [preludeExterns, inputFile] maybeErr <- f e @@ -64,7 +64,7 @@ assertCompiles preludeJs preludeExterns inputFile = do { P.optionsMain = Just "Main" , P.optionsAdditional = P.CompileOptions "Tests" ["Main"] ["Main"] } - assert preludeExterns options inputFile $ either (return . Just) $ \(js, _, _) -> do + assert preludeExterns options inputFile $ either (return . Just . P.prettyPrintMultipleErrors False) $ \(js, _, _) -> do process <- findNodeProcess result <- traverse (\node -> readProcessWithExitCode node [] (preludeJs ++ js)) process case result of @@ -77,7 +77,7 @@ assertDoesNotCompile preludeExterns inputFile = do putStrLn $ "Assert " ++ inputFile ++ " does not compile" assert preludeExterns (P.defaultCompileOptions { P.optionsAdditional = P.CompileOptions "Tests" [] [] }) inputFile $ \e -> case e of - Left err -> putStrLn err >> return Nothing + Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> return Nothing Right _ -> return $ Just "Should not have compiled" findNodeProcess :: IO (Maybe String) @@ -88,7 +88,7 @@ main :: IO () main = do putStrLn "Compiling Prelude" case loadPrelude of - Left err -> putStrLn err >> exitFailure + Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure Right (preludeJs, exts, _) -> do tmp <- getTemporaryDirectory let preludeExterns = tmp ++ pathSeparator : "prelude.externs" @@ -105,4 +105,3 @@ main = do forM_ failingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $ assertDoesNotCompile preludeExterns (failing ++ pathSeparator : inputFile) exitSuccess - |