From 6140c737741469169d756e1284dcdbfc7a945a3d Mon Sep 17 00:00:00 2001 From: meooow25 Date: Sun, 22 Feb 2026 22:08:53 +0100 Subject: [PATCH] Move test and benchmark utils into sublibraries This organizes them better, avoid repetition in the cabal file, and avoid recompiling the same files for different targets. --- .../SetOperations.hs | 0 .../Utils/Fold.hs | 0 .../Utils/Random.hs | 0 containers-tests/containers-tests.cabal | 164 +++++++++--------- .../{tests => test-utils}/IntMapValidity.hs | 2 +- .../{tests => test-utils}/IntSetValidity.hs | 2 +- .../Utils/ArbitrarySetMap.hs | 0 .../{tests => test-utils}/Utils/MergeFunc.hs | 0 .../{tests => test-utils}/Utils/NubSorted.hs | 0 .../{tests => test-utils}/Utils/Strictness.hs | 0 10 files changed, 80 insertions(+), 88 deletions(-) rename containers-tests/{benchmarks/SetOperations => benchmark-utils}/SetOperations.hs (100%) rename containers-tests/{benchmarks => benchmark-utils}/Utils/Fold.hs (100%) rename containers-tests/{benchmarks => benchmark-utils}/Utils/Random.hs (100%) rename containers-tests/{tests => test-utils}/IntMapValidity.hs (97%) rename containers-tests/{tests => test-utils}/IntSetValidity.hs (97%) rename containers-tests/{tests => test-utils}/Utils/ArbitrarySetMap.hs (100%) rename containers-tests/{tests => test-utils}/Utils/MergeFunc.hs (100%) rename containers-tests/{tests => test-utils}/Utils/NubSorted.hs (100%) rename containers-tests/{tests => test-utils}/Utils/Strictness.hs (100%) diff --git a/containers-tests/benchmarks/SetOperations/SetOperations.hs b/containers-tests/benchmark-utils/SetOperations.hs similarity index 100% rename from containers-tests/benchmarks/SetOperations/SetOperations.hs rename to containers-tests/benchmark-utils/SetOperations.hs diff --git a/containers-tests/benchmarks/Utils/Fold.hs b/containers-tests/benchmark-utils/Utils/Fold.hs similarity index 100% rename from containers-tests/benchmarks/Utils/Fold.hs rename to containers-tests/benchmark-utils/Utils/Fold.hs diff --git a/containers-tests/benchmarks/Utils/Random.hs b/containers-tests/benchmark-utils/Utils/Random.hs similarity index 100% rename from containers-tests/benchmarks/Utils/Random.hs rename to containers-tests/benchmark-utils/Utils/Random.hs diff --git a/containers-tests/containers-tests.cabal b/containers-tests/containers-tests.cabal index 63a2ba048..83d3a4b67 100644 --- a/containers-tests/containers-tests.cabal +++ b/containers-tests/containers-tests.cabal @@ -132,6 +132,22 @@ library -- B E N C H M A R K I N G -- ----------------------------- +library benchmark-utils + import: deps, warnings + default-language: Haskell2010 + hs-source-dirs: benchmark-utils + + build-depends: + containers-tests + , random >=1.0 && <1.3 + , transformers + , tasty-bench + + exposed-modules: + SetOperations + Utils.Fold + Utils.Random + benchmark intmap-benchmarks import: benchmark-deps, warnings default-language: Haskell2010 @@ -140,11 +156,8 @@ benchmark intmap-benchmarks main-is: IntMap.hs ghc-options: -O2 - other-modules: - Utils.Fold - build-depends: - transformers + benchmark-utils , random >=1.0 && <1.3 benchmark intset-benchmarks @@ -155,11 +168,8 @@ benchmark intset-benchmarks main-is: IntSet.hs ghc-options: -O2 - other-modules: - Utils.Fold - build-depends: - transformers + benchmark-utils , random >=1.0 && <1.3 benchmark map-benchmarks @@ -172,14 +182,8 @@ benchmark map-benchmarks build-depends: random >=1.0 && <1.3 - other-modules: - Utils.Random - - other-modules: - Utils.Fold - build-depends: - transformers + benchmark-utils benchmark tree-benchmarks import: benchmark-deps, warnings @@ -189,11 +193,8 @@ benchmark tree-benchmarks main-is: Tree.hs ghc-options: -O2 - other-modules: - Utils.Fold - build-depends: - transformers + benchmark-utils benchmark sequence-benchmarks import: benchmark-deps, warnings @@ -203,15 +204,10 @@ benchmark sequence-benchmarks main-is: Sequence.hs ghc-options: -O2 build-depends: - random >=1.0 && <1.3 + benchmark-utils + , random >=1.0 && <1.3 , transformers - other-modules: - Utils.Fold - - build-depends: - transformers - benchmark set-benchmarks import: benchmark-deps, warnings default-language: Haskell2010 @@ -219,17 +215,9 @@ benchmark set-benchmarks hs-source-dirs: benchmarks main-is: Set.hs ghc-options: -O2 - build-depends: - random >=1.0 && <1.3 - - other-modules: - Utils.Random - - other-modules: - Utils.Fold build-depends: - transformers + benchmark-utils benchmark graph-benchmarks import: benchmark-deps, warnings @@ -247,33 +235,33 @@ benchmark set-operations-intmap type: exitcode-stdio-1.0 hs-source-dirs: benchmarks/SetOperations main-is: SetOperations-IntMap.hs - other-modules: SetOperations ghc-options: -O2 + build-depends: + benchmark-utils + benchmark set-operations-intset import: benchmark-deps, warnings default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: benchmarks/SetOperations main-is: SetOperations-IntSet.hs - other-modules: SetOperations ghc-options: -O2 + build-depends: + benchmark-utils + benchmark set-operations-map import: benchmark-deps, warnings default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: benchmarks/SetOperations - benchmarks main-is: SetOperations-Map.hs - other-modules: SetOperations ghc-options: -O2 - build-depends: - random >=1.0 && <1.3 - other-modules: - Utils.Random + build-depends: + benchmark-utils benchmark set-operations-set import: benchmark-deps, warnings @@ -281,15 +269,11 @@ benchmark set-operations-set type: exitcode-stdio-1.0 hs-source-dirs: benchmarks/SetOperations - benchmarks main-is: SetOperations-Set.hs - other-modules: SetOperations ghc-options: -O2 - build-depends: - random >=1.0 && <1.3 - other-modules: - Utils.Random + build-depends: + benchmark-utils benchmark lookupge-intmap import: benchmark-deps, warnings @@ -315,6 +299,25 @@ benchmark lookupge-map -- Every test-suite contains the build-depends and options of the library, -- plus the testing stuff. +library test-utils + import: deps, warnings + default-language: Haskell2010 + hs-source-dirs: test-utils + + build-depends: + containers-tests + , ChasingBottoms + , QuickCheck + , transformers + + exposed-modules: + IntMapValidity + IntSetValidity + Utils.ArbitrarySetMap + Utils.MergeFunc + Utils.NubSorted + Utils.Strictness + test-suite map-lazy-properties import: test-deps, warnings default-language: Haskell2010 @@ -322,8 +325,8 @@ test-suite map-lazy-properties main-is: map-properties.hs type: exitcode-stdio-1.0 - other-modules: - Utils.ArbitrarySetMap + build-depends: + test-utils ghc-options: -O2 other-extensions: @@ -338,8 +341,8 @@ test-suite map-strict-properties type: exitcode-stdio-1.0 cpp-options: -DSTRICT - other-modules: - Utils.ArbitrarySetMap + build-depends: + test-utils ghc-options: -O2 other-extensions: @@ -364,8 +367,8 @@ test-suite set-properties main-is: set-properties.hs type: exitcode-stdio-1.0 - other-modules: - Utils.ArbitrarySetMap + build-depends: + test-utils ghc-options: -O2 other-extensions: @@ -378,7 +381,9 @@ test-suite intmap-lazy-properties hs-source-dirs: tests main-is: intmap-properties.hs type: exitcode-stdio-1.0 - other-modules: IntMapValidity + + build-depends: + test-utils ghc-options: -O2 other-extensions: @@ -392,7 +397,9 @@ test-suite intmap-strict-properties main-is: intmap-properties.hs type: exitcode-stdio-1.0 cpp-options: -DSTRICT - other-modules: IntMapValidity + + build-depends: + test-utils ghc-options: -O2 other-extensions: @@ -405,7 +412,9 @@ test-suite intset-properties hs-source-dirs: tests main-is: intset-properties.hs type: exitcode-stdio-1.0 - other-modules: IntSetValidity + + build-depends: + test-utils ghc-options: -O2 other-extensions: @@ -418,17 +427,16 @@ test-suite seq-properties hs-source-dirs: tests main-is: seq-properties.hs type: exitcode-stdio-1.0 + build-depends: - ChasingBottoms + test-utils + , ChasingBottoms ghc-options: -O2 other-extensions: BangPatterns CPP - other-modules: - Utils.Strictness - test-suite tree-properties import: test-deps, warnings default-language: Haskell2010 @@ -456,19 +464,14 @@ test-suite map-strictness-properties main-is: map-strictness.hs type: exitcode-stdio-1.0 build-depends: - ChasingBottoms + test-utils + , ChasingBottoms ghc-options: -Wall other-extensions: BangPatterns CPP - other-modules: - Utils.ArbitrarySetMap - Utils.MergeFunc - Utils.NubSorted - Utils.Strictness - test-suite intmap-strictness-properties import: test-deps, warnings default-language: Haskell2010 @@ -480,15 +483,11 @@ test-suite intmap-strictness-properties CPP build-depends: - ChasingBottoms + test-utils + , ChasingBottoms ghc-options: -Wall - other-modules: - Utils.MergeFunc - Utils.NubSorted - Utils.Strictness - test-suite set-strictness-properties import: test-deps, warnings default-language: Haskell2010 @@ -500,15 +499,11 @@ test-suite set-strictness-properties CPP build-depends: - ChasingBottoms + test-utils + , ChasingBottoms ghc-options: -Wall - other-modules: - Utils.ArbitrarySetMap - Utils.NubSorted - Utils.Strictness - test-suite intset-strictness-properties import: test-deps, warnings default-language: Haskell2010 @@ -520,14 +515,11 @@ test-suite intset-strictness-properties CPP build-depends: - ChasingBottoms + test-utils + , ChasingBottoms ghc-options: -Wall - other-modules: - Utils.NubSorted - Utils.Strictness - test-suite listutils-properties import: test-deps, warnings default-language: Haskell2010 diff --git a/containers-tests/tests/IntMapValidity.hs b/containers-tests/test-utils/IntMapValidity.hs similarity index 97% rename from containers-tests/tests/IntMapValidity.hs rename to containers-tests/test-utils/IntMapValidity.hs index 1374406c1..cbd4faf1c 100644 --- a/containers-tests/tests/IntMapValidity.hs +++ b/containers-tests/test-utils/IntMapValidity.hs @@ -9,7 +9,7 @@ import Data.List (intercalate, elemIndex) import Data.IntSet.Internal.IntTreeCommons (Prefix(..), nomatch) import Data.IntMap.Internal import Numeric (showHex) -import Test.Tasty.QuickCheck (Property, counterexample, property, (.&&.)) +import Test.QuickCheck (Property, counterexample, property, (.&&.)) {-------------------------------------------------------------------- Assertions diff --git a/containers-tests/tests/IntSetValidity.hs b/containers-tests/test-utils/IntSetValidity.hs similarity index 97% rename from containers-tests/tests/IntSetValidity.hs rename to containers-tests/test-utils/IntSetValidity.hs index b3d2ccc3f..9262d2e56 100644 --- a/containers-tests/tests/IntSetValidity.hs +++ b/containers-tests/test-utils/IntSetValidity.hs @@ -6,7 +6,7 @@ import Data.IntSet.Internal.IntTreeCommons (Prefix(..), nomatch) import Data.IntSet.Internal import Data.List (intercalate) import Numeric (showHex) -import Test.Tasty.QuickCheck (Property, counterexample, property, (.&&.)) +import Test.QuickCheck (Property, counterexample, property, (.&&.)) #include "containers.h" diff --git a/containers-tests/tests/Utils/ArbitrarySetMap.hs b/containers-tests/test-utils/Utils/ArbitrarySetMap.hs similarity index 100% rename from containers-tests/tests/Utils/ArbitrarySetMap.hs rename to containers-tests/test-utils/Utils/ArbitrarySetMap.hs diff --git a/containers-tests/tests/Utils/MergeFunc.hs b/containers-tests/test-utils/Utils/MergeFunc.hs similarity index 100% rename from containers-tests/tests/Utils/MergeFunc.hs rename to containers-tests/test-utils/Utils/MergeFunc.hs diff --git a/containers-tests/tests/Utils/NubSorted.hs b/containers-tests/test-utils/Utils/NubSorted.hs similarity index 100% rename from containers-tests/tests/Utils/NubSorted.hs rename to containers-tests/test-utils/Utils/NubSorted.hs diff --git a/containers-tests/tests/Utils/Strictness.hs b/containers-tests/test-utils/Utils/Strictness.hs similarity index 100% rename from containers-tests/tests/Utils/Strictness.hs rename to containers-tests/test-utils/Utils/Strictness.hs