Skip to content

Commit f75bd70

Browse files
committed
Add test for compilation error capture
1 parent 0ed9c4c commit f75bd70

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
@@ -396,6 +396,19 @@ test_signal_handlers = IOTestCase "signal_handlers" [] $ \wrapInterp -> do
396396
return r
397397
#endif
398398

399+
test_error_capture :: IOTestCase
400+
test_error_capture = IOTestCase "error_capture" [mod_file] $ \wrapInterp-> do
401+
liftIO $ writeFile mod_file "$"
402+
r <- wrapInterp runInterpreter $ do
403+
loadModules [mod_file]
404+
case r of
405+
Right () -> assertFailure "Loaded invalid file"
406+
Left (WontCompile _) -> pure $ Right ()
407+
Left e -> assertFailure $ "Got other than WontCompiler error: " ++ show e
408+
409+
where mod_name = "TEST_ErrorCapture"
410+
mod_file = mod_name ++ ".hs"
411+
399412
tests :: [TestCase]
400413
tests = [test_reload_modified
401414
,test_lang_exts
@@ -422,6 +435,7 @@ tests = [test_reload_modified
422435
ioTests :: [IOTestCase]
423436
ioTests = [test_signal_handlers
424437
,test_package_db
438+
,test_error_capture
425439
]
426440

427441
main :: IO ()

0 commit comments

Comments
 (0)