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

Remove more workarounds for GHCs < 9.2 (#4092) #4098

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ library ghcide-test-utils
visibility: public
default-language: GHC2021

hs-source-dirs: test/src test/cabal
hs-source-dirs: test/src test/cabal
exposed-modules:
Development.IDE.Test
Development.IDE.Test.Runfiles
Expand All @@ -306,14 +306,13 @@ library ghcide-test-utils
lsp-test ^>= 0.17,
tasty-hunit >= 0.10,
text,
row-types,

default-extensions:
LambdaCase
OverloadedStrings
RecordWildCards
ViewPatterns

test-suite ghcide-tests
import: warnings
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -365,7 +364,7 @@ test-suite ghcide-tests
if impl(ghc <9.3)
build-depends: ghc-typelits-knownnat

hs-source-dirs: test/exe
hs-source-dirs: test/exe
ghc-options: -threaded -O0

main-is: Main.hs
Expand All @@ -392,7 +391,6 @@ test-suite ghcide-tests
NonLspCommandLine
OpenCloseTest
OutlineTests
PluginParsedResultTests
PluginSimpleTests
PositionMappingTests
PreprocessorTests
Expand Down
6 changes: 0 additions & 6 deletions ghcide/test/data/plugin-recorddot/RecordDot.hs

This file was deleted.

1 change: 0 additions & 1 deletion ghcide/test/data/plugin-recorddot/cabal.project

This file was deleted.

9 changes: 0 additions & 9 deletions ghcide/test/data/plugin-recorddot/plugin.cabal

This file was deleted.

2 changes: 1 addition & 1 deletion ghcide/test/exe/CodeLensTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ addSigLensesTests =
, ("rank2Test (k :: forall a . a -> a) = (k 233 :: Int, k \"QAQ\")", "rank2Test :: (forall a. a -> a) -> (Int, String)")
, ("symbolKindTest = Proxy @\"qwq\"", "symbolKindTest :: Proxy \"qwq\"")
, ("promotedKindTest = Proxy @Nothing", if ghcVersion >= GHC96 then "promotedKindTest :: Proxy Nothing" else "promotedKindTest :: Proxy 'Nothing")
, ("typeOperatorTest = Refl", if ghcVersion >= GHC92 then "typeOperatorTest :: forall {k} {a :: k}. a :~: a" else "typeOperatorTest :: a :~: a")
, ("typeOperatorTest = Refl", "typeOperatorTest :: forall {k} {a :: k}. a :~: a")
, ("notInScopeTest = mkCharType", "notInScopeTest :: String -> Data.Data.DataType")
, ("aVeryLongSignature a b c d e f g h i j k l m n = a && b && c && d && e && f && g && h && i && j && k && l && m && n", "aVeryLongSignature :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool")
]
Expand Down
3 changes: 1 addition & 2 deletions ghcide/test/exe/DependentFileTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module DependentFileTest (tests) where
import Control.Monad.IO.Class (liftIO)
import Data.Row
import qualified Data.Text as T
import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion)
import Development.IDE.Test (expectDiagnostics)
import Development.IDE.Types.Location
import Language.LSP.Protocol.Message
Expand Down Expand Up @@ -45,7 +44,7 @@ tests = testGroup "addDependentFile"
_ <- createDoc "Foo.hs" "haskell" fooContent
doc <- createDoc "Baz.hs" "haskell" bazContent
expectDiagnostics
[("Foo.hs", [(DiagnosticSeverity_Error, if ghcVersion >= GHC92 then (4,11) else (4, 6), "Couldn't match type")])]
[("Foo.hs", [(DiagnosticSeverity_Error, (4,11), "Couldn't match type")])]
-- Now modify the dependent file
liftIO $ writeFile depFilePath "B"
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
Expand Down
16 changes: 7 additions & 9 deletions ghcide/test/exe/FindDefinitionAndHoverTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,11 @@ tests = let
typeDefinitionTests = [ tst (getTypeDefinitions, checkDefs) aaaL14 sourceFilePath (pure tcData) "Saturated data con"
, tst (getTypeDefinitions, checkDefs) aL20 sourceFilePath (pure [ExpectNoDefinitions]) "Polymorphic variable"]

