Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Migrate DependentFileTest] part of #4173 Migrate ghcide tests to hls test utils #4195

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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