@@ -11,6 +11,7 @@ module Main (main) where
11
11
12
12
import Control.Applicative.Combinators
13
13
import Control.Exception (catch )
14
+ import qualified Control.Lens as Lens
14
15
import Control.Monad
15
16
import Control.Monad.IO.Class (liftIO )
16
17
import Data.Aeson (FromJSON , Value )
@@ -32,6 +33,7 @@ import Language.Haskell.LSP.Test hiding (openDoc')
32
33
import Language.Haskell.LSP.Messages
33
34
import Language.Haskell.LSP.Types
34
35
import Language.Haskell.LSP.Types.Capabilities
36
+ import qualified Language.Haskell.LSP.Types.Lens as Lsp (diagnostics , params , message )
35
37
import Language.Haskell.LSP.VFS (applyChange )
36
38
import Network.URI
37
39
import System.Environment.Blank (setEnv )
@@ -231,7 +233,6 @@ diagnosticTests = testGroup "diagnostics"
231
233
[ deferralTest " type error" " True" " Couldn't match expected type"
232
234
, deferralTest " typed hole" " _" " Found hole"
233
235
, deferralTest " out of scope var" " unbound" " Variable not in scope"
234
- , deferralTest " message shows error" " True" " A.hs:3:5: error:"
235
236
]
236
237
237
238
, testSessionWait " remove required module" $ do
@@ -433,6 +434,25 @@ diagnosticTests = testGroup "diagnostics"
433
434
]
434
435
)
435
436
]
437
+ , testSessionWait " strip file path" $ do
438
+ let
439
+ name = " Testing"
440
+ content = T. unlines
441
+ [ " module " <> name <> " where"
442
+ , " value :: Maybe ()"
443
+ , " value = [()]"
444
+ ]
445
+ _ <- openDoc' (T. unpack name <> " .hs" ) " haskell" content
446
+ notification <- skipManyTill anyMessage diagnostic
447
+ let
448
+ offenders =
449
+ Lsp. params .
450
+ Lsp. diagnostics .
451
+ Lens. folded .
452
+ Lsp. message .
453
+ Lens. filtered (T. isInfixOf (" /" <> name <> " .hs:" ))
454
+ failure msg = liftIO $ assertFailure $ " Expected file path to be stripped but got " <> T. unpack msg
455
+ Lens. mapMOf_ offenders failure notification
436
456
]
437
457
438
458
codeActionTests :: TestTree
@@ -729,11 +749,7 @@ removeImportTests = testGroup "remove import actions"
729
749
_ <- waitForDiagnostics
730
750
[CACodeAction action@ CodeAction { _title = actionTitle }]
731
751
<- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
732
- #if MIN_GHC_API_VERSION(8,6,0)
733
752
liftIO $ " Remove !!, <?> from import" @=? actionTitle
734
- #else
735
- liftIO $ " Remove A.!!, A.<?> from import" @=? actionTitle
736
- #endif
737
753
executeCodeAction action
738
754
contentAfterAction <- documentContents docB
739
755
let expectedContentAfterAction = T. unlines
0 commit comments