recordDotSyntaxTests
| ghcVersion >= GHC92 =
[ tst (getHover, checkHover) (Position 17 24) (T.unpack "RecordDotSyntax.hs") (pure [ExpectHoverText ["x :: MyRecord"]]) "hover over parent"
, tst (getHover, checkHover) (Position 17 25) (T.unpack "RecordDotSyntax.hs") (pure [ExpectHoverText ["_ :: MyChild"]]) "hover over dot shows child"
, tst (getHover, checkHover) (Position 17 26) (T.unpack "RecordDotSyntax.hs") (pure [ExpectHoverText ["_ :: MyChild"]]) "hover over child"
]
| otherwise = []
recordDotSyntaxTests =
[ tst (getHover, checkHover) (Position 17 24) (T.unpack "RecordDotSyntax.hs") (pure [ExpectHoverText ["x :: MyRecord"]]) "hover over parent"
, tst (getHover, checkHover) (Position 17 25) (T.unpack "RecordDotSyntax.hs") (pure [ExpectHoverText ["_ :: MyChild"]]) "hover over dot shows child"
, tst (getHover, checkHover) (Position 17 26) (T.unpack "RecordDotSyntax.hs") (pure [ExpectHoverText ["_ :: MyChild"]]) "hover over child"
]

test runDef runHover look expect = testM runDef runHover look (return expect)

Expand Down Expand Up @@ -157,8 +155,8 @@ tests = let
spaceL37 = Position 41 24 ; space = [ExpectNoDefinitions, ExpectHoverText [":: Char"]]
docL41 = Position 45 1 ; doc = [ExpectHoverText ["Recognizable docs: kpqz"]]
; constr = [ExpectHoverText ["Monad m"]]
eitL40 = Position 44 28 ; kindE = [ExpectHoverText [if ghcVersion >= GHC92 then ":: Type -> Type -> Type\n" else ":: * -> * -> *\n"]]
intL40 = Position 44 34 ; kindI = [ExpectHoverText [if ghcVersion >= GHC92 then ":: Type\n" else ":: *\n"]]
eitL40 = Position 44 28 ; kindE = [ExpectHoverText [":: Type -> Type -> Type\n"]]
intL40 = Position 44 34 ; kindI = [ExpectHoverText [":: Type\n"]]
tvrL40 = Position 44 37 ; kindV = [ExpectHoverText [":: * -> *\n"]]
intL41 = Position 45 20 ; litI = [ExpectHoverText ["7518"]]
chrL36 = Position 41 24 ; litC = [ExpectHoverText ["'f'"]]
Expand Down
2 changes: 0 additions & 2 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import OutlineTests
import HighlightTests
import FindDefinitionAndHoverTests
import PluginSimpleTests
import PluginParsedResultTests
import PreprocessorTests
import THTests
import SymlinkTests
Expand Down Expand Up @@ -103,7 +102,6 @@ main = do
, HighlightTests.tests
, FindDefinitionAndHoverTests.tests
, PluginSimpleTests.tests
, PluginParsedResultTests.tests
, PreprocessorTests.tests
, THTests.tests
, SymlinkTests.tests
Expand Down
16 changes: 0 additions & 16 deletions ghcide/test/exe/PluginParsedResultTests.hs

This file was deleted.

3 changes: 0 additions & 3 deletions ghcide/test/exe/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ xfail = flip expectFailBecause
ignoreInWindowsBecause :: String -> TestTree -> TestTree
ignoreInWindowsBecause = ignoreFor (BrokenForOS Windows)

ignoreForGHC92Plus :: String -> TestTree -> TestTree
ignoreForGHC92Plus = ignoreFor (BrokenForGHC [GHC92, GHC94, GHC96, GHC98])

knownBrokenForGhcVersions :: [GhcVersion] -> String -> TestTree -> TestTree
knownBrokenForGhcVersions ghcVers = knownBrokenFor (BrokenForGHC ghcVers)

