Skip to content

Commit ecec015

Browse files
committed
Ported distributed-process-tests
1 parent e81b319 commit ecec015

File tree

10 files changed

+43
-76
lines changed

10 files changed

+43
-76
lines changed

packages/distributed-process-tests/distributed-process-tests.cabal

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ common warnings
3030
-Wredundant-constraints
3131
-fhide-source-paths
3232
-Wpartial-fields
33+
-Wunused-packages
3334

3435
library
3536
import: warnings
@@ -42,19 +43,16 @@ library
4243
Control.Distributed.Process.Tests.Tracing
4344
Control.Distributed.Process.Tests.Internal.Utils
4445
Build-Depends: base >= 4.14 && < 5,
45-
ansi-terminal >= 0.5,
4646
binary >= 0.8 && < 0.9,
4747
bytestring >= 0.10 && < 0.13,
4848
distributed-process >= 0.6.0 && < 0.8,
4949
distributed-static,
5050
exceptions >= 0.10,
51-
HUnit >= 1.2 && < 1.7,
5251
network-transport >= 0.4.1.0 && < 0.6,
53-
network >= 2.5 && < 3.3,
5452
random >= 1.0 && < 1.4,
5553
setenv >= 0.1.1.3,
56-
test-framework >= 0.6 && < 0.9,
57-
test-framework-hunit >= 0.2.0 && < 0.4,
54+
tasty >= 1.5 && <1.6,
55+
tasty-hunit >=0.10 && <0.11,
5856
stm
5957
hs-source-dirs: src
6058
default-language: Haskell98
@@ -76,10 +74,8 @@ Test-Suite TestCHInMemory
7674
CPP-Options: -DTEST_SUITE_MODULE=Control.Distributed.Process.Tests.CH
7775
Build-Depends: base >= 4.14 && < 5,
7876
distributed-process-tests,
79-
network >= 2.3 && < 3.3,
80-
network-transport >= 0.4.1.0 && < 0.6,
8177
network-transport-inmemory >= 0.5,
82-
test-framework >= 0.6 && < 0.9
78+
tasty >= 1.5 && <1.6,
8379
default-extensions: CPP
8480
default-language: Haskell98
8581
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
@@ -93,10 +89,9 @@ Test-Suite TestCHInTCP
9389
if flag(tcp)
9490
Build-Depends: base >= 4.14 && < 5,
9591
distributed-process-tests,
96-
network >= 2.5 && < 3.2,
97-
network-transport >= 0.4.1.0 && < 0.6,
92+
network >= 2.3 && < 3.3,
9893
network-transport-tcp >= 0.5 && < 0.9,
99-
test-framework >= 0.6 && < 0.9
94+
tasty >= 1.5 && <1.6,
10095
else
10196
Buildable: False
10297
default-extensions: CPP
@@ -112,10 +107,8 @@ Test-Suite TestClosure
112107
CPP-Options: -DTEST_SUITE_MODULE=Control.Distributed.Process.Tests.Closure
113108
Build-Depends: base >= 4.14 && < 5,
114109
distributed-process-tests,
115-
network >= 2.3 && < 3.3,
116-
network-transport >= 0.4.1.0 && < 0.6,
117110
network-transport-inmemory >= 0.5,
118-
test-framework >= 0.6 && < 0.9
111+
tasty >= 1.5 && <1.6,
119112
default-extensions: CPP
120113
default-language: Haskell98
121114
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
@@ -128,10 +121,8 @@ Test-Suite TestStats
128121
CPP-Options: -DTEST_SUITE_MODULE=Control.Distributed.Process.Tests.Stats
129122
Build-Depends: base >= 4.14 && < 5,
130123
distributed-process-tests,
131-
network >= 2.3 && < 3.3,
132-
network-transport >= 0.4.1.0 && < 0.6,
133124
network-transport-inmemory >= 0.5,
134-
test-framework >= 0.6 && < 0.9
125+
tasty >= 1.5 && <1.6,
135126
default-extensions: CPP
136127
default-language: Haskell98
137128
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
@@ -144,10 +135,8 @@ Test-Suite TestMxInMemory
144135
CPP-Options: -DTEST_SUITE_MODULE=Control.Distributed.Process.Tests.Mx
145136
Build-Depends: base >= 4.14 && < 5,
146137
distributed-process-tests,
147-
network >= 2.3 && < 3.3,
148-
network-transport >= 0.4.1.0 && < 0.6,
149138
network-transport-inmemory >= 0.5,
150-
test-framework >= 0.6 && < 0.9
139+
tasty >= 1.5 && <1.6,
151140
default-extensions: CPP
152141
default-language: Haskell98
153142
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
@@ -160,10 +149,8 @@ Test-Suite TestTracingInMemory
160149
CPP-Options: -DTEST_SUITE_MODULE=Control.Distributed.Process.Tests.Tracing
161150
Build-Depends: base >= 4.14 && < 5,
162151
distributed-process-tests,
163-
network >= 2.3 && < 3.3,
164-
network-transport >= 0.4.1.0 && < 0.6,
165152
network-transport-inmemory >= 0.5,
166-
test-framework >= 0.6 && < 0.9
153+
tasty >= 1.5 && <1.6,
167154
default-extensions: CPP
168155
default-language: Haskell98
169156
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
@@ -176,10 +163,8 @@ Test-Suite TestMxInTCP
176163
CPP-Options: -DTEST_SUITE_MODULE=Control.Distributed.Process.Tests.Mx
177164
Build-Depends: base >= 4.14 && < 5,
178165
distributed-process-tests,
179-
network >= 2.3 && < 3.3,
180-
network-transport >= 0.4.1.0 && < 0.6,
181166
network-transport-inmemory >= 0.5,
182-
test-framework >= 0.6 && < 0.9
167+
tasty >= 1.5 && <1.6,
183168
default-extensions: CPP
184169
default-language: Haskell98
185170
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/CH.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ import Control.Distributed.Process.Node
4242
import Control.Distributed.Process.Tests.Internal.Utils (pause)
4343
import Control.Distributed.Process.Serializable (Serializable)
4444
import Data.Maybe (isNothing, isJust)
45-
import Test.HUnit (Assertion, assertBool, assertEqual, assertFailure)
46-
import Test.Framework (Test, testGroup)
47-
import Test.Framework.Providers.HUnit (testCase)
45+
import Test.Tasty (TestTree, testGroup)
46+
import Test.Tasty.HUnit (Assertion, assertBool, assertEqual, testCase)
4847

