Skip to content

Commit 90a62bb

Browse files
committed
Remove usage of deprecated functions
1 parent 22f19ff commit 90a62bb

File tree

4 files changed

+40
-39
lines changed

4 files changed

+40
-39
lines changed

distributed-process-tests.cabal

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ library
3030
bytestring >= 0.9 && < 0.13,
3131
distributed-process >= 0.5.3 && < 0.8,
3232
distributed-static,
33+
exceptions >=0.10 && <0.11,
3334
HUnit >= 1.2 && < 1.7,
3435
network-transport >= 0.4.1.0 && < 0.6,
3536
network >= 2.5 && < 3.3,
@@ -46,7 +47,6 @@ library
4647
DeriveDataTypeable,
4748
DeriveGeneric,
4849
GeneralizedNewtypeDeriving,
49-
OverlappingInstances,
5050
RankNTypes,
5151
RecordWildCards,
5252
ScopedTypeVariables
@@ -64,7 +64,7 @@ Test-Suite TestCHInMemory
6464
network-transport-inmemory >= 0.5,
6565
test-framework >= 0.6 && < 0.9
6666
Extensions: CPP
67-
ghc-options: -Wall -threaded -debug -eventlog -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
67+
ghc-options: -Wall -threaded -debug -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
6868
HS-Source-Dirs: tests
6969

7070
Test-Suite TestCHInTCP
@@ -81,7 +81,7 @@ Test-Suite TestCHInTCP
8181
else
8282
Buildable: False
8383
Extensions: CPP
84-
ghc-options: -Wall -threaded -debug -eventlog -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
84+
ghc-options: -Wall -threaded -debug -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
8585
HS-Source-Dirs: tests
8686

8787

@@ -110,7 +110,7 @@ Test-Suite TestStats
110110
network-transport-inmemory >= 0.5,
111111
test-framework >= 0.6 && < 0.9
112112
Extensions: CPP
113-
ghc-options: -Wall -debug -eventlog -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
113+
ghc-options: -Wall -debug -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
114114
HS-Source-Dirs: tests
115115

116116

@@ -139,5 +139,5 @@ Test-Suite TestTracing
139139
network-transport-inmemory >= 0.5,
140140
test-framework >= 0.6 && < 0.9
141141
Extensions: CPP
142-
ghc-options: -Wall -debug -eventlog -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
142+
ghc-options: -Wall -debug -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
143143
HS-Source-Dirs: tests

