Skip to content

Commit

Permalink
[Migrate DependentFileTest] part of #4173 Migrate ghcide tests to hls…
Browse files Browse the repository at this point in the history
… test utils (#4195)

* wip trace flaky

* clena up trace

* cleanup

* cleanup
  • Loading branch information
soulomoon authored Apr 29, 2024
1 parent 8afc65a commit a3e4b95
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ghcide/test/exe/DependentFileTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

module DependentFileTest (tests) where

import Config
import Control.Monad.IO.Class (liftIO)
import Data.Row
import qualified Data.Text as T
Expand All @@ -16,19 +17,19 @@ import Language.LSP.Protocol.Types hiding
SemanticTokensEdit (..),
mkRange)
import Language.LSP.Test
import System.FilePath
import Test.Hls.FileSystem (FileSystem, toAbsFp)
import Test.Tasty
import TestUtils

tests :: TestTree
tests = testGroup "addDependentFile"
[testGroup "file-changed" [testSession' "test" test]
[testGroup "file-changed" [testWithDummyPlugin' "test" (mkIdeTestFs []) test]
]
where
test :: FileSystem -> Session ()
test dir = do
-- If the file contains B then no type error
-- otherwise type error
let depFilePath = dir </> "dep-file.txt"
let depFilePath = toAbsFp dir "dep-file.txt"
liftIO $ writeFile depFilePath "A"
let fooContent = T.unlines
[ "{-# LANGUAGE TemplateHaskell #-}"
Expand All @@ -41,7 +42,7 @@ tests = testGroup "addDependentFile"
, " if f == \"B\" then [| 1 |] else lift f)"
]
let bazContent = T.unlines ["module Baz where", "import Foo ()"]
_ <- createDoc "Foo.hs" "haskell" fooContent
_fooDoc <- createDoc "Foo.hs" "haskell" fooContent
doc <- createDoc "Baz.hs" "haskell" bazContent
expectDiagnostics
[("Foo.hs", [(DiagnosticSeverity_Error, (4,11), "Couldn't match type")])]
Expand Down

0 comments on commit a3e4b95

Please sign in to comment.