@@ -11,6 +11,7 @@ module Main (main) where
1111
1212import Control.Applicative.Combinators
1313import Control.Exception (catch )
14+ import qualified Control.Lens as Lens
1415import Control.Monad
1516import Control.Monad.IO.Class (liftIO )
1617import Data.Aeson (FromJSON , Value )
@@ -32,6 +33,7 @@ import Language.Haskell.LSP.Test hiding (openDoc')
3233import Language.Haskell.LSP.Messages
3334import Language.Haskell.LSP.Types
3435import Language.Haskell.LSP.Types.Capabilities
36+ import qualified Language.Haskell.LSP.Types.Lens as Lsp (diagnostics , params , message )
3537import Language.Haskell.LSP.VFS (applyChange )
3638import Network.URI
3739import System.Environment.Blank (setEnv )
@@ -231,7 +233,6 @@ diagnosticTests = testGroup "diagnostics"
231233 [ deferralTest " type error" " True" " Couldn't match expected type"
232234 , deferralTest " typed hole" " _" " Found hole"
233235 , deferralTest " out of scope var" " unbound" " Variable not in scope"
234- , deferralTest " message shows error" " True" " A.hs:3:5: error:"
235236 ]
236237
237238 , testSessionWait " remove required module" $ do
@@ -433,6 +434,25 @@ diagnosticTests = testGroup "diagnostics"
433434 ]
434435 )
435436 ]
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
436456 ]
437457
438458codeActionTests :: TestTree
@@ -729,11 +749,7 @@ removeImportTests = testGroup "remove import actions"
729749 _ <- waitForDiagnostics
730750 [CACodeAction action@ CodeAction { _title = actionTitle }]
731751 <- getCodeActions docB (Range (Position 2 0 ) (Position 2 5 ))
732- #if MIN_GHC_API_VERSION(8,6,0)
733752 liftIO $ " Remove !!, <?> from import" @=? actionTitle
734- #else
735- liftIO $ " Remove A.!!, A.<?> from import" @=? actionTitle
736- #endif
737753 executeCodeAction action
738754 contentAfterAction <- documentContents docB
739755 let expectedContentAfterAction = T. unlines
0 commit comments