Expand Down
25 changes: 9 additions & 16 deletions plugins/hls-eval-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,22 @@ tests =
else
"-- No instance for (Num String) arising from a use of `+'\n-- In the expression: \"a\" + \"bc\"\n-- In an equation for `res': res = \"a\" + \"bc\""


evalInFile "T8.hs" "-- >>> \"" "-- lexical error in string/character literal at end of input"
evalInFile "T8.hs" "-- >>> 3 `div` 0" "-- divide by zero" -- The default for marking exceptions is False
, goldenWithEval "Applies file LANGUAGE extensions" "T9" "hs"
, goldenWithEval' "Evaluate a type with :kind!" "T10" "hs" (if ghcVersion >= GHC92 then "ghc92.expected" else "expected")
, goldenWithEval' "Reports an error for an incorrect type with :kind!" "T11" "hs" (
if ghcVersion >= GHC94 then "ghc94.expected"
else if ghcVersion >= GHC92 then "ghc92.expected"
else "expected"
)
, goldenWithEval' "Shows a kind with :kind" "T12" "hs" (if ghcVersion >= GHC92 then "ghc92.expected" else "expected")
, goldenWithEval' "Reports an error for an incorrect type with :kind" "T13" "hs" (if ghcVersion >= GHC92 then "ghc92.expected" else "expected")
, goldenWithEval "Evaluate a type with :kind!" "T10" "hs"
, goldenWithEval' "Reports an error for an incorrect type with :kind!" "T11" "hs"
(if ghcVersion >= GHC94 then "ghc94.expected" else "expected")
, goldenWithEval "Shows a kind with :kind" "T12" "hs"
, goldenWithEval "Reports an error for an incorrect type with :kind" "T13" "hs"
, goldenWithEval' "Returns a fully-instantiated type for :type" "T14" "hs" (if ghcVersion >= GHC98 then "ghc98.expected" else "expected") -- See https://gitlab.haskell.org/ghc/ghc/-/issues/24069
, knownBrokenForGhcVersions [GHC92, GHC94, GHC96, GHC98] "type +v does not work anymore with 9.2" $ goldenWithEval "Returns an uninstantiated type for :type +v, admitting multiple whitespaces around arguments" "T15" "hs"
, goldenWithEval "Returns defaulted type for :type +d, admitting multiple whitespaces around arguments" "T16" "hs"
, goldenWithEval' ":type reports an error when given with unknown +x option" "T17" "hs" (if ghcVersion >= GHC92 then "ghc92.expected" else "expected")
, goldenWithEval ":type reports an error when given with unknown +x option" "T17" "hs"
, goldenWithEval "Reports an error when given with unknown command" "T18" "hs"
, goldenWithEval "Returns defaulted type for :type +d reflecting the default declaration specified in the >>> prompt" "T19" "hs"
, expectFailBecause "known issue - see a note in P.R. #361" $
goldenWithEval' ":type +d reflects the `default' declaration of the module" "T20" "hs" (if ghcVersion >= GHC92 then "ghc92.expected" else "expected")
goldenWithEval ":type +d reflects the `default' declaration of the module" "T20" "hs"
, testCase ":type handles a multilined result properly" $
evalInFile "T21.hs" "-- >>> :type fun" $ T.unlines [
"-- fun",
Expand Down Expand Up @@ -125,13 +121,10 @@ tests =
, goldenWithEvalAndFs "Transitive local dependency" (FS.directProjectMulti ["TTransitive.hs", "TLocalImport.hs", "Util.hs"]) "TTransitive" "hs"
-- , goldenWithEval "Local Modules can be imported in a test" "TLocalImportInTest" "hs"
, goldenWithEval "Setting language option TupleSections" "TLanguageOptionsTupleSections" "hs"
, goldenWithEval' ":set accepts ghci flags" "TFlags" "hs" (if ghcVersion >= GHC98 then "ghc98.expected" else if ghcVersion >= GHC92 then "ghc92.expected" else "expected")
, goldenWithEval' ":set accepts ghci flags" "TFlags" "hs" (if ghcVersion >= GHC98 then "ghc98.expected" else "expected")
, testCase ":set -fprint-explicit-foralls works" $ do
evalInFile "T8.hs" "-- >>> :t id" "-- id :: a -> a"
evalInFile "T8.hs" "-- >>> :set -fprint-explicit-foralls\n-- >>> :t id"
(if ghcVersion >= GHC92
then "-- id :: forall a. a -> a"
else "-- id :: forall {a}. a -> a")
evalInFile "T8.hs" "-- >>> :set -fprint-explicit-foralls\n-- >>> :t id" "-- id :: forall a. a -> a"
, goldenWithEval "The default language extensions for the eval plugin are the same as those for ghci" "TSameDefaultLanguageExtensionsAsGhci" "hs"
, goldenWithEval "IO expressions are supported, stdout/stderr output is ignored" "TIO" "hs"
, goldenWithEvalAndFs "Property checking" cabalProjectFS "TProperty" "hs"
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-eval-plugin/test/testdata/T10.expected.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type Dummy = 1 + 1
-- >>> type N = 1
-- >>> type M = 40
-- >>> :kind! N + M + 1
-- N + M + 1 :: Nat
-- N + M + 1 :: Natural
-- = 42
11 changes: 0 additions & 11 deletions plugins/hls-eval-plugin/test/testdata/T10.ghc92.expected

This file was deleted.

11 changes: 0 additions & 11 deletions plugins/hls-eval-plugin/test/testdata/T10.ghc92.expected.hs

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/hls-eval-plugin/test/testdata/T11.expected.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T11 where

-- >>> :kind! A
-- Not in scope: type constructor or class ‘A’
-- Not in scope: type constructor or class `A'
2 changes: 1 addition & 1 deletion plugins/hls-eval-plugin/test/testdata/T12.expected.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ type Dummy = 1 + 1
-- >>> type N = 1
-- >>> type M = 40
-- >>> :kind N + M + 1
-- N + M + 1 :: Nat
-- N + M + 1 :: Natural
10 changes: 0 additions & 10 deletions plugins/hls-eval-plugin/test/testdata/T12.ghc92.expected.hs

This file was deleted.

10 changes: 0 additions & 10 deletions plugins/hls-eval-plugin/test/testdata/T12.ghc92_expected.hs

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/hls-eval-plugin/test/testdata/T13.expected.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T13 where

-- >>> :kind A
-- Not in scope: type constructor or class ‘A’
-- Not in scope: type constructor or class `A'
4 changes: 0 additions & 4 deletions plugins/hls-eval-plugin/test/testdata/T13.ghc92.expected.hs

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/hls-eval-plugin/test/testdata/T13.ghc92_expected.hs

This file was deleted.

8 changes: 0 additions & 8 deletions plugins/hls-eval-plugin/test/testdata/T15.ghc92_expected.hs

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/hls-eval-plugin/test/testdata/T17.expected.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module T17 where

-- >>> :type +no 42
-- parse error on input ‘+’
-- parse error on input `+'
4 changes: 0 additions & 4 deletions plugins/hls-eval-plugin/test/testdata/T17.ghc92.expected.hs

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/hls-eval-plugin/test/testdata/T17.ghc92_expected.hs

This file was deleted.

7 changes: 0 additions & 7 deletions plugins/hls-eval-plugin/test/testdata/T20.ghc92.expected.hs

This file was deleted.

7 changes: 0 additions & 7 deletions plugins/hls-eval-plugin/test/testdata/T20.ghc92_expected.hs

This file was deleted.

6 changes: 4 additions & 2 deletions plugins/hls-eval-plugin/test/testdata/TFlags.expected.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ module TFlags where
Options apply only in the section where they are defined (unless they are in the setup section), so this will fail:

>>> class L a b c
Too many parameters for class ‘L’
Too many parameters for class `L'
(Enable MultiParamTypeClasses to allow multi-parameter classes)
In the class declaration for `L'
-}


Expand All @@ -31,8 +32,9 @@ Options apply to all tests in the same section after their declaration.
Not set yet:

>>> class D
No parameters for class ‘D’
No parameters for class `D'
(Enable MultiParamTypeClasses to allow no-parameter classes)
In the class declaration for `D'

Now it works:

Expand Down