@@ -28,16 +28,21 @@ module Test.Hls
28
28
waitForTypecheck ,
29
29
waitForAction ,
30
30
sendConfigurationChanged ,
31
- getLastBuildKeys )
31
+ getLastBuildKeys ,
32
+ waitForKickDone ,
33
+ waitForKickStart ,
34
+ )
32
35
where
33
36
34
37
import Control.Applicative.Combinators
35
38
import Control.Concurrent.Async (async , cancel , wait )
36
39
import Control.Concurrent.Extra
37
40
import Control.Exception.Base
38
- import Control.Monad (unless , void )
41
+ import Control.Monad (guard , unless , void )
39
42
import Control.Monad.IO.Class
40
- import Data.Aeson (Value (Null ), toJSON )
43
+ import Data.Aeson (Result (Success ),
44
+ Value (Null ), fromJSON ,
45
+ toJSON )
41
46
import qualified Data.Aeson as A
42
47
import Data.ByteString.Lazy (ByteString )
43
48
import Data.Default (def )
@@ -247,3 +252,22 @@ getLastBuildKeys = callTestPlugin GetBuildKeysBuilt
247
252
sendConfigurationChanged :: Value -> Session ()
248
253
sendConfigurationChanged config =
249
254
sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams config)
255
+
256
+ waitForKickDone :: Session ()
257
+ waitForKickDone = void $ skipManyTill anyMessage nonTrivialKickDone
258
+
259
+ waitForKickStart :: Session ()
260
+ waitForKickStart = void $ skipManyTill anyMessage nonTrivialKickStart
261
+
262
+ nonTrivialKickDone :: Session ()
263
+ nonTrivialKickDone = kick " done" >>= guard . not . null
264
+
265
+ nonTrivialKickStart :: Session ()
266
+ nonTrivialKickStart = kick " start" >>= guard . not . null
267
+
268
+ kick :: T. Text -> Session [FilePath ]
269
+ kick msg = do
270
+ NotMess NotificationMessage {_params} <- customNotification $ " kick/" <> msg
271
+ case fromJSON _params of
272
+ Success x -> return x
273
+ other -> error $ " Failed to parse kick/done details: " <> show other
0 commit comments