Skip to content

Commit c5126c9

Browse files
committed
add a test for deeply nested import cycles
1 parent 63929b8 commit c5126c9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ghcide/test/exe/Main.hs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,30 @@ diagnosticTests = testGroup "diagnostics"
405405
, [(DsError, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]
406406
)
407407
]
408+
, testSession' "deeply nested cyclic module dependency" $ \path -> do
409+
let contentA = unlines
410+
[ "module ModuleA where" , "import ModuleB" ]
411+
let contentB = unlines
412+
[ "module ModuleB where" , "import ModuleA" ]
413+
let contentC = unlines
414+
[ "module ModuleC where" , "import ModuleB" ]
415+
let contentD = T.unlines
416+
[ "module ModuleD where" , "import ModuleC" ]
417+
cradle =
418+
"cradle: {direct: {arguments: [ModuleA, ModuleB, ModuleC, ModuleD]}}"
419+
liftIO $ writeFile (path </> "ModuleA.hs") contentA
420+
liftIO $ writeFile (path </> "ModuleB.hs") contentB
421+
liftIO $ writeFile (path </> "ModuleC.hs") contentC
422+
liftIO $ writeFile (path </> "hie.yaml") cradle
423+
_ <- createDoc "ModuleD.hs" "haskell" contentD
424+
expectDiagnostics
425+
[ ( "ModuleA.hs"
426+
, [(DsError, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]
427+
)
428+
, ( "ModuleB.hs"
429+
, [(DsError, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]
430+
)
431+
]
408432
, testSessionWait "cyclic module dependency with hs-boot" $ do
409433
let contentA = T.unlines
410434
[ "module ModuleA where"

0 commit comments

Comments
 (0)