Skip to content

Commit 9321d72

Browse files
committed
Add test for compilation error capture
1 parent 0a0577f commit 9321d72

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

unit-tests/run-unit-tests.hs

+14
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,19 @@ test_signal_handlers = IOTestCase "signal_handlers" [] $ \wrapInterp -> do
495495
return r
496496
#endif
497497

498+
test_error_capture :: IOTestCase
499+
test_error_capture = IOTestCase "error_capture" [mod_file] $ \wrapInterp-> do
500+
liftIO $ writeFile mod_file "$"
501+
r <- wrapInterp runInterpreter $ do
502+
loadModules [mod_file]
503+
case r of
504+
Right () -> assertFailure "Loaded invalid file"
505+
Left (WontCompile _) -> pure $ Right ()
506+
Left e -> assertFailure $ "Got other than WontCompiler error: " ++ show e
507+
508+
where mod_name = "TEST_ErrorCapture"
509+
mod_file = mod_name ++ ".hs"
510+
498511
tests :: [TestCase]
499512
tests = [test_reload_modified
500513
,test_lang_exts
@@ -522,6 +535,7 @@ ioTests :: [IOTestCase]
522535
ioTests = [test_signal_handlers
523536
,test_package_db
524537
,test_ghc_environment_file
538+
,test_error_capture
525539
]
526540

527541
main :: IO ()

0 commit comments

Comments
 (0)