Skip to content

Commit 5d98805

Browse files
committed
distributed-process-fsm has been merged into the Cloud Haskell monorepo
This includes updating the test suite to use Tasty (rather than test-framework), and updating dependency bounds
1 parent 401c9d0 commit 5d98805

File tree

2 files changed

+68
-97
lines changed

2 files changed

+68
-97
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,64 @@
1+
cabal-version: 3.0
12
name: distributed-process-fsm
2-
version: 0.0.1
3-
cabal-version: >=1.8
3+
version: 0.0.2
44
build-type: Simple
5-
license: BSD3
5+
license: BSD-3-Clause
66
license-file: LICENCE
77
Copyright: Tim Watson 2017
88
Author: Tim Watson
9-
Maintainer: Tim Watson <[email protected]>
9+
Maintainer: The Haskell Distributed team
1010
Stability: experimental
1111
Homepage: http://github.com/haskell-distributed/distributed-process-fsm
1212
Bug-Reports: http://github.com/haskell-distributed/distributed-process-fsm/issues
1313
synopsis: The Cloud Haskell implementation of Erlang/OTP gen_statem
1414
description: Cloud Haskell framework for building finite state machines around CSPs
1515
category: Control
16-
Tested-With: GHC==7.10.3 GHC==8.0.1 GHC==8.0.2
17-
data-dir: ""
16+
Tested-With: GHC==8.10.7 GHC==9.0.2 GHC==9.2.8 GHC==9.4.5 GHC==9.6.4 GHC==9.8.2 GHC==9.10.1 GHC==9.12.1
1817

1918
source-repository head
2019
type: git
21-
location: https://github.com/haskell-distributed/distributed-process-fsm
20+
location: https://github.com/haskell-distributed/distributed-process
21+
22+
common warnings
23+
ghc-options: -Wall
24+
-Wcompat
25+
-Widentities
26+
-Wincomplete-uni-patterns
27+
-Wincomplete-record-updates
28+
-Wredundant-constraints
29+
-fhide-source-paths
30+
-Wpartial-fields
31+
-Wunused-packages
2232

2333
library
24-
build-depends:
25-
base >= 4.8.2.0 && < 5,
26-
distributed-process >= 0.6.6 && < 0.8,
27-
distributed-process-extras >= 0.3.1 && < 0.4,
28-
distributed-process-client-server >= 0.2.5.1 && < 0.3,
29-
binary >= 0.6.3.0 && < 0.9,
30-
deepseq >= 1.3.0.1 && < 1.6,
31-
mtl,
32-
containers >= 0.4 && < 0.6,
33-
unordered-containers >= 0.2.3.0 && < 0.3,
34-
stm >= 2.4 && < 2.5,
35-
time > 1.4 && < 1.9,
36-
transformers,
37-
exceptions >= 0.5 && < 11
38-
extensions: CPP
39-
hs-source-dirs: src
40-
ghc-options: -Wall
41-
exposed-modules:
42-
Control.Distributed.Process.FSM,
43-
Control.Distributed.Process.FSM.Client,
44-
Control.Distributed.Process.FSM.Internal.Types,
45-
Control.Distributed.Process.FSM.Internal.Process
34+
import: warnings
35+
default-language: Haskell2010
36+
build-depends: base >= 4.14 && < 5,
37+
distributed-process >= 0.6.6 && < 0.8,
38+
distributed-process-extras >= 0.3.1 && < 0.4,
39+
distributed-process-client-server >= 0.2.5.1 && < 0.3,
40+
binary >= 0.8 && < 0.10,
41+
mtl >= 2.0 && <2.4,
42+
containers >= 0.4 && < 0.8,
43+
exceptions >= 0.10
44+
hs-source-dirs: src
45+
exposed-modules: Control.Distributed.Process.FSM,
46+
Control.Distributed.Process.FSM.Client,
47+
Control.Distributed.Process.FSM.Internal.Types,
48+
Control.Distributed.Process.FSM.Internal.Process
4649

