Skip to content

Commit 6c09156

Browse files
committed
Merge pull request #17 from tweag/fix/spawnAsync
Fix/spawn async
2 parents be78954 + 9c81def commit 6c09156

File tree

1 file changed

+17
-1
lines changed
  • src/Control/Distributed/Process/Tests

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Control.Concurrent.MVar
1717
, takeMVar
1818
, readMVar
1919
)
20-
import Control.Monad (replicateM_, replicateM, forever, void, unless)
20+
import Control.Monad (replicateM_, replicateM, forever, void, unless, join)
2121
import Control.Exception (SomeException, throwIO)
2222
import qualified Control.Exception as Ex (catch)
2323
import Control.Applicative ((<$>), (<*>), pure, (<|>))
@@ -719,6 +719,21 @@ testSpawnLocal TestTransport{..} = do
719719

720720
takeMVar done
721721

722+
testSpawnAsyncStrictness :: TestTransport -> Assertion
723+
testSpawnAsyncStrictness TestTransport{..} = do
724+
node <- newLocalNode testTransport initRemoteTable
725+
done <- newEmptyMVar
726+
727+
runProcess node $ do
728+
here <-getSelfNode
729+
730+
ev <- try $ spawnAsync here (error "boom")
731+
liftIO $ case ev of
732+
Right _ -> putMVar done (error "Exception didn't fire")
733+
Left (_::SomeException) -> putMVar done (return ())
734+
735+
join $ takeMVar done
736+
722737
testReconnect :: TestTransport -> Assertion
723738
testReconnect TestTransport{..} = do
724739
[node1, node2] <- replicateM 2 $ newLocalNode testTransport initRemoteTable
@@ -1370,6 +1385,7 @@ tests testtrans = return [
13701385
, testCase "Registry" (testRegistry testtrans)
13711386
, testCase "RemoteRegistry" (testRemoteRegistry testtrans)
13721387
, testCase "SpawnLocal" (testSpawnLocal testtrans)
1388+
, testCase "SpawnAsyncStrictness" (testSpawnAsyncStrictness testtrans)
13731389
, testCase "HandleMessageIf" (testHandleMessageIf testtrans)
13741390
, testCase "MatchAny" (testMatchAny testtrans)
13751391
, testCase "MatchAnyHandle" (testMatchAnyHandle testtrans)

0 commit comments

Comments
 (0)