From b9b74fa4e0eb22461249aa16f52c01d88d36a5ff Mon Sep 17 00:00:00 2001 From: Naushadh Date: Sun, 20 Jan 2019 17:12:42 -0500 Subject: [PATCH 1/3] [stackage#4312] Relax `network` upper bound - Fixes: https://github.com/commercialhaskell/stackage/issues/4312 - Address some compiler warnings in tests (IO with unused result). - Updated deprecated/removed upstream API usage in tests with conditional blocks to support older test matrices. --- io-streams.cabal | 2 +- test/System/IO/Streams/Tests/Concurrent.hs | 2 +- test/System/IO/Streams/Tests/Network.hs | 34 +++++++++++++++++----- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/io-streams.cabal b/io-streams.cabal index e43e2c0..4fe1c64 100644 --- a/io-streams.cabal +++ b/io-streams.cabal @@ -124,7 +124,7 @@ Library attoparsec >= 0.10 && <0.14, bytestring >= 0.9 && <0.11, bytestring-builder >= 0.10 && <0.11, - network >= 2.3 && <2.9, + network >= 2.3 && <3.1, primitive >= 0.2 && <0.7, process >= 1.1 && <1.7, text >= 0.10 && <1.3, diff --git a/test/System/IO/Streams/Tests/Concurrent.hs b/test/System/IO/Streams/Tests/Concurrent.hs index 10ee136..68df43f 100644 --- a/test/System/IO/Streams/Tests/Concurrent.hs +++ b/test/System/IO/Streams/Tests/Concurrent.hs @@ -47,7 +47,7 @@ testConcurrentMerge = testCase "concurrent/concurrentMerge" $ do chans inputs <- mapM Streams.chanToInput chans resultMVar <- newEmptyMVar - forkIO (Streams.concurrentMerge inputs >>= Streams.toList + _ <- forkIO (Streams.concurrentMerge inputs >>= Streams.toList >>= putMVar resultMVar) putMVar firstMVar 0 result <- takeMVar resultMVar diff --git a/test/System/IO/Streams/Tests/Network.hs b/test/System/IO/Streams/Tests/Network.hs index 45b981d..b8e5a19 100644 --- a/test/System/IO/Streams/Tests/Network.hs +++ b/test/System/IO/Streams/Tests/Network.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} module System.IO.Streams.Tests.Network (tests) where @@ -13,6 +14,10 @@ import System.Timeout (timeout) import Test.Framework import Test.Framework.Providers.HUnit import Test.HUnit hiding (Test) +#if MIN_VERSION_network(2,7,0) +#else +import Data.List (intercalate) +#endif ------------------------------------------------------------------------------ import qualified System.IO.Streams.Internal as Streams import qualified System.IO.Streams.Internal.Network as Streams @@ -32,10 +37,23 @@ testSocket = testCase "network/socket" $ assertEqual "ok" (Just ()) x where + -- compats +#if MIN_VERSION_network(2,7,0) + mkAddr = pure . N.tupleToHostAddress + defaultPort = N.defaultPort + close = N.close + bind = N.bind +#else + mkAddr (o1,o2,o3,o4) = N.inet_addr . intercalate "." $ map show [o1,o2,o3,o4] + defaultPort = N.aNY_PORT + close = N.sClose + bind = N.bindSocket +#endif + go = do portMVar <- newEmptyMVar resultMVar <- newEmptyMVar - forkIO $ client portMVar resultMVar + _ <- forkIO $ client portMVar resultMVar server portMVar l <- takeMVar resultMVar assertEqual "testSocket" l ["ok"] @@ -43,28 +61,28 @@ testSocket = testCase "network/socket" $ client mvar resultMVar = do port <- takeMVar mvar sock <- N.socket N.AF_INET N.Stream N.defaultProtocol - addr <- N.inet_addr "127.0.0.1" + addr <- mkAddr (127, 0, 0, 1) let saddr = N.SockAddrInet port addr N.connect sock saddr (is, os) <- Streams.socketToStreams sock Streams.fromList ["", "ok"] >>= Streams.connectTo os N.shutdown sock N.ShutdownSend Streams.toList is >>= putMVar resultMVar - N.sClose sock + close sock server mvar = do sock <- N.socket N.AF_INET N.Stream N.defaultProtocol - addr <- N.inet_addr "127.0.0.1" - let saddr = N.SockAddrInet N.aNY_PORT addr - N.bindSocket sock saddr + addr <- mkAddr (127, 0, 0, 1) + let saddr = N.SockAddrInet defaultPort addr + bind sock saddr N.listen sock 5 port <- N.socketPort sock putMVar mvar port (csock, _) <- N.accept sock (is, os) <- Streams.socketToStreams csock Streams.toList is >>= flip Streams.writeList os - N.sClose csock - N.sClose sock + close csock + close sock testSocketWithError :: Test testSocketWithError = testCase "network/socket-error" $ N.withSocketsDo $ do From 4150c0c9990eb2044a43f8b58a5553fda823a04c Mon Sep 17 00:00:00 2001 From: Naushadh Date: Sun, 20 Jan 2019 17:14:58 -0500 Subject: [PATCH 2/3] Ignore stack-work dir. Though the project does not have a stack.yaml file, contributors may use it for their own development and this makes it slightly easier. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 02b709e..7c2e901 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ docs/templates/out .cabal-sandbox/ cabal.sandbox.config cabal.project.local +.stack-work/ From 8ebb795b86e20d60ba6fdbbb25c3cb1ef90b2d98 Mon Sep 17 00:00:00 2001 From: Naushadh Date: Sun, 20 Jan 2019 17:48:15 -0500 Subject: [PATCH 3/3] Try to address compat with older `base` Prelude. --- changelog.md | 3 +++ io-streams.cabal | 2 +- test/System/IO/Streams/Tests/Network.hs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index ca05908..b218daf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# Version 1.5.0.2 +Fix [stackage#4312](https://github.com/commercialhaskell/stackage/issues/4312): Relax `network` upper bound + # Version 1.5.0.1 Bugfix: `concurrentMerge []` should not block forever, even if this case is pathological. diff --git a/io-streams.cabal b/io-streams.cabal index 4fe1c64..73a17d4 100644 --- a/io-streams.cabal +++ b/io-streams.cabal @@ -1,5 +1,5 @@ Name: io-streams -Version: 1.5.0.1 +Version: 1.5.0.2 License: BSD3 License-file: LICENSE Category: Data, Network, IO-Streams diff --git a/test/System/IO/Streams/Tests/Network.hs b/test/System/IO/Streams/Tests/Network.hs index b8e5a19..8763168 100644 --- a/test/System/IO/Streams/Tests/Network.hs +++ b/test/System/IO/Streams/Tests/Network.hs @@ -39,7 +39,7 @@ testSocket = testCase "network/socket" $ where -- compats #if MIN_VERSION_network(2,7,0) - mkAddr = pure . N.tupleToHostAddress + mkAddr = return . N.tupleToHostAddress defaultPort = N.defaultPort close = N.close bind = N.bind