From f75bd70ceee5ad99d19983af257f40af5bd1ab2f Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Fri, 6 May 2022 16:32:38 +0200 Subject: [PATCH] Add test for compilation error capture --- unit-tests/run-unit-tests.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unit-tests/run-unit-tests.hs b/unit-tests/run-unit-tests.hs index 0824445..ae29a64 100644 --- a/unit-tests/run-unit-tests.hs +++ b/unit-tests/run-unit-tests.hs @@ -396,6 +396,19 @@ test_signal_handlers = IOTestCase "signal_handlers" [] $ \wrapInterp -> do return r #endif +test_error_capture :: IOTestCase +test_error_capture = IOTestCase "error_capture" [mod_file] $ \wrapInterp-> do + liftIO $ writeFile mod_file "$" + r <- wrapInterp runInterpreter $ do + loadModules [mod_file] + case r of + Right () -> assertFailure "Loaded invalid file" + Left (WontCompile _) -> pure $ Right () + Left e -> assertFailure $ "Got other than WontCompiler error: " ++ show e + + where mod_name = "TEST_ErrorCapture" + mod_file = mod_name ++ ".hs" + tests :: [TestCase] tests = [test_reload_modified ,test_lang_exts @@ -422,6 +435,7 @@ tests = [test_reload_modified ioTests :: [IOTestCase] ioTests = [test_signal_handlers ,test_package_db + ,test_error_capture ] main :: IO ()