1
1
module Main where
2
2
3
+ import Control.Monad (void )
3
4
import Data.Either (rights )
4
5
import Data.Text (Text )
5
6
import qualified Data.Text as T
6
7
import qualified Data.Text.IO as TIO
7
8
import Ide.Plugin.ChangeTypeSignature (errorMessageRegexes )
8
9
import qualified Ide.Plugin.ChangeTypeSignature as ChangeTypeSignature
9
10
import System.FilePath ((<.>) , (</>) )
10
- import Test.Hls (CodeAction (.. ),
11
- CodeActionKind (CodeActionQuickFix ),
12
- Command , IdeState ,
11
+ import Test.Hls (CodeAction (.. ), Command ,
12
+ GhcVersion (GHC92 ), IdeState ,
13
13
PluginDescriptor ,
14
14
Position (Position ),
15
15
Range (Range ), Session ,
16
16
TestName , TestTree ,
17
17
TextDocumentIdentifier ,
18
- assertBool , assertFailure ,
18
+ assertFailure ,
19
19
defaultTestRunner ,
20
20
executeCodeAction ,
21
21
getCodeActions ,
22
- goldenWithHaskellDoc , liftIO ,
23
- openDoc , runSessionWithServer ,
24
- testCase , testGroup , toEither ,
25
- type ( |? ) ( InR ) ,
26
- waitForDiagnostics ,
27
- waitForProgressDone , (@=?) ,
28
- (@?=) )
22
+ goldenWithHaskellDoc ,
23
+ knownBrokenForGhcVersions ,
24
+ liftIO , openDoc ,
25
+ runSessionWithServer , testCase ,
26
+ testGroup , toEither , type ( |? ) ,
27
+ waitForAllProgressDone ,
28
+ waitForDiagnostics , (@?=) )
29
29
import Text.Regex.TDFA ((=~) )
30
30
31
31
main :: IO ()
@@ -36,23 +36,21 @@ changeTypeSignaturePlugin = ChangeTypeSignature.descriptor "changeTypeSignature"
36
36
37
37
test :: TestTree
38
38
test = testGroup " changeTypeSignature" [
39
- codeActionTest " TExpectedActual" 4 11
40
- , codeActionTest " TRigidType" 4 14
41
- , codeActionTest " TLocalBinding" 6 21
42
- , codeActionTest " TLocalBindingShadow1" 10 7
43
- , codeActionTest " TLocalBindingShadow2" 6 21
39
+ testRegexes
40
+ , codeActionTest " TExpectedActual" 4 11
41
+ , knownBrokenForGhcVersions [GHC92 ] " Error Message in 9.2 does not provide enough info" $ codeActionTest " TRigidType" 4 14
42
+ , codeActionTest " TLocalBinding" 7 22
43
+ , codeActionTest " TLocalBindingShadow1" 11 8
44
+ , codeActionTest " TLocalBindingShadow2" 7 22
44
45
, codeActionProperties " TErrorGivenPartialSignature" [(4 , 13 )] $ \ actions -> liftIO $ length actions @?= 0
45
- , testRegexes
46
46
]
47
47
48
48
testRegexes :: TestTree
49
49
testRegexes = testGroup " Regex Testing" [
50
50
testRegexOne
51
51
, testRegexTwo
52
+ , testRegex921One
52
53
]
53
- where
54
- regex1 = errorMessageRegexes !! 0
55
- regex2 = errorMessageRegexes !! 1
56
54
57
55
testRegexOne :: TestTree
58
56
testRegexOne = testGroup " Regex One" [
@@ -76,6 +74,16 @@ testRegexTwo = testGroup "Regex Two" [
76
74
where
77
75
regex = errorMessageRegexes !! 1
78
76
77
+ -- test ghc-9.2.1 error message regex
78
+ testRegex921One :: TestTree
79
+ testRegex921One = testGroup " Regex One" [
80
+ regexTest " ghc921-error1.txt" regex True
81
+ , regexTest " ghc921-error2.txt" regex True
82
+ , regexTest " ghc921-error3.txt" regex True
83
+ ]
84
+ where
85
+ regex = errorMessageRegexes !! 2
86
+
79
87
testDataDir :: FilePath
80
88
testDataDir = " test" </> " testdata"
81
89
@@ -84,7 +92,8 @@ goldenChangeSignature fp = goldenWithHaskellDoc changeTypeSignaturePlugin (fp <>
84
92
85
93
codeActionTest :: FilePath -> Int -> Int -> TestTree
86
94
codeActionTest fp line col = goldenChangeSignature fp $ \ doc -> do
87
- waitForDiagnostics -- code actions are triggered from Diagnostics
95
+ void $ waitForDiagnostics -- code actions are triggered from Diagnostics
96
+ void $ waitForAllProgressDone -- apparently some tests need this to get the CodeAction to show up
88
97
actions <- getCodeActions doc (pointRange line col)
89
98
foundActions <- findChangeTypeActions actions
90
99
liftIO $ length foundActions @?= 1
0 commit comments