@@ -12,6 +12,7 @@ import Control.Monad
1212import Control.Monad.IO.Class (liftIO)
1313import Data.Char (toLower)
1414import Data.Foldable
15+import Development.IDE.GHC.Util
1516import qualified Data.Text as T
1617import Development.IDE.Test
1718import Development.IDE.Test.Runfiles
@@ -694,7 +695,7 @@ findDefinitionAndHoverTests :: TestTree
694695findDefinitionAndHoverTests = let
695696
696697 tst (get, check) pos targetRange title = testSession title $ do
697− doc <- openDoc' sourceFilePath "haskell" source
698+ doc <- openTestDataDoc sourceFilePath
698699 found <- get doc pos
699700 check found targetRange
700701
@@ -751,8 +752,8 @@ findDefinitionAndHoverTests = let
751752 (T.unpack $ "failed to find: `" <> part <> "` in hover message:\n" <> whole)
752753 (part `T.isInfixOf` whole)
753754
754− sourceFilePath = "Testing.hs" -- TODO: convert from sourceFileName
755− sourceFileName = "Testing.hs"
755+ sourceFilePath = T.unpack sourceFileName
756+ sourceFileName = "GotoHover.hs"
756757
757758 mkFindTests tests = testGroup "get"
758759 [ testGroup "definition" $ mapMaybe fst tests
@@ -765,33 +766,6 @@ findDefinitionAndHoverTests = let
765766 hover = (getHover , checkHover)
766767 --type_ = (getTypeDefinitions, checkTDefs) -- getTypeDefinitions always times out
767768
768− source = T.unlines
769− -- 0123456789 123456789 123456789 123456789
770− [ "{-# OPTIONS_GHC -Wmissing-signatures #-}" -- 0
771− , "module Testing where" -- 1
772− , "import Data.Text (Text, pack)" -- 2
773− , "data TypeConstructor = DataConstructor" -- 3
774− , " { fff :: Text" -- 4
775− , " , ggg :: Int }" -- 5
776− , "aaa :: TypeConstructor" -- 6
777− , "aaa = DataConstructor" -- 7
778− , " { fff = \"\"" -- 8
779− , " , ggg = 0" -- 9
780− -- 0123456789 123456789 123456789 123456789
781− , " }" -- 10
782− , "bbb :: TypeConstructor" -- 11
783− , "bbb = DataConstructor \"\" 0" -- 12
784− , "ccc :: (Text, Int)" -- 13
785− , "ccc = (fff bbb, ggg aaa)" -- 14
786− , "ddd :: Num a => a -> a -> a" -- 15
787− , "ddd vv ww = vv +! ww" -- 16
788− , "a +! b = a - b" -- 17
789− , "hhh (Just a) (><) = a >< a" -- 18
790− , "iii a b = a `b` a" -- 19
791− , "jjj s = pack $ s <> s" -- 20
792− -- 0123456789 123456789 123456789 123456789
793− ]
794−
795769 -- search locations expectations on results
796770 fffL4 = _start fffR ; fffR = mkRange 4 4 4 7 ; fff = [ExpectRange fffR]
797771 fffL8 = Position 8 4 ;
@@ -888,3 +862,8 @@ run s = withTempDir $ \dir -> do
888862 -- If you uncomment this you can see all messages
889863 -- which can be quite useful for debugging.
890864 -- { logMessages = True, logColor = False, logStdErr = True }
865+
866+openTestDataDoc :: FilePath -> Session TextDocumentIdentifier
867+openTestDataDoc path = do
868+ source <- liftIO $ readFileUtf8 $ "test/data" </> path
869+ openDoc' path "haskell" source