Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Add test for th link failure (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
wz1000 authored Oct 9, 2020
1 parent b60a64f commit 2f7487e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
1 change: 0 additions & 1 deletion test/data/TH/THB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ module THB where
import THA

$th_a

29 changes: 28 additions & 1 deletion test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,7 @@ thTests =
return ()
, ignoreInWindowsForGHC88 (thReloadingTest `xfail` "expect broken (#672)")
-- Regression test for https://github.com/digital-asset/ghcide/issues/614
, thLinkingTest `xfail` "expect broken"
, testSessionWait "findsTHIdentifiers" $ do
let sourceA =
T.unlines
Expand Down Expand Up @@ -2509,7 +2510,7 @@ thReloadingTest = testCase "reloading-th-test" $ withoutStackEnv $ runWithExtraF
bPath = dir </> "THB.hs"
cPath = dir </> "THC.hs"

aSource <- liftIO $ readFileUtf8 aPath -- th = [d|a :: ()|]
aSource <- liftIO $ readFileUtf8 aPath -- th = [d|a = ()|]
bSource <- liftIO $ readFileUtf8 bPath -- $th
cSource <- liftIO $ readFileUtf8 cPath -- c = a :: ()

Expand All @@ -2535,6 +2536,32 @@ thReloadingTest = testCase "reloading-th-test" $ withoutStackEnv $ runWithExtraF
closeDoc bdoc
closeDoc cdoc

thLinkingTest :: TestTree
thLinkingTest = testCase "th-linking-test" $ withoutStackEnv $ runWithExtraFiles "TH" $ \dir -> do

let aPath = dir </> "THA.hs"
bPath = dir </> "THB.hs"

aSource <- liftIO $ readFileUtf8 aPath -- th_a = [d|a :: ()|]
bSource <- liftIO $ readFileUtf8 bPath -- $th_a

adoc <- createDoc aPath "haskell" aSource
bdoc <- createDoc bPath "haskell" bSource

expectDiagnostics [("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]

let aSource' = T.unlines $ init (init (T.lines aSource)) ++ ["th :: DecsQ", "th = [d| a = False|]"]
changeDoc adoc [TextDocumentContentChangeEvent Nothing Nothing aSource']

-- modify b too
let bSource' = T.unlines $ init (T.lines bSource) ++ ["$th"]
changeDoc bdoc [TextDocumentContentChangeEvent Nothing Nothing bSource']

expectDiagnostics [("THB.hs", [(DsWarning, (4,0), "Top-level binding")])]

closeDoc adoc
closeDoc bdoc


completionTests :: TestTree
completionTests
Expand Down

0 comments on commit 2f7487e

Please sign in to comment.