Skip to content

Commit

Permalink
fix(runtime): make single threaded execution of tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Jun 9, 2021
1 parent 30fe94c commit b3b331f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/runtime-prototype/src/StuntDouble/ActorMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ makeEventLoop time seed tk name = do
Http port -> httpTransport port
Stm -> stmTransport
ls <- initLoopState name time seed t
pids <- if True -- XXX: introduce and parametrise by flag
pids <- if False -- XXX: introduce and parametrise by flag
then do
aInHandler <- async (handleInbound ls)
aAsyncIOHandler <- async (handleAsyncIO ls)
Expand Down
19 changes: 6 additions & 13 deletions src/runtime-prototype/src/StuntDouble/Transport/NamedPipe.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module StuntDouble.Transport.NamedPipe where

import Control.Exception
import Control.Concurrent.Async
import Control.Exception
import System.FilePath
import System.IO
import System.IO.Error
import System.Posix.Files
import System.FilePath
import System.Timeout

import StuntDouble.Reference
import StuntDouble.Message
import StuntDouble.Envelope
import StuntDouble.Message
import StuntDouble.Reference
import StuntDouble.Transport

------------------------------------------------------------------------
Expand Down Expand Up @@ -40,12 +41,4 @@ safeCreateNamedPipe fp =
return

hMaybeGetLine :: Handle -> IO (Maybe String)
hMaybeGetLine h = do
eof <- hIsEOF h
if eof
then return Nothing
else do
rdy <- hReady h
if rdy
then fmap Just (hGetLine h)
else return Nothing
hMaybeGetLine = timeout 1000 . hGetLine
16 changes: 11 additions & 5 deletions src/runtime-prototype/test/StuntDouble/Transport/NamedPipeTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import StuntDouble

------------------------------------------------------------------------

unit_transportNamedPipe :: IO ()
unit_transportNamedPipe :: Assertion
unit_transportNamedPipe = do
t <- namedPipeTransport "/tmp" (EventLoopName "a")
t <- namedPipeTransport "/tmp" (EventLoopName "transportNamedPipe")
let e = Envelope RequestKind (RemoteRef "from" 0) (InternalMessage "msg")
(RemoteRef "a" 1) 0
(RemoteRef "transportNamedPipe" 1) 0
transportSend t e
e' <- transportReceive t
e' @?= Just e
me' <- transportReceive t
me' @?= Just e

unit_transportNamedPipeNothing :: Assertion
unit_transportNamedPipeNothing = do
t <- namedPipeTransport "/tmp" (EventLoopName "transportNamedPipeNothing")
me <- transportReceive t
me @?= Nothing

0 comments on commit b3b331f

Please sign in to comment.