src/Control/Distributed/Process/Tests/CH.hs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import Control.Concurrent.MVar
2323
, readMVar
2424
)
2525
import Control.Monad (replicateM_, replicateM, forever, void, unless, join)
26+
import Control.Monad.Catch as Ex (catch, finally, mask, onException, try)
2627
import Control.Exception (SomeException, throwIO, ErrorCall(..))
27-
import qualified Control.Exception as Ex (catch)
2828
import Control.Applicative ((<$>), (<*>), pure, (<|>))
2929
import qualified Network.Transport as NT (closeEndPoint, EndPointAddress)
3030
import Control.Distributed.Process
@@ -145,19 +145,20 @@ monitorTestProcess :: ProcessId -- Process to monitor/link to
145145
-> MVar () -- Signal for successful termination
146146
-> Process ()
147147
monitorTestProcess theirAddr mOrL un reason monitorSetup done =
148-
catch (do mRef <- monitorOrLink mOrL theirAddr monitorSetup
149-
case (un, mRef) of
150-
(True, Nothing) -> do
151-
unlink theirAddr
152-
liftIO $ putMVar done ()
153-
(True, Just ref) -> do
154-
unmonitor ref
155-
liftIO $ putMVar done ()
156-
(False, ref) -> do
157-
ProcessMonitorNotification ref' pid reason' <- expect
158-
True <- return $ Just ref' == ref && pid == theirAddr && mOrL && reason == reason'
159-
liftIO $ putMVar done ()
160-
)
148+
Ex.catch (do
149+
mRef <- monitorOrLink mOrL theirAddr monitorSetup
150+
case (un, mRef) of
151+
(True, Nothing) -> do
152+
unlink theirAddr
153+
liftIO $ putMVar done ()
154+
(True, Just ref) -> do
155+
unmonitor ref
156+
liftIO $ putMVar done ()
157+
(False, ref) -> do
158+
ProcessMonitorNotification ref' pid reason' <- expect
159+
True <- return $ Just ref' == ref && pid == theirAddr && mOrL && reason == reason'
160+
liftIO $ putMVar done ()
161+
)
161162
(\(ProcessLinkException pid reason') -> do
162163
True <- return $ pid == theirAddr && not mOrL && not un && reason == reason'
163164
liftIO $ putMVar done ()
@@ -651,10 +652,10 @@ testRegistry TestTransport{..} = do
651652
nsend "ping" (Pong us)
652653
Ping pid' <- expect
653654
True <- return $ pingServer == pid'
654-
Left (ProcessRegistrationException "dead" Nothing) <- try $ register "dead" deadProcess
655-
Left (ProcessRegistrationException "ping" (Just x)) <- try $ register "ping" deadProcess
655+
Left (ProcessRegistrationException "dead" Nothing) <- Ex.try $ register "dead" deadProcess
656+
Left (ProcessRegistrationException "ping" (Just x)) <- Ex.try $ register "ping" deadProcess
656657
True <- return $ x == pingServer
657-
Left (ProcessRegistrationException "dead" Nothing) <- try $ unregister "dead"
658+
Left (ProcessRegistrationException "dead" Nothing) <- Ex.try $ unregister "dead"
658659
liftIO $ putMVar done ()
659660

660661
takeMVar done
@@ -777,7 +778,7 @@ testSpawnAsyncStrictness TestTransport{..} = do
777778
runProcess node $ do
778779
here <-getSelfNode
779780

780-
ev <- try $ spawnAsync here (error "boom")
781+
ev <- Ex.try $ spawnAsync here (error "boom")
781782
liftIO $ case ev of
782783
Right _ -> putMVar done (error "Exception didn't fire")
783784
Left (_::SomeException) -> putMVar done (return ())
@@ -868,7 +869,7 @@ testUSend usendPrim TestTransport{..} numMessages = do
868869
processA <- newEmptyMVar
869870
usendTestOk <- newEmptyMVar
870871

871-
forkProcess node1 $ flip catch (\e -> liftIO $ print (e :: SomeException) ) $ do
872+
forkProcess node1 $ flip Ex.catch (\e -> liftIO $ print (e :: SomeException) ) $ do
872873
us <- getSelfPid
873874
liftIO $ putMVar processA us
874875
them <- expect
@@ -1277,7 +1278,7 @@ testMaskRestoreScope TestTransport{..} = do
12771278
parentPid <- newEmptyMVar :: IO (MVar ProcessId)
12781279
spawnedPid <- newEmptyMVar :: IO (MVar ProcessId)
12791280

1280-
void $ runProcess localNode $ mask $ \unmask -> do
1281+
void $ runProcess localNode $ Ex.mask $ \unmask -> do
12811282
getSelfPid >>= liftIO . putMVar parentPid
12821283
void $ spawnLocal $ unmask (getSelfPid >>= liftIO . putMVar spawnedPid)
12831284

@@ -1306,7 +1307,7 @@ testPrettyExit TestTransport{..} = do
13061307

13071308
_ <- forkProcess localNode $ do
13081309
(die "timeout")
1309-
`catch` \ex@(ProcessExitException from _) ->
1310+
`Ex.catch` \ex@(ProcessExitException from _) ->
13101311
let expected = "exit-from=" ++ (show from)
13111312
in do
13121313
True <- return $ (show ex) == expected
@@ -1480,11 +1481,11 @@ testCallLocal TestTransport{..} = do
14801481
spawnLocal $ do
14811482
caller <- getSelfPid
14821483
send keeper caller
1483-
onException
1484+
Ex.onException
14841485
(callLocal $ do
1485-
onException (do send keeper caller
1486-
expect)
1487-
(do liftIO $ writeIORef ibox True))
1486+
Ex.onException (do send keeper caller
1487+
expect)
1488+
(do liftIO $ writeIORef ibox True))
14881489
(send keeper ())
14891490
caller <- expect
14901491
exit caller "test"
@@ -1496,7 +1497,7 @@ testCallLocal TestTransport{..} = do
14961497
-- Testing that when the worker raises an exception, the exception is propagated to the parent.
14971498
ibox2 <- newIORef False
14981499
runProcess node $ do
1499-
r <- try (callLocal $ error "e" >> return ())
1500+
r <- Ex.try (callLocal $ error "e" >> return ())
15001501
liftIO $ writeIORef ibox2 $ case r of
15011502
Left (ErrorCall "e") -> True
15021503
_ -> False
@@ -1514,7 +1515,7 @@ testCallLocal TestTransport{..} = do
15141515
send keeper us
15151516
() <- expect
15161517
liftIO yield)
1517-
`finally` (liftIO $ writeIORef ibox3 True)
1518+
`Ex.finally` (liftIO $ writeIORef ibox3 True)
15181519
liftIO $ putMVar result3 =<< readIORef ibox3
15191520
worker <- expect
15201521
send worker ()
@@ -1531,8 +1532,8 @@ testCallLocal TestTransport{..} = do
15311532
callLocal
15321533
((do send keeper caller
15331534
expect)
1534-
`finally` (liftIO $ writeIORef ibox4 True))
1535-
`finally` (liftIO $ putMVar result4 =<< readIORef ibox4)
1535+
`Ex.finally` (liftIO $ writeIORef ibox4 True))
1536+
`Ex.finally` (liftIO $ putMVar result4 =<< readIORef ibox4)
15361537
caller <- expect
15371538
exit caller "hi!"
15381539
True <- takeMVar result4

