@@ -8,24 +8,29 @@ module Main
8
8
( main
9
9
) where
10
10
11
- import Control.Lens (Prism' , prism' , (^..) , (^?) )
12
- import Control.Monad (void )
13
- import qualified Ide.Plugin.Class as Class
14
- import qualified Language.LSP.Types.Lens as J
11
+ import Control.Lens (Prism' , prism' , (^..) , (^?) )
12
+ import Control.Monad (void )
13
+ import Data.Functor.Contravariant (contramap )
14
+ import Development.IDE.Types.Logger
15
+ import qualified Ide.Plugin.Class as Class
16
+ import qualified Language.LSP.Types.Lens as J
15
17
import System.FilePath
16
18
import Test.Hls
17
19
20
+
18
21
main :: IO ()
19
- main = defaultTestRunner tests
22
+ main = do
23
+ recorder <- makeDefaultStderrRecorder Nothing Debug
24
+ defaultTestRunner . tests $ contramap (fmap pretty) recorder
20
25
21
- classPlugin :: PluginDescriptor IdeState
22
- classPlugin = Class. descriptor " class"
26
+ classPlugin :: Recorder ( WithPriority Class. Log ) -> PluginDescriptor IdeState
27
+ classPlugin recorder = Class. descriptor recorder " class"
23
28
24
- tests :: TestTree
25
- tests = testGroup
29
+ tests :: Recorder ( WithPriority Class. Log ) -> TestTree
30
+ tests recorder = testGroup
26
31
" class"
27
32
[ testCase " Produces addMinimalMethodPlaceholders code actions for one instance" $ do
28
- runSessionWithServer classPlugin testDataDir $ do
33
+ runSessionWithServer ( classPlugin recorder) testDataDir $ do
29
34
doc <- openDoc " T1.hs" " haskell"
30
35
_ <- waitForDiagnosticsFromSource doc " typecheck"
31
36
caResults <- getAllCodeActions doc
@@ -34,23 +39,23 @@ tests = testGroup
34
39
[ Just " Add placeholders for '=='"
35
40
, Just " Add placeholders for '/='"
36
41
]
37
- , goldenWithClass " Creates a placeholder for '=='" " T1" " eq" $ \ (eqAction: _) -> do
42
+ , goldenWithClass recorder " Creates a placeholder for '=='" " T1" " eq" $ \ (eqAction: _) -> do
38
43
executeCodeAction eqAction
39
- , goldenWithClass " Creates a placeholder for '/='" " T1" " ne" $ \ (_: neAction: _) -> do
44
+ , goldenWithClass recorder " Creates a placeholder for '/='" " T1" " ne" $ \ (_: neAction: _) -> do
40
45
executeCodeAction neAction
41
- , goldenWithClass " Creates a placeholder for 'fmap'" " T2" " fmap" $ \ (_: _: fmapAction: _) -> do
46
+ , goldenWithClass recorder " Creates a placeholder for 'fmap'" " T2" " fmap" $ \ (_: _: fmapAction: _) -> do
42
47
executeCodeAction fmapAction
43
- , goldenWithClass " Creates a placeholder for multiple methods 1" " T3" " 1" $ \ (mmAction: _) -> do
48
+ , goldenWithClass recorder " Creates a placeholder for multiple methods 1" " T3" " 1" $ \ (mmAction: _) -> do
44
49
executeCodeAction mmAction
45
- , goldenWithClass " Creates a placeholder for multiple methods 2" " T3" " 2" $ \ (_: mmAction: _) -> do
50
+ , goldenWithClass recorder " Creates a placeholder for multiple methods 2" " T3" " 2" $ \ (_: mmAction: _) -> do
46
51
executeCodeAction mmAction
47
- , goldenWithClass " Creates a placeholder for a method starting with '_'" " T4" " " $ \ (_fAction: _) -> do
52
+ , goldenWithClass recorder " Creates a placeholder for a method starting with '_'" " T4" " " $ \ (_fAction: _) -> do
48
53
executeCodeAction _fAction
49
- , goldenWithClass " Creates a placeholder for '==' with extra lines" " T5" " " $ \ (eqAction: _) -> do
54
+ , goldenWithClass recorder " Creates a placeholder for '==' with extra lines" " T5" " " $ \ (eqAction: _) -> do
50
55
executeCodeAction eqAction
51
- , goldenWithClass " Creates a placeholder for only the unimplemented methods of multiple methods" " T6" " 1" $ \ (gAction: _) -> do
56
+ , goldenWithClass recorder " Creates a placeholder for only the unimplemented methods of multiple methods" " T6" " 1" $ \ (gAction: _) -> do
52
57
executeCodeAction gAction
53
- , goldenWithClass " Creates a placeholder for other two multiple methods" " T6" " 2" $ \ (_: ghAction: _) -> do
58
+ , goldenWithClass recorder " Creates a placeholder for other two methods" " T6" " 2" $ \ (_: ghAction: _) -> do
54
59
executeCodeAction ghAction
55
60
]
56
61
@@ -59,9 +64,9 @@ _CACodeAction = prism' InR $ \case
59
64
InR action -> Just action
60
65
_ -> Nothing
61
66
62
- goldenWithClass :: TestName -> FilePath -> FilePath -> ([CodeAction ] -> Session () ) -> TestTree
63
- goldenWithClass title path desc act =
64
- goldenWithHaskellDoc classPlugin title testDataDir path (desc <.> " expected" ) " hs" $ \ doc -> do
67
+ goldenWithClass :: Recorder ( WithPriority Class. Log ) -> TestName -> FilePath -> FilePath -> ([CodeAction ] -> Session () ) -> TestTree
68
+ goldenWithClass recorder title path desc act =
69
+ goldenWithHaskellDoc ( classPlugin recorder) title testDataDir path (desc <.> " expected" ) " hs" $ \ doc -> do
65
70
_ <- waitForDiagnosticsFromSource doc " typecheck"
66
71
actions <- concatMap (^.. _CACodeAction) <$> getAllCodeActions doc
67
72
act actions
0 commit comments