Skip to content

Commit

Permalink
Merge pull request #466 from haskell-distributed/tasty-port
Browse files Browse the repository at this point in the history
Port test suites to `tasty` (from `test-framework`)
  • Loading branch information
LaurentRDC authored Jan 9, 2025
2 parents 477d17c + 043c82d commit 66fae14
Show file tree
Hide file tree
Showing 45 changed files with 183 additions and 289 deletions.
4 changes: 4 additions & 0 deletions packages/distributed-process-async/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased

* Ported test suite to use `tasty` rather than `test-framework`.

2024-10-30 David Simmons-Duffin <[email protected]> 0.2.10

* Bump dependency bound for ansi-terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ common warnings
-Wredundant-constraints
-fhide-source-paths
-Wpartial-fields
-Wunused-packages

library
import: warnings
Expand Down Expand Up @@ -75,13 +76,11 @@ test-suite AsyncTests
network-transport-tcp >= 0.6 && < 0.9,
binary >= 0.8 && < 0.9,
deepseq >= 1.4 && < 1.7,
-- HUnit >= 1.2 && < 2,
stm >= 2.3 && < 2.6,
test-framework >= 0.6 && < 0.9,
test-framework-hunit,
tasty >= 1.5 && <1.6,
tasty-hunit >=0.10 && <0.11,
transformers
hs-source-dirs:
tests
hs-source-dirs: tests
default-language: Haskell2010
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
default-extensions: CPP
Expand Down
12 changes: 6 additions & 6 deletions packages/distributed-process-async/tests/TestAsync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Data.Typeable()
import Network.Transport.TCP
import qualified Network.Transport as NT

import Test.Framework (Test, testGroup, defaultMain)
import Test.Framework.Providers.HUnit (testCase)
import Test.Tasty(TestTree, testGroup, defaultMain)
import Test.Tasty.HUnit (testCase)

testAsyncPoll :: TestResult (AsyncResult ()) -> Process ()
testAsyncPoll result = do
Expand Down Expand Up @@ -158,8 +158,8 @@ testAsyncRecursive result = do
myNode <- getSelfNode
fib (myNode,6) >>= stash result