4948
newtype Ping = Ping ProcessId
5049
deriving (Typeable, Binary, Show)
@@ -1770,8 +1769,8 @@ testCallLocal TestTransport{..} = do
17701769
takeMVar result4 >>= assertBool "Expected 'True'"
17711770
-- XXX: Testing that when mask_ $ callLocal p runs p in masked state.
17721771

1773-
tests :: TestTransport -> IO [Test]
1774-
tests testtrans = return [
1772+
tests :: TestTransport -> IO TestTree
1773+
tests testtrans = return $ testGroup "CH" [
17751774
testGroup "Basic features" [
17761775
testCase "Ping" (testPing testtrans)
17771776
, testCase "Math" (testMath testtrans)

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/Closure.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ import Control.Distributed.Process.Internal.Types
3131
import Control.Distributed.Static (staticLabel, staticClosure)
3232
import qualified Network.Transport as NT
3333

34-
import Test.HUnit (Assertion)
35-
import Test.Framework (Test)
36-
import Test.Framework.Providers.HUnit (testCase)
34+
import Test.Tasty (TestTree, testGroup)
35+
import Test.Tasty.HUnit (Assertion, testCase)
3736

3837
--------------------------------------------------------------------------------
3938
-- Supporting definitions --
@@ -563,10 +562,10 @@ testSpawnTerminate TestTransport{..} rtable = do
563562

564563
takeMVar masterDone
565564

566-
tests :: TestTransport -> IO [Test]
565+
tests :: TestTransport -> IO TestTree
567566
tests testtrans = do
568567
let rtable = __remoteTable . __remoteTableDecl $ initRemoteTable
569-
return
568+
return $ testGroup "Closure"
570569
[ testCase "Unclosure" (testUnclosure testtrans rtable)
571570
, testCase "Bind" (testBind testtrans rtable)
572571
, testCase "SendPureClosure" (testSendPureClosure testtrans rtable)

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/Internal/Utils.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ import Control.Monad.STM (atomically)
7979
import Data.Binary
8080
import Data.Typeable (Typeable)
8181

82-
import Test.HUnit (Assertion, assertFailure)
83-
import Test.HUnit.Base (assertBool)
82+
import Test.Tasty.HUnit (Assertion, assertBool)
8483

8584
import GHC.Generics
8685
import System.Timeout (timeout)

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/Mx.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,8 @@ import Data.Maybe (isJust, fromJust, isNothing, fromMaybe, catMaybes)
4141
import Data.Typeable
4242
import GHC.Generics hiding (from)
4343

44-
import Test.Framework
45-
( Test
46-
, testGroup
47-
)
48-
import Test.Framework.Providers.HUnit (testCase)
49-
import Test.HUnit (assertBool, assertEqual)
44+
import Test.Tasty (TestTree, testGroup)
45+
import Test.Tasty.HUnit (assertBool, assertEqual, testCase)
5046

5147
data Publish = Publish
5248
deriving (Typeable, Generic, Eq)
@@ -461,11 +457,11 @@ testMxSend mNode label test = do
461457
send p' s
462458
return r
463459

464-
tests :: TestTransport -> IO [Test]
460+
tests :: TestTransport -> IO TestTree
465461
tests TestTransport{..} = do
466462
node1 <- newLocalNode testTransport initRemoteTable
467463
node2 <- newLocalNode testTransport initRemoteTable
468-
return [
464+
return $ testGroup "Mx" [
469465
testGroup "MxAgents" [
470466
testCase "EventHandling"
471467
(delayedAssertion
@@ -527,7 +523,7 @@ tests TestTransport{..} = do
527523
build :: LocalNode
528524
-> LocalNode
529525
-> [(String, [(String, (Maybe LocalNode -> Process ()))])]
530-
-> [Test]
526+
-> [TestTree]
531527
build n ln specs =
532528
[ testGroup (intercalate "-" [groupName, caseSuffix]) [
533529
testCase (intercalate "-" [caseName, caseSuffix])

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/Receive.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import Control.Distributed.Process.Node
1414

1515
import Control.Monad
1616

17-
import Test.HUnit (Assertion, (@?=))
18-
import Test.Framework (Test)
19-
import Test.Framework.Providers.HUnit (testCase)
17+
import Test.Tasty (TestTree, testGroup)
18+
import Test.Tasty.HUnit (Assertion, (@?=), testCase)
2019

2120
-- Tests:
2221

@@ -147,8 +146,8 @@ testReceive transport rtable = do
147146
node <- newLocalNode transport rtable
148147
runProcess node $ master
149148

150-
tests :: TestTransport -> IO [Test]
149+
tests :: TestTransport -> IO TestTree
151150
tests TestTransport{..} = do
152151
let rtable = initRemoteTable
153-
return
152+
return $ testGroup "Receive"
154153
[ testCase "testReceive" (testReceive testTransport rtable) ]

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/Stats.hs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ import Control.Distributed.Process.Node
1616
import Data.Binary ()
1717
import Data.Typeable ()
1818

19-
import Test.Framework
20-
( Test
21-
, testGroup
22-
)
23-
import Test.HUnit (Assertion)
24-
import Test.Framework.Providers.HUnit (testCase)
19+
import Test.Tasty (TestTree, testGroup)
20+
import Test.Tasty.HUnit (Assertion, testCase)
2521

2622
testLocalDeadProcessInfo :: TestResult (Maybe ProcessInfo) -> Process ()
2723
testLocalDeadProcessInfo result = do
@@ -107,10 +103,10 @@ testRemoteLiveProcessInfo TestTransport{..} node1 = do
107103
a <- delayedAssertion "getProcessInfo remotePid failed" n True
108104
return a
109105

110-
tests :: TestTransport -> IO [Test]
106+
tests :: TestTransport -> IO TestTree
111107
tests testtrans@TestTransport{..} = do
112108
node1 <- newLocalNode testTransport initRemoteTable
113-
return [
109+
return $ testGroup "Stats" [
114110
testGroup "Process Info" [
115111
testCase "testLocalDeadProcessInfo"
116112
(delayedAssertion

packages/distributed-process-tests/src/Control/Distributed/Process/Tests/Tracing.hs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ import Data.List (isPrefixOf, isSuffixOf)
2525

2626
import Prelude hiding ((<*))
2727

28-
import Test.Framework
29-
( Test
30-
, testGroup
31-
)
32-
import Test.Framework.Providers.HUnit (testCase)
28+
import Test.Tasty (TestTree, testGroup)
29+
import Test.Tasty.HUnit ( testCase)
3330
import System.Environment (getEnvironment)
3431
-- These are available in System.Environment only since base 4.7
3532
import System.SetEnv (setEnv, unsetEnv)
@@ -375,14 +372,14 @@ testSystemLoggerMxUnRegistered t = testSystemLoggerMsg t
375372
(getSelfPid >>= register "a" >> unregister "a" >> getSelfPid)
376373
(\self -> isPrefixOf $ "MxUnRegistered " ++ show self ++ " " ++ show "a")
377374

378-
tests :: TestTransport -> IO [Test]
375+
tests :: TestTransport -> IO TestTree
379376
tests testtrans@TestTransport{..} = do
380377
node1 <- newLocalNode testTransport initRemoteTable
381378
-- if we execute the test cases in parallel, the
382379
-- various tracers will race with one another and
383380
-- we'll get garbage results (or worse, deadlocks)
384381
lock <- liftIO $ newMVar ()
385-
return [
382+
return $ testGroup "Tracing" [
386383
testGroup "Tracing" [
387384
testCase "Spawn Tracing"
388385
(synchronisedAssertion

packages/distributed-process-tests/tests/runInMemory.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import TEST_SUITE_MODULE (tests)
66

77
import Network.Transport.Test (TestTransport(..))
88
import Network.Transport.InMemory
9-
import Test.Framework (defaultMainWithArgs)
10-
11-
import System.Environment (getArgs)
9+
import Test.Tasty (defaultMain, localOption)
10+
import Test.Tasty.Runners (NumThreads)
1211

1312
main :: IO ()
1413
main = do
@@ -17,7 +16,6 @@ main = do
1716
{ testTransport = transport
1817
, testBreakConnection = \addr1 addr2 -> breakConnection internals addr1 addr2 "user error"
1918
}
20-
args <- getArgs
2119
-- Tests are time sensitive. Running the tests concurrently can slow them
2220
-- down enough that threads using threadDelay would wake up later than
2321
-- expected, thus changing the order in which messages were expected.
@@ -27,4 +25,4 @@ main = do
2725
-- The problem was first detected with
2826
-- 'Control.Distributed.Process.Tests.CH.testMergeChannels'
2927
-- in particular.
30-
defaultMainWithArgs ts ("-j" : "1" : args)
28+
defaultMain (localOption (1::NumThreads) ts)

packages/distributed-process-tests/tests/runTCP.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import Network.Transport.TCP
1313
, defaultTCPAddr
1414
, TCPParameters(..)
1515
)
16-
import Test.Framework (defaultMainWithArgs)
16+
import Test.Tasty (defaultMain, localOption)
17+
import Test.Tasty.Runners (NumThreads)
1718

1819
import Control.Concurrent (threadDelay)
1920
import Control.Exception (IOException, try)
20-
import System.Environment (getArgs)
2121
import System.IO
2222

2323
main :: IO ()
@@ -34,7 +34,6 @@ main = do
3434
either (\e -> const (return ()) (e :: IOException)) close esock
3535
threadDelay 10000
3636
}
37-
args <- getArgs
3837
-- Tests are time sensitive. Running the tests concurrently can slow them
3938
-- down enough that threads using threadDelay would wake up later than
4039
-- expected, thus changing the order in which messages were expected.
@@ -44,4 +43,4 @@ main = do
4443
-- The problem was first detected with
4544
-- 'Control.Distributed.Process.Tests.CH.testMergeChannels'
4645
-- in particular.
47-
defaultMainWithArgs ts ("-j" : "1" : args)
46+
defaultMain (localOption (1::NumThreads) ts)

0 commit comments

Comments
 (0)