4750
test-suite FsmTests
48-
type: exitcode-stdio-1.0
49-
-- x-uses-tf: true
50-
build-depends:
51-
base >= 4.4 && < 5,
52-
ansi-terminal >= 0.5 && < 0.7,
53-
network >= 2.3 && < 2.7,
54-
network-transport >= 0.4 && < 0.6,
55-
network-transport-tcp >= 0.4 && < 0.7,
56-
distributed-process >= 0.6.6 && < 0.8,
57-
distributed-process-extras >= 0.3.1 && < 0.4,
58-
distributed-process-client-server >= 0.2.5.1 && < 0.3,
59-
distributed-process-fsm,
60-
distributed-process-systest >= 0.1.1 && < 0.3,
61-
distributed-static,
62-
binary >= 0.6.3.0 && < 0.9,
63-
bytestring,
64-
containers,
65-
data-accessor,
66-
deepseq >= 1.3.0.1 && < 1.5,
67-
fingertree < 0.2,
68-
hashable,
69-
mtl,
70-
stm >= 2.3 && < 2.5,
71-
time,
72-
transformers,
73-
unordered-containers >= 0.2.3.0 && < 0.3,
74-
test-framework >= 0.6 && < 0.9,
75-
test-framework-hunit,
76-
QuickCheck >= 2.4,
77-
test-framework-quickcheck2,
78-
HUnit >= 1.2 && < 2,
79-
rematch >= 0.2.0.0,
80-
ghc-prim
81-
hs-source-dirs:
82-
tests
83-
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind -eventlog
84-
extensions: CPP
85-
main-is: TestFSM.hs
51+
import: warnings
52+
type: exitcode-stdio-1.0
53+
build-depends: base >= 4.14 && < 5,
54+
network-transport >= 0.4 && < 0.6,
55+
network-transport-tcp >= 0.4 && <= 0.9,
56+
distributed-process >= 0.6.6 && < 0.8,
57+
distributed-process-extras >= 0.3.1 && < 0.4,
58+
distributed-process-fsm,
59+
binary,
60+
tasty >= 1.5 && <1.6,
61+
tasty-hunit >=0.10 && <0.11,
62+
hs-source-dirs: tests
63+
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
64+
main-is: TestFSM.hs

packages/distributed-process-fsm/tests/TestFSM.hs

+22-30
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ import Control.Distributed.Process.Extras.Time hiding (timeout)
1818
import Control.Distributed.Process.Extras.Timer
1919
import Control.Distributed.Process.FSM hiding (State, liftIO)
2020
import Control.Distributed.Process.FSM.Client (call, callTimeout)
21-
import Control.Distributed.Process.SysTest.Utils
2221
import Control.Monad (replicateM_, forM_)
23-
import Control.Rematch (equalTo)
2422

25-
#if ! MIN_VERSION_base(4,6,0)
26-
import Prelude hiding (catch, drop)
27-
#else
2823
import Prelude hiding (drop, (*>))
29-
#endif
3024

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)
3328

3429
import Network.Transport.TCP
3530
import qualified Network.Transport as NT
@@ -154,7 +149,7 @@ republicationOfEvents = do
154149
send pid "hello" -- triggers `nextEvent ()`
155150

156151
res <- receiveChanTimeout (asTimeout $ seconds 5) rp :: Process (Maybe ())
157-
res `shouldBe` equalTo (Just ())
152+
liftIO $ assertEqual mempty (Just ()) res
158153

159154
send pid Off
160155

@@ -163,7 +158,7 @@ republicationOfEvents = do
163158
send pid On
164159

165160
res' <- receiveChanTimeout (asTimeout $ seconds 20) rp :: Process (Maybe ())
166-
res' `shouldBe` equalTo (Just ())
161+
liftIO $ assertEqual mempty (Just ()) res
167162

168163
kill pid "thankyou byebye"
169164

@@ -180,15 +175,15 @@ verifyOuterStateHandler = do
180175
() <- receiveChan rpOn
181176

182177
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
184179

185180
send pid Off
186181
send pid ()
187182
Nothing <- receiveChanTimeout (asTimeout $ seconds 3) rpOn
188183
() <- receiveChan rpOff
189184

