@@ -3385,7 +3385,7 @@ cradleTests :: TestTree
3385
3385
cradleTests = testGroup " cradle"
3386
3386
[testGroup " dependencies" [sessionDepsArePickedUp]
3387
3387
,testGroup " ignore-fatal" [ignoreFatalWarning]
3388
- ,testGroup " loading" [loadCradleOnlyonce]
3388
+ ,testGroup " loading" [loadCradleOnlyonce, retryFailedCradle ]
3389
3389
,testGroup " multi" [simpleMultiTest, simpleMultiTest2]
3390
3390
,testGroup " sub-directory" [simpleSubDirectoryTest]
3391
3391
]
@@ -3412,6 +3412,43 @@ loadCradleOnlyonce = testGroup "load cradle only once"
3412
3412
msgs <- manyTill (skipManyTill anyMessage cradleLoadedMessage) (skipManyTill anyMessage (message @ PublishDiagnosticsNotification ))
3413
3413
liftIO $ length msgs @?= 0
3414
3414
3415
+ retryFailedCradle :: TestTree
3416
+ retryFailedCradle = testSession' " retry failed" $ \ dir -> do
3417
+ -- The false cradle always fails
3418
+ let hieContents = " cradle: {bios: {shell: \" false\" }}"
3419
+ hiePath = dir </> " hie.yaml"
3420
+ liftIO $ writeFile hiePath hieContents
3421
+ hieDoc <- createDoc hiePath " yaml" $ T. pack hieContents
3422
+ let aPath = dir </> " A.hs"
3423
+ doc <- createDoc aPath " haskell" " main = return ()"
3424
+ Right WaitForIdeRuleResult {.. } <- waitForAction " TypeCheck" doc
3425
+ liftIO $ " Test assumption failed: cradle should error out" `assertBool` not ideResultSuccess
3426
+
3427
+ -- Fix the cradle and typecheck again
3428
+ let validCradle = " cradle: {bios: {shell: \" echo A.hs\" }}"
3429
+ liftIO $ writeFileUTF8 hiePath $ T. unpack validCradle
3430
+ changeDoc
3431
+ hieDoc
3432
+ [ TextDocumentContentChangeEvent
3433
+ { _range = Nothing ,
3434
+ _rangeLength = Nothing ,
3435
+ _text = validCradle
3436
+ }
3437
+ ]
3438
+
3439
+ -- Force a session restart by making an edit, just to dirty the typecheck node
3440
+ changeDoc
3441
+ doc
3442
+ [ TextDocumentContentChangeEvent
3443
+ { _range = Just Range {_start = Position 0 0 , _end = Position 0 0 },
3444
+ _rangeLength = Nothing ,
3445
+ _text = " \n "
3446
+ }
3447
+ ]
3448
+
3449
+ Right WaitForIdeRuleResult {.. } <- waitForAction " TypeCheck" doc
3450
+ liftIO $ " No joy after fixing the cradle" `assertBool` ideResultSuccess
3451
+
3415
3452
3416
3453
dependentFileTest :: TestTree
3417
3454
dependentFileTest = testGroup " addDependentFile"
0 commit comments