tests :: LocalNode -> [Test]
tests localNode = [
tests :: LocalNode -> TestTree
tests localNode = testGroup "" [
testGroup "Handling async results with STM" [
testCase "testAsyncCancel"
(delayedAssertion
Expand Down Expand Up @@ -210,14 +210,14 @@ tests localNode = [
]
]

asyncStmTests :: NT.Transport -> IO [Test]
asyncStmTests :: NT.Transport -> IO TestTree
asyncStmTests transport = do
localNode <- newLocalNode transport $ __remoteTableDecl initRemoteTable
let testData = tests localNode
return testData

-- | Given a @builder@ function, make and run a test suite on a single transport
testMain :: (NT.Transport -> IO [Test]) -> IO ()
testMain :: (NT.Transport -> IO TestTree) -> IO ()
testMain builder = do
Right (transport, _) <- createTransportExposeInternals (defaultTCPAddr "127.0.0.1" "0") defaultTCPParameters
testData <- builder transport
Expand Down
4 changes: 4 additions & 0 deletions packages/distributed-process-client-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

Unreleased

* Ported test suite to use `tasty` rather than `test-framework`.

2024-10-30 David Simmons-Duffin <[email protected]> 0.2.7.1

* Bump dependency bound for ansi-terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ common warnings
-Wredundant-constraints
-fhide-source-paths
-Wpartial-fields
-Wunused-packages

library
import: warnings
Expand Down Expand Up @@ -87,10 +88,9 @@ test-suite ManagedProcessTests
binary >= 0.8 && < 0.9,
deepseq,
network >= 2.3 && < 3.3,
HUnit >= 1.2 && < 2,
stm,
test-framework >= 0.6 && < 0.9,
test-framework-hunit,
tasty >= 1.5 && <1.6,
tasty-hunit >=0.10 && <0.11,
transformers,
ghc-prim,
exceptions
Expand Down Expand Up @@ -125,10 +125,9 @@ test-suite PrioritisedProcessTests
binary,
deepseq,
network,
HUnit,
stm,
test-framework,
test-framework-hunit,
tasty >= 1.5 && <1.6,
tasty-hunit >=0.10 && <0.11,
transformers,
ghc-prim,
exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import MathsDemo
import Counter
import qualified SafeCounter as SafeCounter

import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase)
import TestUtils
import ManagedProcessCommon

Expand Down Expand Up @@ -210,13 +210,14 @@ testCounterExceedsLimit result = do
]
stash result (r /= DiedNormal)

tests :: NT.Transport -> IO [Test]
tests :: NT.Transport -> IO TestTree
tests transport = do
localNode <- newLocalNode transport initRemoteTable
scpid <- newEmptyMVar
_ <- forkProcess localNode $ SafeCounter.startCounter 5 >>= stash scpid
safeCounter <- takeMVar scpid
return [
return $
testGroup "" [
testGroup "Basic Client/Server Functionality" [
testCase "basic call with explicit server reply"
(delayedAssertion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import Data.List (isInfixOf)
import Data.Maybe (isNothing, isJust)
import Data.Typeable (Typeable)

import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase)
import TestUtils
import ManagedProcessCommon

Expand Down Expand Up @@ -534,10 +534,10 @@ testCallPrioritisation result = do
let ms = rights st
stash result $ ms == ["we do prioritise", "the longest", "commands", "first"]

tests :: NT.Transport -> IO [Test]
tests :: NT.Transport -> IO TestTree
tests transport = do
localNode <- newLocalNode transport initRemoteTable
return [
return $ testGroup "" [
testGroup "basic server functionality matches un-prioritised processes" [
testCase "basic call with explicit server reply"
(delayedAssertion
Expand Down
4 changes: 2 additions & 2 deletions packages/distributed-process-client-server/tests/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Control.Distributed.Process.Node
import Control.Distributed.Process.Extras
import Control.Distributed.Process.Extras.Time
import Control.Distributed.Process.Extras.Timer
import Test.Framework (Test, defaultMain)
import Test.Tasty (TestTree, defaultMain)

import Network.Transport.TCP
import qualified Network.Transport as NT
Expand All @@ -41,7 +41,7 @@ mkNode port = do
newLocalNode transport1 initRemoteTable

-- | Given a @builder@ function, make and run a test suite on a single transport
testMain :: (NT.Transport -> IO [Test]) -> IO ()
testMain :: (NT.Transport -> IO TestTree) -> IO ()
testMain builder = do
Right (transport, _) <- createTransportExposeInternals (defaultTCPAddr "127.0.0.1" "0") defaultTCPParameters
testData <- builder transport
Expand Down
4 changes: 4 additions & 0 deletions packages/distributed-process-execution/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased

* Ported test suite to use `tasty` rather than `test-framework`.

2024-10-30 David Simmons-Duffin <[email protected]> 0.1.4.1

* Bump dependency bound for ansi-terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ common warnings
-Wredundant-constraints
-fhide-source-paths
-Wpartial-fields
-Wunused-packages

library
import: warnings
Expand All @@ -45,14 +46,10 @@ library
distributed-process-client-server >= 0.2.0 && < 0.3,
binary >= 0.8 && < 0.9,
deepseq >= 1.4 && < 1.7,
mtl,
containers >= 0.6 && < 0.8,
hashable >= 1.2.0.5 && < 1.6,
unordered-containers >= 0.2.3.0 && < 0.3,
fingertree < 0.2,
stm >= 2.4 && < 2.6,
time,
transformers
hs-source-dirs: src
exposed-modules:
Control.Distributed.Process.Execution,
Expand All @@ -69,38 +66,16 @@ library
test-suite ExchangeTests
import: warnings
type: exitcode-stdio-1.0
-- x-uses-tf: true
build-depends:
base >= 4.14 && < 5,
ansi-terminal >= 0.5 && < 1.2,
containers,
hashable,
unordered-containers >= 0.2.3.0 && < 0.3,
build-depends: base >= 4.14 && < 5,
distributed-process,
distributed-process-execution,
distributed-process-extras,
distributed-process-systest ^>= 0.4,
distributed-static,
bytestring,
data-accessor,
fingertree < 0.2,
network-transport >= 0.4 && < 0.6,
deepseq,
mtl,
network-transport-tcp >= 0.4 && < 0.9,
binary >= 0.8 && < 0.9,
network >= 2.3 && < 3.3,
HUnit >= 1.2 && < 2,
stm,
time,
test-framework >= 0.6 && < 0.9,
test-framework-hunit,
QuickCheck >= 2.4,
test-framework-quickcheck2,
transformers,
ghc-prim
hs-source-dirs:
tests
tasty >= 1.5 && <1.6,
tasty-hunit >=0.10 && <0.11,
hs-source-dirs: tests
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
main-is: TestExchange.hs
default-language: Haskell2010
Expand All @@ -109,38 +84,16 @@ test-suite ExchangeTests
test-suite MailboxTests
import: warnings
type: exitcode-stdio-1.0
-- x-uses-tf: true
build-depends:
base >= 4.14 && < 5,
ansi-terminal >= 0.5 && < 1.2,
containers,
hashable,
unordered-containers >= 0.2.3.0 && < 0.3,
build-depends: base >= 4.14 && < 5,
distributed-process,
distributed-process-execution,
distributed-process-extras,
distributed-process-systest ^>= 0.4,
distributed-static,
bytestring,
data-accessor,
fingertree < 0.2,
network-transport >= 0.4 && < 0.6,
deepseq,
mtl,
network-transport-tcp >= 0.4 && < 0.9,
binary >= 0.8 && < 0.9,
network >= 2.3 && < 3.3,
HUnit >= 1.2 && < 2,
stm,
time,
test-framework >= 0.6 && < 0.9,
test-framework-hunit,
QuickCheck >= 2.4,
test-framework-quickcheck2,
transformers,
ghc-prim
hs-source-dirs:
tests
tasty >= 1.5 && <1.6,
tasty-hunit >=0.10 && <0.11,
hs-source-dirs: tests
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-warn-unused-do-bind
main-is: TestMailbox.hs
other-modules: MailboxTestFilters
Expand Down
11 changes: 5 additions & 6 deletions packages/distributed-process-execution/tests/TestExchange.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import Control.Monad (void, forM, forever)
import Prelude hiding (drop)
import Network.Transport.TCP
import qualified Network.Transport as NT
import Test.Framework as TF (defaultMain, testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.HUnit (assertEqual, assertBool)
import Test.Tasty (defaultMain, testGroup, TestTree)
import Test.Tasty.HUnit (assertEqual, assertBool, testCase)

testKeyBasedRouting :: TestResult Bool -> Process ()
testKeyBasedRouting result = do
Expand Down Expand Up @@ -158,10 +157,10 @@ myRemoteTable :: RemoteTable
myRemoteTable =
Control.Distributed.Process.Extras.__remoteTable initRemoteTable

tests :: NT.Transport -> IO [Test]
tests :: NT.Transport -> IO TestTree
tests transport = do
localNode <- newLocalNode transport myRemoteTable
return [
return $ testGroup "" [
testGroup "Event Manager"
[
testCase "Simple Event Handlers"
Expand All @@ -187,7 +186,7 @@ main :: IO ()
main = testMain $ tests

-- | Given a @builder@ function, make and run a test suite on a single transport
testMain :: (NT.Transport -> IO [Test]) -> IO ()
testMain :: (NT.Transport -> IO TestTree) -> IO ()
testMain builder = do
Right (transport, _) <- createTransportExposeInternals (defaultTCPAddr "127.0.0.1" "10501") defaultTCPParameters
testData <- builder transport
Expand Down
11 changes: 5 additions & 6 deletions packages/distributed-process-execution/tests/TestMailbox.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import Prelude hiding (drop)

import Data.Maybe (catMaybes)

import Test.Framework as TF (defaultMain, testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.HUnit (assertEqual)
import Test.Tasty (defaultMain, testGroup, TestTree)
import Test.Tasty.HUnit (assertEqual, testCase)

import qualified MailboxTestFilters (__remoteTable)
import MailboxTestFilters (myFilter, intFilter)
Expand Down Expand Up @@ -175,11 +174,11 @@ myRemoteTable =
Control.Distributed.Process.Extras.__remoteTable $
MailboxTestFilters.__remoteTable initRemoteTable

tests :: NT.Transport -> IO [Test]
tests :: NT.Transport -> IO TestTree
tests transport = do
{- verboseCheckWithResult stdArgs -}
localNode <- newLocalNode transport myRemoteTable
return [
return $ testGroup "" [
testGroup "Dequeue/Pop Ordering"
[
testCase "Queue Ordering"
Expand Down Expand Up @@ -253,7 +252,7 @@ main :: IO ()
main = testMain $ tests

-- | Given a @builder@ function, make and run a test suite on a single transport
testMain :: (NT.Transport -> IO [Test]) -> IO ()
testMain :: (NT.Transport -> IO TestTree) -> IO ()
testMain builder = do
Right (transport, _) <- createTransportExposeInternals (defaultTCPAddr "127.0.0.1" "10501") defaultTCPParameters
testData <- builder transport
Expand Down
4 changes: 4 additions & 0 deletions packages/distributed-process-extras/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased

* Ported test suite to use `tasty` rather than `test-framework`.

2024-10-30 David Simmons-Duffin <[email protected]> 0.3.8

* Bump dependency bound for ansi-terminal
Expand Down
Loading

0 comments on commit 66fae14

Please sign in to comment.