git.iko.soy/distributed-process
on master help sign in
Move the transport tests to a separate package

This paves the way for reusing these tests in other transports

commit80b8e8813da89fbd1d6125a732c901c2f25257a5 authorEdsko de Vries <edsko@edsko.net> dateMon 3 Sep 2012, 18:17 (14 years ago) parentb6f32f0
9 files changed+107−46
network-transport-composed/src/Network/Transport/Composed.hs+4 network-transport-tcp/network-transport-tcp.cabal+9−21 network-transport-tcp/tests/TestTCP.hs+3−3 network-transport-tests/LICENSE+30 network-transport-tests/Setup.hs+2 network-transport-tests/network-transport-tests.cabal+35 network-transport-tcp/tests/TestTransport.hs → network-transport-tests/src/Network/Transport/Tests.hs+3−3 network-transport-tcp/tests/TestAuxiliary.hs → network-transport-tests/src/Network/Transport/Tests/Auxiliary.hs+10−9 network-transport-tcp/tests/Traced.hs → network-transport-tests/src/Network/Transport/Tests/Traced.hs+11−10
network-transport-composed/src/Network/Transport/Composed.hs+4
@@ -14,6 +14,10 @@
1414-- When C2 connects to C1 then it is assumed that whatever transport C2 uses
1515-- to connect to C1, this is the same transport that C1 needs to use to connect
1616-- 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?
1721module Network.Transport.Composed
1822 ( ComposedTransport(..)
1923 , createTransport
network-transport-tcp/network-transport-tcp.cabal+9−21
@@ -10,8 +10,8 @@ Maintainer: edsko@well-typed.com, dcoutts@well-typed.com
1010Stability: experimental
1111Homepage: http://github.com/haskell-distributed/distributed-process
1212Bug-Reports: mailto:edsko@well-typed.com
13−Synopsis: TCP instantation of Network.Transport
14−Description: TCP instantation of Network.Transport
13+Synopsis: TCP instantiation of Network.Transport
14+Description: TCP instantiation of Network.Transport
1515Tested-With: GHC==7.0.4 GHC==7.2.2 GHC==7.4.1 GHC==7.4.2
1616Category: Network
1717
@@ -37,23 +37,11 @@ Test-Suite TestTCP
3737 Type: exitcode-stdio-1.0
3838 Main-Is: TestTCP.hs
3939 Build-Depends: base >= 4.3 && < 5,
40− network-transport >= 0.3 && < 0.4,
41− data-accessor >= 0.2 && < 0.3,
42− containers >= 0.4 && < 0.6,
43− bytestring >= 0.9 && < 0.11,
40+ network-transport-tests >= 0.1 && < 0.2,
4441 network >= 2.3 && < 2.4,
45− random >= 1.0 && < 1.1,
46− ansi-terminal >= 0.5 && < 0.6,
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
52− Extensions: ExistentialQuantification,
53− FlexibleInstances,
54− DeriveDataTypeable,
55− RankNTypes,
56− OverlappingInstances,
57− OverloadedStrings,
58− CPP
59− HS-Source-Dirs: tests src
42+ network-transport >= 0.3 && < 0.4,
43+ network-transport-tcp >= 0.3 && < 0.4
44+ ghc-options: -threaded -rtsopts -with-rtsopts=-N
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
1111 , catch
1212#endif
1313 )
14−import TestTransport (testTransport)
15−import TestAuxiliary (forkTry, runTests)
1614import Network.Transport
1715import Network.Transport.TCP ( createTransport
1816 , createTransportExposeInternals
@@ -54,10 +52,12 @@ import qualified Network.Socket as N ( sClose
5452 )
5553import Network.Socket.ByteString (sendMany)
5654import Data.String (fromString)
57−import Traced
5855import GHC.IO.Exception (ioe_errno)
5956import Foreign.C.Error (Errno(..), eADDRNOTAVAIL)
6057import System.Timeout (timeout)
58+import Network.Transport.Tests (testTransport)
59+import Network.Transport.Tests.Auxiliary (forkTry, runTests)
60+import Network.Transport.Tests.Traced
6161
6262instance Traceable ControlHeader where
6363 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 @@
11{-# LANGUAGE RebindableSyntax #-}
2−module TestTransport where
2+module Network.Transport.Tests where
33
44import Prelude hiding
55 ( (>>=)
@@ -10,7 +10,6 @@ import Prelude hiding
1010 , catch
1111#endif
1212 )
13−import TestAuxiliary (forkTry, runTests, trySome, randomThreadDelay)
1413import Control.Concurrent (forkIO, killThread, yield)
1514import Control.Concurrent.MVar (newEmptyMVar, takeMVar, putMVar, readMVar, tryTakeMVar, modifyMVar_, newMVar)
1615import Control.Exception (evaluate, throw, throwIO, bracket)
@@ -27,7 +26,8 @@ import Data.Map (Map)
2726import qualified Data.Map as Map (empty, insert, delete, findWithDefault, adjust, null, toList, map)
2827import Data.String (fromString)
2928import Data.List (permutations)
30−import Traced
29+import Network.Transport.Tests.Auxiliary (forkTry, runTests, trySome, randomThreadDelay)
30+import Network.Transport.Tests.Traced
3131
3232-- | Server that echoes messages straight back to the origin endpoint.
3333echoServer :: EndPoint -> IO ()
network-transport-tcp/tests/TestAuxiliary.hs → network-transport-tests/src/Network/Transport/Tests/Auxiliary.hsrenamed+10−9
@@ -1,12 +1,13 @@
11{-# OPTIONS_GHC -fno-warn-orphans #-}
2−module TestAuxiliary ( -- Running tests
3− runTest
4− , runTests
5− -- Writing tests
6− , forkTry
7− , trySome
8− , randomThreadDelay
9− ) where
2+module Network.Transport.Tests.Auxiliary
3+ ( -- Running tests
4+ runTest
5+ , runTests
6+ -- Writing tests
7+ , forkTry
8+ , trySome
9+ , randomThreadDelay
10+ ) where
1011
1112#if ! MIN_VERSION_base(4,6,0)
1213import Prelude hiding (catch)
@@ -26,7 +27,7 @@ import System.Console.ANSI ( SGR(SetColor, Reset)
2627 )
2728import System.Random (randomIO)
2829import Network.Transport
29−import Traced (Traceable(..), traceShow)
30+import Network.Transport.Tests.Traced (Traceable(..), traceShow)
3031
3132-- | Like fork, but throw exceptions in the child thread to the parent
3233forkTry :: IO () -> IO ThreadId
network-transport-tcp/tests/Traced.hs → network-transport-tests/src/Network/Transport/Tests/Traced.hsrenamed+11−10
@@ -39,16 +39,17 @@
3939-- > *** Exception: user error (Pattern match failure in do expression at Traced.hs:193:3-6)
4040-- > Trace:
4141-- > 0 Left 1
42−module Traced ( MonadS(..)
43− , return
44− , (>>=)
45− , (>>)
46− , fail
47− , ifThenElse
48− , Showable(..)
49− , Traceable(..)
50− , traceShow
51− ) where
42+module Network.Transport.Tests.Traced
43+ ( MonadS(..)
44+ , return
45+ , (>>=)
46+ , (>>)
47+ , fail
48+ , ifThenElse
49+ , Showable(..)
50+ , Traceable(..)
51+ , traceShow
52+ ) where
5253
5354import Prelude hiding
5455 ( (>>=)