Skip to content

Commit c482379

Browse files
authored
Merge testsuites into one (#351)
This should improve dev ergonomics and speed up building and running the tests. Context: #284
1 parent b7a79aa commit c482379

File tree

9 files changed

+69
-132
lines changed

9 files changed

+69
-132
lines changed

tests/Main.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Main (main) where
2+
3+
import Test.Tasty (defaultMain, testGroup)
4+
5+
import qualified Regressions
6+
import qualified Properties
7+
import qualified Strictness
8+
9+
main :: IO ()
10+
main = defaultMain $ testGroup "All"
11+
[ Properties.tests
12+
, Regressions.tests
13+
, Strictness.tests
14+
]

tests/Properties.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Properties (tests) where
2+
3+
import Test.Tasty (TestTree, testGroup)
4+
5+
import qualified Properties.HashMapLazy
6+
import qualified Properties.HashMapStrict
7+
import qualified Properties.HashSet
8+
import qualified Properties.List
9+
10+
tests :: TestTree
11+
tests = testGroup "Properties"
12+
[ Properties.HashMapLazy.tests
13+
, Properties.HashMapStrict.tests
14+
, Properties.HashSet.tests
15+
, Properties.List.tests
16+
]

tests/HashMapProperties.hs renamed to tests/Properties/HashMapLazy.hs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
-- | Tests for the 'Data.HashMap.Lazy' module. We test functions by
55
-- comparing them to @Map@ from @containers@.
66

7-
module Main (main) where
7+
#if defined(STRICT)
8+
module Properties.HashMapStrict (tests) where
9+
#else
10+
module Properties.HashMapLazy (tests) where
11+
#endif
812

913
import Control.Monad ( guard )
1014
import qualified Data.Foldable as Foldable
@@ -25,7 +29,7 @@ import qualified Data.HashMap.Lazy as HM
2529
import qualified Data.Map.Lazy as M
2630
#endif
2731
import Test.QuickCheck (Arbitrary(..), Property, (==>), (===), forAll, elements)
28-
import Test.Tasty (TestTree, defaultMain, testGroup)
32+
import Test.Tasty (TestTree, testGroup)
2933
import Test.Tasty.QuickCheck (testProperty)
3034
import Data.Functor.Identity (Identity (..))
3135
import Control.Applicative (Const (..))
@@ -441,7 +445,13 @@ pKeys = (L.sort . M.keys) `eq` (L.sort . HM.keys)
441445
-- * Test list
442446

443447
tests :: TestTree
444-
tests = testGroup "HashMap properties"
448+
tests =
449+
testGroup
450+
#if defined(STRICT)
451+
"Data.HashMap.Strict"
452+
#else
453+
"Data.HashMap.Lazy"
454+
#endif
445455
[
446456
-- Instances
447457
testGroup "instances"
@@ -571,12 +581,6 @@ eq_ f g = (M.toAscList . f) `eq` (toAscList . g)
571581

572582
infix 4 `eq_`
573583

574-
------------------------------------------------------------------------
575-
-- * Test harness
576-
577-
main :: IO ()
578-
main = defaultMain tests
579-
580584
------------------------------------------------------------------------
581585
-- * Helpers
582586

tests/Properties/HashMapStrict.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
3+
#define STRICT
4+
5+
#include "HashMapLazy.hs"

tests/HashSetProperties.hs renamed to tests/Properties/HashSet.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- | Tests for the 'Data.HashSet' module. We test functions by
44
-- comparing them to @Set@ from @containers@.
55

6-
module Main (main) where
6+
module Properties.HashSet (tests) where
77

88
import qualified Data.Foldable as Foldable
99
import Data.Hashable (Hashable(hashWithSalt))
@@ -12,7 +12,7 @@ import qualified Data.HashSet as S
1212
import qualified Data.Set as Set
1313
import Data.Ord (comparing)
1414
import Test.QuickCheck (Arbitrary, Property, (==>), (===))
15-
import Test.Tasty (TestTree, defaultMain, testGroup)
15+
import Test.Tasty (TestTree, testGroup)
1616
import Test.Tasty.QuickCheck (testProperty)
1717

1818
-- Key type that generates more hash collisions.
@@ -160,7 +160,7 @@ pToList = Set.toAscList `eq` toAscList
160160
-- * Test list
161161

162162
tests :: TestTree
163-
tests = testGroup "HashSet properties"
163+
tests = testGroup "Data.HashSet"
164164
[
165165
-- Instances
166166
testGroup "instances"
@@ -227,12 +227,6 @@ eq_ :: (Eq a, Hashable a, Ord a)
227227
-- equivalent
228228
eq_ f g = (Set.toAscList . f) `eq` (toAscList . g)
229229

230-
------------------------------------------------------------------------
231-
-- * Test harness
232-
233-
main :: IO ()
234-
main = defaultMain tests
235-
236230
------------------------------------------------------------------------
237231
-- * Helpers
238232

tests/List.hs renamed to tests/Properties/List.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
module Main (main) where
1+
module Properties.List (tests) where
22

33
import Data.HashMap.Internal.List
44
import Data.List (nub, sort, sortBy)
55
import Data.Ord (comparing)
66

7-
import Test.Tasty (TestTree, defaultMain, testGroup)
7+
import Test.Tasty (TestTree, testGroup)
88
import Test.Tasty.QuickCheck (testProperty)
99
import Test.QuickCheck ((==>), (===), property, Property)
1010

@@ -63,6 +63,3 @@ modelUnorderedCompareTrans xs ys zs =
6363
pUnorderedCompare :: [Int] -> [Int] -> Property
6464
pUnorderedCompare xs ys =
6565
unorderedCompare compare xs ys === modelUnorderedCompare xs ys
66-
67-
main :: IO ()
68-
main = defaultMain tests

tests/Regressions.hs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE ScopedTypeVariables #-}
22
{-# LANGUAGE MagicHash #-}
33
{-# LANGUAGE UnboxedTuples #-}
4-
module Main where
4+
module Regressions (tests) where
55

66
import Control.Exception (evaluate)
77
import Control.Monad (replicateM)
@@ -16,7 +16,7 @@ import System.Mem (performGC)
1616
import System.Mem.Weak (mkWeakPtr, deRefWeak)
1717
import System.Random (randomIO)
1818
import Test.HUnit (Assertion, assert)
19-
import Test.Tasty (TestTree, defaultMain, testGroup)
19+
import Test.Tasty (TestTree, testGroup)
2020
import Test.Tasty.HUnit (testCase)
2121
import Test.Tasty.QuickCheck (testProperty)
2222
import Test.QuickCheck
@@ -135,9 +135,3 @@ tests = testGroup "Regression tests"
135135
, testCase "issue254 lazy" issue254Lazy
136136
, testCase "issue254 strict" issue254Strict
137137
]
138-
139-
------------------------------------------------------------------------
140-
-- * Test harness
141-
142-
main :: IO ()
143-
main = defaultMain tests

tests/Strictness.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{-# LANGUAGE CPP, FlexibleInstances, GeneralizedNewtypeDeriving #-}
22
{-# OPTIONS_GHC -fno-warn-orphans #-}
33

4-
module Main (main) where
4+
module Strictness (tests) where
55

66
import Data.Hashable (Hashable(hashWithSalt))
77
import Test.ChasingBottoms.IsBottom
8-
import Test.Tasty (TestTree, defaultMain, testGroup)
8+
import Test.Tasty (TestTree, testGroup)
99
import Test.Tasty.QuickCheck (testProperty)
1010
import Test.QuickCheck (Arbitrary(arbitrary), Property, (===), (.&&.))
1111
import Test.QuickCheck.Function
@@ -150,7 +150,7 @@ pFromListWithValueResultStrict lst comb_lazy calc_good_raw
150150
-- * Test list
151151

152152
tests :: TestTree
153-
tests = testGroup "Strictness tests"
153+
tests = testGroup "Strictness"
154154
[
155155
-- Basic interface
156156
testGroup "HashMap.Strict"
@@ -175,12 +175,6 @@ tests = testGroup "Strictness tests"
175175
]
176176
]
177177

178-
------------------------------------------------------------------------
179-
-- * Test harness
180-
181-
main :: IO ()
182-
main = defaultMain tests
183-
184178
------------------------------------------------------------------------
185179
-- * Utilities
186180

unordered-containers.cabal

Lines changed: 11 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -78,85 +78,23 @@ library
7878
if flag(debug)
7979
cpp-options: -DASSERTS
8080

81-
test-suite hashmap-lazy-properties
81+
test-suite unordered-containers-tests
8282
hs-source-dirs: tests
83-
main-is: HashMapProperties.hs
83+
main-is: Main.hs
8484
type: exitcode-stdio-1.0
85-
86-
build-depends:
87-
base,
88-
containers >= 0.5.8,
89-
hashable >= 1.0.1.1,
90-
QuickCheck >= 2.4.0.1,
91-
tasty >= 1.4.0.3,
92-
tasty-quickcheck >= 0.10.1.2,
93-
unordered-containers
94-
95-
default-language: Haskell2010
96-
ghc-options: -Wall
97-
cpp-options: -DASSERTS
98-
99-
test-suite hashmap-strict-properties
100-
hs-source-dirs: tests
101-
main-is: HashMapProperties.hs
102-
type: exitcode-stdio-1.0
103-
104-
build-depends:
105-
base,
106-
containers >= 0.5.8,
107-
hashable >= 1.0.1.1,
108-
QuickCheck >= 2.4.0.1,
109-
tasty >= 1.4.0.3,
110-
tasty-quickcheck >= 0.10.1.2,
111-
unordered-containers
112-
113-
default-language: Haskell2010
114-
ghc-options: -Wall
115-
cpp-options: -DASSERTS -DSTRICT
116-
117-
test-suite hashset-properties
118-
hs-source-dirs: tests
119-
main-is: HashSetProperties.hs
120-
type: exitcode-stdio-1.0
121-
122-
build-depends:
123-
base,
124-
containers >= 0.4.2.0,
125-
hashable >= 1.0.1.1,
126-
QuickCheck >= 2.4.0.1,
127-
tasty >= 1.4.0.3,
128-
tasty-quickcheck >= 0.10.1.2,
129-
unordered-containers
130-
131-
default-language: Haskell2010
132-
ghc-options: -Wall
133-
cpp-options: -DASSERTS
134-
135-
test-suite list-tests
136-
hs-source-dirs: tests .
137-
main-is: List.hs
13885
other-modules:
139-
Data.HashMap.Internal.List
140-
type: exitcode-stdio-1.0
141-
142-
build-depends:
143-
base,
144-
containers >= 0.4,
145-
QuickCheck >= 2.4.0.1,
146-
tasty >= 1.4.0.3,
147-
tasty-quickcheck >= 0.10.1.2
148-
149-
default-language: Haskell2010
150-
ghc-options: -Wall
151-
cpp-options: -DASSERTS
152-
153-
test-suite regressions
154-
hs-source-dirs: tests
155-
main-is: Regressions.hs
156-
type: exitcode-stdio-1.0
86+
Regressions
87+
Properties
88+
Properties.HashMapLazy
89+
Properties.HashMapStrict
90+
Properties.HashSet
91+
Properties.List
92+
Strictness
15793

15894
build-depends:
15995
base,
96+
ChasingBottoms,
97+
containers >= 0.5.8,
16098
hashable >= 1.0.1.1,
16199
HUnit,
162100
QuickCheck >= 2.4.0.1,
@@ -170,25 +108,6 @@ test-suite regressions
170108
ghc-options: -Wall
171109
cpp-options: -DASSERTS
172110

173-
test-suite strictness-properties
174-
hs-source-dirs: tests
175-
main-is: Strictness.hs
176-
type: exitcode-stdio-1.0
177-
178-
build-depends:
179-
base,
180-
ChasingBottoms,
181-
containers >= 0.4.2,
182-
hashable >= 1.0.1.1,
183-
QuickCheck >= 2.4.0.1,
184-
tasty >= 1.4.0.3,
185-
tasty-quickcheck >= 0.10.1.2,
186-
unordered-containers
187-
188-
default-language: Haskell2010
189-
ghc-options: -Wall
190-
cpp-options: -DASSERTS
191-
192111
benchmark benchmarks
193112
hs-source-dirs: benchmarks
194113
main-is: Benchmarks.hs

0 commit comments

Comments
 (0)