src/Control/Distributed/Process/Tests/Internal/Utils.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import Control.Distributed.Process.Serializable()
7979

8080
import Control.Exception (AsyncException(ThreadKilled), SomeException)
8181
import Control.Monad (forever)
82+
import Control.Monad.Catch as Ex (catch, finally)
8283
import Control.Monad.STM (atomically)
8384
import Control.Rematch hiding (match)
8485
import Control.Rematch.Run
@@ -122,8 +123,8 @@ synchronisedAssertion note localNode expected testProc lock = do
122123
result <- newEmptyMVar
123124
_ <- forkProcess localNode $ do
124125
acquire lock
125-
finally (testProc result)
126-
(release lock)
126+
Ex.finally (testProc result)
127+
(release lock)
127128
assertComplete note result expected
128129
where acquire lock' = liftIO $ takeMVar lock'
129130
release lock' = liftIO $ putMVar lock' ()
@@ -223,10 +224,10 @@ testProcessReport pid = do
223224
tryRunProcess :: LocalNode -> Process () -> IO ()
224225
tryRunProcess node p = do
225226
tid <- liftIO myThreadId
226-
runProcess node $ catch p (\e -> liftIO $ throwTo tid (e::SomeException))
227+
runProcess node $ Ex.catch p (\e -> liftIO $ throwTo tid (e::SomeException))
227228

228229
tryForkProcess :: LocalNode -> Process () -> IO ProcessId
229230
tryForkProcess node p = do
230231
tid <- liftIO myThreadId
231-
forkProcess node $ catch p (\e -> liftIO $ throwTo tid (e::SomeException))
232+
forkProcess node $ Ex.catch p (\e -> liftIO $ throwTo tid (e::SomeException))
232233

tests/runInMemory.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Network.Transport.Test (TestTransport(..))
88
import Network.Transport.InMemory
99
import Test.Framework (defaultMainWithArgs)
1010

11-
import Control.Concurrent (threadDelay)
1211
import System.Environment (getArgs)
1312

1413
main :: IO ()

0 commit comments

Comments
 (0)