@@ -18,18 +18,13 @@ import Control.Distributed.Process.Extras.Time hiding (timeout)
18
18
import Control.Distributed.Process.Extras.Timer
19
19
import Control.Distributed.Process.FSM hiding (State , liftIO )
20
20
import Control.Distributed.Process.FSM.Client (call , callTimeout )
21
- import Control.Distributed.Process.SysTest.Utils
22
21
import Control.Monad (replicateM_ , forM_ )
23
- import Control.Rematch (equalTo )
24
22
25
- #if ! MIN_VERSION_base(4,6,0)
26
- import Prelude hiding (catch , drop )
27
- #else
28
23
import Prelude hiding (drop , (*>) )
29
- #endif
30
24
31
- import Test.Framework as TF (defaultMain , testGroup , Test )
32
- import Test.Framework.Providers.HUnit
25
+
26
+ import Test.Tasty (TestTree , testGroup , defaultMain )
27
+ import Test.Tasty.HUnit (testCase , assertEqual , assertBool )
33
28
34
29
import Network.Transport.TCP
35
30
import qualified Network.Transport as NT
@@ -154,7 +149,7 @@ republicationOfEvents = do
154
149
send pid " hello" -- triggers `nextEvent ()`
155
150
156
151
res <- receiveChanTimeout (asTimeout $ seconds 5 ) rp :: Process (Maybe () )
157
- res `shouldBe` equalTo (Just () )
152
+ liftIO $ assertEqual mempty (Just () ) res
158
153
159
154
send pid Off
160
155
@@ -163,7 +158,7 @@ republicationOfEvents = do
163
158
send pid On
164
159
165
160
res' <- receiveChanTimeout (asTimeout $ seconds 20 ) rp :: Process (Maybe () )
166
- res' `shouldBe` equalTo (Just () )
161
+ liftIO $ assertEqual mempty (Just () ) res
167
162
168
163
kill pid " thankyou byebye"
169
164
@@ -180,15 +175,15 @@ verifyOuterStateHandler = do
180
175
() <- receiveChan rpOn
181
176
182
177
resp <- callTimeout pid " hello there" (seconds 3 ):: Process (Maybe String )
183
- resp `shouldBe` equalTo (Nothing :: Maybe String )
178
+ liftIO $ assertEqual mempty (Nothing :: Maybe String ) resp
184
179
185
180
send pid Off
186
181
send pid ()
187
182
Nothing <- receiveChanTimeout (asTimeout $ seconds 3 ) rpOn
188
183
() <- receiveChan rpOff
189
184
190
185
res <- call pid " hello" :: Process String
191
- res `shouldBe` equalTo " hello"
186
+ liftIO $ assertEqual mempty " hello" res
192
187
193
188
kill pid " bye bye"
194
189
@@ -202,7 +197,7 @@ verifyMailboxHandling = do
202
197
203
198
sleep $ seconds 5
204
199
alive <- isProcessAlive pid
205
- alive `shouldBe` equalTo True
200
+ liftIO $ assertBool mempty alive
206
201
207
202
-- we should resume after the ExitNormal handler runs, and get back into the ()
208
203
-- handler due to safeWait (*>) which adds a `safe` filter check for the given type
@@ -211,18 +206,18 @@ verifyMailboxHandling = do
211
206
exit pid ExitShutdown
212
207
monitor pid >>= waitForDown
213
208
alive' <- isProcessAlive pid
214
- alive' `shouldBe` equalTo False
209
+ liftIO $ assertBool mempty ( not alive')
215
210
216
211
verifyStopBehaviour :: Process ()
217
212
verifyStopBehaviour = do
218
213
pid <- start Off initCount switchFsm
219
214
alive <- isProcessAlive pid
220
- alive `shouldBe` equalTo True
215
+ liftIO $ assertBool mempty alive
221
216
222
217
exit pid $ ExitOther " foobar"
223
218
monitor pid >>= waitForDown
224
219
alive' <- isProcessAlive pid
225
- alive' `shouldBe` equalTo False
220
+ liftIO $ assertBool mempty ( not alive')
226
221
227
222
notSoQuirkyDefinitions :: Process ()
228
223
notSoQuirkyDefinitions = do
@@ -235,41 +230,40 @@ quirkyOperators = do
235
230
walkingAnFsmTree :: ProcessId -> Process ()
236
231
walkingAnFsmTree pid = do
237
232
mSt <- pushButton pid
238
- mSt `shouldBe` equalTo On
233
+ liftIO $ assertEqual mempty On mSt
239
234
240
235
mSt' <- pushButton pid
241
- mSt' `shouldBe` equalTo Off
236
+ liftIO $ assertEqual mempty Off mSt'
242
237
243
238
mCk <- check pid
244
- mCk `shouldBe` equalTo (2 :: StateData )
239
+ liftIO $ assertEqual mempty (2 :: StateData ) mCk
245
240
246
241
-- verify that the process implementation turns exit signals into handlers...
247
242
exit pid ExitNormal
248
243
sleep $ seconds 6
249
244
alive <- isProcessAlive pid
250
- alive `shouldBe` equalTo True
245
+ liftIO $ assertBool mempty alive
251
246
252
247
mCk2 <- check pid
253
- mCk2 `shouldBe` equalTo (0 :: StateData )
248
+ liftIO $ assertEqual mempty (0 :: StateData ) mCk2
254
249
255
250
mrst' <- pushButton pid
256
- mrst' `shouldBe` equalTo On
251
+ liftIO $ assertEqual mempty On mrst'
257
252
258
253
exit pid ExitShutdown
259
254
monitor pid >>= waitForDown
260
255
alive' <- isProcessAlive pid
261
- alive' `shouldBe` equalTo False
256
+ liftIO $ assertBool mempty ( not alive')
262
257
263
258
myRemoteTable :: RemoteTable
264
259
myRemoteTable =
265
260
Control.Distributed.Process.Extras. __remoteTable $ initRemoteTable
266
261
267
- tests :: NT. Transport -> IO [ Test ]
262
+ tests :: NT. Transport -> IO TestTree
268
263
tests transport = do
269
264
{- verboseCheckWithResult stdArgs -}
270
265
localNode <- newLocalNode transport myRemoteTable
271
- return [
272
- testGroup " Language/DSL"
266
+ return $ testGroup " Language/DSL"
273
267
[
274
268
testCase " Traversing an FSM definition (operators)"
275
269
(runProcess localNode quirkyOperators)
@@ -284,15 +278,13 @@ tests transport = do
284
278
, testCase " Traversing an FSM definition (event re-publication)"
285
279
(runProcess localNode republicationOfEvents)
286
280
]
287
- ]
288
281
289
282
main :: IO ()
290
283
main = testMain $ tests
291
284
292
285
-- | Given a @builder@ function, make and run a test suite on a single transport
293
- testMain :: (NT. Transport -> IO [ Test ] ) -> IO ()
286
+ testMain :: (NT. Transport -> IO TestTree ) -> IO ()
294
287
testMain builder = do
295
- Right (transport, _) <- createTransportExposeInternals
296
- " 127.0.0.1" " 0" (" 127.0.0.1" ,) defaultTCPParameters
288
+ Right (transport, _) <- createTransportExposeInternals (defaultTCPAddr " 127.0.0.1" " 0" ) defaultTCPParameters
297
289
testData <- builder transport
298
290
defaultMain testData
0 commit comments