git.iko.soy/distributed-process
on master help sign in
Move the transport tests to a separate package
80b8e88Edsko de Vries
network-transport-composed/src/Network/Transport/Composed.hs+4
@@ -14,6 +14,10 @@
14-- When C2 connects to C1 then it is assumed that whatever transport C2 uses
14-- When C2 connects to C1 then it is assumed that whatever transport C2 uses
15-- to connect to C1, this is the same transport that C1 needs to use to connect
15-- to connect to C1, this is the same transport that C1 needs to use to connect
16-- back to C2.
16-- back to C2.
17+--
18+-- TODO: at the moment the address reported by a ConnectionOpened might differ
19+-- from the address reported by the remote endpoint itself. This might cause
20+-- difficulties?
17module Network.Transport.Composed
21module Network.Transport.Composed
18 ( ComposedTransport(..)
22 ( ComposedTransport(..)
19 , createTransport
23 , createTransport
network-transport-tcp/network-transport-tcp.cabal+9−21
@@ -10,8 +10,8 @@ Maintainer: edsko@well-typed.com, dcoutts@well-typed.com
10Stability: experimental
10Stability: experimental
11Homepage: http://github.com/haskell-distributed/distributed-process
11Homepage: http://github.com/haskell-distributed/distributed-process
12Bug-Reports: mailto:edsko@well-typed.com
12Bug-Reports: mailto:edsko@well-typed.com
13−Synopsis: TCP instantation of Network.Transport
13+Synopsis: TCP instantiation of Network.Transport
14−Description: TCP instantation of Network.Transport
14+Description: TCP instantiation of Network.Transport
15Tested-With: GHC==7.0.4 GHC==7.2.2 GHC==7.4.1 GHC==7.4.2
15Tested-With: GHC==7.0.4 GHC==7.2.2 GHC==7.4.1 GHC==7.4.2
16Category: Network
16Category: Network
17
17
@@ -37,23 +37,11 @@ Test-Suite TestTCP
37 Type: exitcode-stdio-1.0
37 Type: exitcode-stdio-1.0
38 Main-Is: TestTCP.hs
38 Main-Is: TestTCP.hs
39 Build-Depends: base >= 4.3 && < 5,
39 Build-Depends: base >= 4.3 && < 5,
40− network-transport >= 0.3 && < 0.4,
40+ network-transport-tests >= 0.1 && < 0.2,
41− data-accessor >= 0.2 && < 0.3,
42− containers >= 0.4 && < 0.6,
43− bytestring >= 0.9 && < 0.11,
44 network >= 2.3 && < 2.4,
41 network >= 2.3 && < 2.4,
45− random >= 1.0 && < 1.1,
42+ network-transport >= 0.3 && < 0.4,
46− ansi-terminal >= 0.5 && < 0.6,
43+ network-transport-tcp >= 0.3 && < 0.4
47− mtl >= 2.0 && < 2.2
48− Other-modules: TestAuxiliary,
49− TestTransport,
50− Traced
51− ghc-options: -Wall -fno-warn-unused-do-bind -threaded -rtsopts -with-rtsopts=-N
44+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
52− Extensions: ExistentialQuantification,
53− FlexibleInstances,
54− DeriveDataTypeable,
55− RankNTypes,
56− OverlappingInstances,
57− OverloadedStrings,
58− CPP
59− HS-Source-Dirs: tests src
45+ HS-Source-Dirs: tests
46+ Extensions: CPP,
47+ OverloadedStrings
network-transport-tcp/tests/TestTCP.hs+3−3
@@ -11,8 +11,6 @@ import Prelude hiding
11 , catch
11 , catch
12#endif
12#endif
13 )
13 )
14−import TestTransport (testTransport)
15−import TestAuxiliary (forkTry, runTests)
16import Network.Transport
14import Network.Transport
17import Network.Transport.TCP ( createTransport
15import Network.Transport.TCP ( createTransport
18 , createTransportExposeInternals
16 , createTransportExposeInternals
@@ -54,10 +52,12 @@ import qualified Network.Socket as N ( sClose
54 )
52 )
55import Network.Socket.ByteString (sendMany)
53import Network.Socket.ByteString (sendMany)
56import Data.String (fromString)
54import Data.String (fromString)
57−import Traced
58import GHC.IO.Exception (ioe_errno)
55import GHC.IO.Exception (ioe_errno)
59import Foreign.C.Error (Errno(..), eADDRNOTAVAIL)
56import Foreign.C.Error (Errno(..), eADDRNOTAVAIL)
60import System.Timeout (timeout)
57import System.Timeout (timeout)
58+import Network.Transport.Tests (testTransport)
59+import Network.Transport.Tests.Auxiliary (forkTry, runTests)
60+import Network.Transport.Tests.Traced
61
61
62instance Traceable ControlHeader where
62instance Traceable ControlHeader where
63 trace = traceShow
63 trace = traceShow
network-transport-tests/LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Copyright (c) 2012, Edsko de Vries
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are met:
7+
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of Edsko de Vries nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
network-transport-tests/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
network-transport-tests/network-transport-tests.cabalnew file+35
@@ -0,0 +1,35 @@
1+name: network-transport-tests
2+version: 0.1.0.0
3+synopsis: Unit tests for Network.Transport implementations
4+-- description:
5+homepage: http://github.com/haskell-distributed/distributed-process
6+license: BSD3
7+license-file: LICENSE
8+author: Edsko de Vries
9+maintainer: edsko@well-typed.com
10+copyright: Well-Typed LLP
11+category: Network
12+build-type: Simple
13+cabal-version: >=1.8
14+
15+library
16+ exposed-modules: Network.Transport.Tests,
17+ Network.Transport.Tests.Auxiliary,
18+ Network.Transport.Tests.Traced
19+ -- other-modules:
20+ build-depends: base ==4.5.*,
21+ network-transport >= 0.3 && < 0.4,
22+ containers >= 0.4 && < 0.6,
23+ bytestring >= 0.9 && < 0.11,
24+ random >= 1.0 && < 1.1,
25+ mtl >= 2.1 && < 2.2,
26+ ansi-terminal >= 0.5 && < 0.6
27+ hs-source-dirs: src
28+ ghc-options: -Wall -fno-warn-unused-do-bind
29+ extensions: CPP,
30+ ExistentialQuantification,
31+ FlexibleInstances,
32+ DeriveDataTypeable,
33+ RankNTypes,
34+ OverloadedStrings,
35+ OverlappingInstances
network-transport-tcp/tests/TestTransport.hs → network-transport-tests/src/Network/Transport/Tests.hsrenamed+3−3
@@ -1,5 +1,5 @@
1{-# LANGUAGE RebindableSyntax #-}
1{-# LANGUAGE RebindableSyntax #-}
2−module TestTransport where
2+module Network.Transport.Tests where
3
3
4import Prelude hiding
4import Prelude hiding
5 ( (>>=)
5 ( (>>=)
@@ -10,7 +10,6 @@ import Prelude hiding
10 , catch
10 , catch
11#endif
11#endif
12 )
12 )
13−import TestAuxiliary (forkTry, runTests, trySome, randomThreadDelay)
14import Control.Concurrent (forkIO, killThread, yield)
13import Control.Concurrent (forkIO, killThread, yield)
15import Control.Concurrent.MVar (newEmptyMVar, takeMVar, putMVar, readMVar, tryTakeMVar, modifyMVar_, newMVar)
14import Control.Concurrent.MVar (newEmptyMVar, takeMVar, putMVar, readMVar, tryTakeMVar, modifyMVar_, newMVar)
16import Control.Exception (evaluate, throw, throwIO, bracket)
15import Control.Exception (evaluate, throw, throwIO, bracket)
@@ -27,7 +26,8 @@ import Data.Map (Map)
27import qualified Data.Map as Map (empty, insert, delete, findWithDefault, adjust, null, toList, map)
26import qualified Data.Map as Map (empty, insert, delete, findWithDefault, adjust, null, toList, map)
28import Data.String (fromString)
27import Data.String (fromString)
29import Data.List (permutations)
28import Data.List (permutations)
30−import Traced
29+import Network.Transport.Tests.Auxiliary (forkTry, runTests, trySome, randomThreadDelay)
30+import Network.Transport.Tests.Traced
31
31
32-- | Server that echoes messages straight back to the origin endpoint.
32-- | Server that echoes messages straight back to the origin endpoint.
33echoServer :: EndPoint -> IO ()
33echoServer :: EndPoint -> IO ()
network-transport-tcp/tests/TestAuxiliary.hs → network-transport-tests/src/Network/Transport/Tests/Auxiliary.hsrenamed+10−9
@@ -1,12 +1,13 @@
1{-# OPTIONS_GHC -fno-warn-orphans #-}
1{-# OPTIONS_GHC -fno-warn-orphans #-}
2+module Network.Transport.Tests.Auxiliary
2−module TestAuxiliary ( -- Running tests
3+ ( -- Running tests
3− runTest
4+ runTest
4− , runTests
5+ , runTests
5− -- Writing tests
6+ -- Writing tests
6− , forkTry
7+ , forkTry
7− , trySome
8+ , trySome
8− , randomThreadDelay
9+ , randomThreadDelay
9− ) where
10+ ) where
10
11
11#if ! MIN_VERSION_base(4,6,0)
12#if ! MIN_VERSION_base(4,6,0)
12import Prelude hiding (catch)
13import Prelude hiding (catch)
@@ -26,7 +27,7 @@ import System.Console.ANSI ( SGR(SetColor, Reset)
26 )
27 )
27import System.Random (randomIO)
28import System.Random (randomIO)
28import Network.Transport
29import Network.Transport
29−import Traced (Traceable(..), traceShow)
30+import Network.Transport.Tests.Traced (Traceable(..), traceShow)
30
31
31-- | Like fork, but throw exceptions in the child thread to the parent
32-- | Like fork, but throw exceptions in the child thread to the parent
32forkTry :: IO () -> IO ThreadId
33forkTry :: IO () -> IO ThreadId
network-transport-tcp/tests/Traced.hs → network-transport-tests/src/Network/Transport/Tests/Traced.hsrenamed+11−10
@@ -39,16 +39,17 @@
39-- > *** Exception: user error (Pattern match failure in do expression at Traced.hs:193:3-6)
39-- > *** Exception: user error (Pattern match failure in do expression at Traced.hs:193:3-6)
40-- > Trace:
40-- > Trace:
41-- > 0 Left 1
41-- > 0 Left 1
42+module Network.Transport.Tests.Traced
42−module Traced ( MonadS(..)
43+ ( MonadS(..)
43− , return
44+ , return
44− , (>>=)
45+ , (>>=)
45− , (>>)
46+ , (>>)
46− , fail
47+ , fail
47− , ifThenElse
48+ , ifThenElse
48− , Showable(..)
49+ , Showable(..)
49− , Traceable(..)
50+ , Traceable(..)
50− , traceShow
51+ , traceShow
51− ) where
52+ ) where
52
53
53import Prelude hiding
54import Prelude hiding
54 ( (>>=)
55 ( (>>=)