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