190185
res <- call pid "hello" :: Process String
191-
res `shouldBe` equalTo "hello"
186+
liftIO $ assertEqual mempty "hello" res
192187

193188
kill pid "bye bye"
194189

@@ -202,7 +197,7 @@ verifyMailboxHandling = do
202197

203198
sleep $ seconds 5
204199
alive <- isProcessAlive pid
205-
alive `shouldBe` equalTo True
200+
liftIO $ assertBool mempty alive
206201

207202
-- we should resume after the ExitNormal handler runs, and get back into the ()
208203
-- handler due to safeWait (*>) which adds a `safe` filter check for the given type
@@ -211,18 +206,18 @@ verifyMailboxHandling = do
211206
exit pid ExitShutdown
212207
monitor pid >>= waitForDown
213208
alive' <- isProcessAlive pid
214-
alive' `shouldBe` equalTo False
209+
liftIO $ assertBool mempty (not alive')
215210

216211
verifyStopBehaviour :: Process ()
217212
verifyStopBehaviour = do
218213
pid <- start Off initCount switchFsm
219214
alive <- isProcessAlive pid
220-
alive `shouldBe` equalTo True
215+
liftIO $ assertBool mempty alive
221216

222217
exit pid $ ExitOther "foobar"
223218
monitor pid >>= waitForDown
224219
alive' <- isProcessAlive pid
225-
alive' `shouldBe` equalTo False
220+
liftIO $ assertBool mempty (not alive')
226221

227222
notSoQuirkyDefinitions :: Process ()
228223
notSoQuirkyDefinitions = do
@@ -235,41 +230,40 @@ quirkyOperators = do
235230
walkingAnFsmTree :: ProcessId -> Process ()
236231
walkingAnFsmTree pid = do
237232
mSt <- pushButton pid
238-
mSt `shouldBe` equalTo On
233+
liftIO $ assertEqual mempty On mSt
239234

240235
mSt' <- pushButton pid
241-
mSt' `shouldBe` equalTo Off
236+
liftIO $ assertEqual mempty Off mSt'
242237

243238
mCk <- check pid
244-
mCk `shouldBe` equalTo (2 :: StateData)
239+
liftIO $ assertEqual mempty (2 :: StateData) mCk
245240

246241
-- verify that the process implementation turns exit signals into handlers...
247242
exit pid ExitNormal
248243
sleep $ seconds 6
249244
alive <- isProcessAlive pid
250-
alive `shouldBe` equalTo True
245+
liftIO $ assertBool mempty alive
251246

252247
mCk2 <- check pid
253-
mCk2 `shouldBe` equalTo (0 :: StateData)
248+
liftIO $ assertEqual mempty (0 :: StateData) mCk2
254249

255250
mrst' <- pushButton pid
256-
mrst' `shouldBe` equalTo On
251+
liftIO $ assertEqual mempty On mrst'
257252

258253
exit pid ExitShutdown
259254
monitor pid >>= waitForDown
260255
alive' <- isProcessAlive pid
261-
alive' `shouldBe` equalTo False
256+
liftIO $ assertBool mempty (not alive')
262257

263258
myRemoteTable :: RemoteTable
264259
myRemoteTable =
265260
Control.Distributed.Process.Extras.__remoteTable $ initRemoteTable
266261

267-
tests :: NT.Transport -> IO [Test]
262+
tests :: NT.Transport -> IO TestTree
268263
tests transport = do
269264
{- verboseCheckWithResult stdArgs -}
270265
localNode <- newLocalNode transport myRemoteTable
271-
return [
272-
testGroup "Language/DSL"
266+
return $ testGroup "Language/DSL"
273267
[
274268
testCase "Traversing an FSM definition (operators)"
275269
(runProcess localNode quirkyOperators)
@@ -284,15 +278,13 @@ tests transport = do
284278
, testCase "Traversing an FSM definition (event re-publication)"
285279
(runProcess localNode republicationOfEvents)
286280
]
287-
]
288281

289282
main :: IO ()
290283
main = testMain $ tests
291284

292285
-- | 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 ()
294287
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
297289
testData <- builder transport
298290
defaultMain testData

0 commit comments

Comments
 (0)