Skip to content

Commit

Permalink
Add test for compilation error capture
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed May 6, 2022
1 parent 0ed9c4c commit f75bd70
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions unit-tests/run-unit-tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -422,6 +435,7 @@ tests = [test_reload_modified
ioTests :: [IOTestCase]
ioTests = [test_signal_handlers
,test_package_db
,test_error_capture
]

main :: IO ()
Expand Down

0 comments on commit f75bd70

Please sign in to comment.