Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for compilation error capture #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions unit-tests/run-unit-tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,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 Down Expand Up @@ -522,6 +535,7 @@ ioTests :: [IOTestCase]
ioTests = [test_signal_handlers
,test_package_db
,test_ghc_environment_file
,test_error_capture
]

main :: IO ()
Expand Down
Loading