From 663d920cd05c18248d8febbdbf28c279216e0af5 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Wed, 24 Jan 2024 21:40:23 +0300 Subject: [PATCH] Expose tests as a library as well Fixes #459 --- vector/{tests => tests-exe}/Main.hs | 0 vector/vector.cabal | 126 +++++++++++++++------------- 2 files changed, 66 insertions(+), 60 deletions(-) rename vector/{tests => tests-exe}/Main.hs (100%) diff --git a/vector/tests/Main.hs b/vector/tests-exe/Main.hs similarity index 100% rename from vector/tests/Main.hs rename to vector/tests-exe/Main.hs diff --git a/vector/vector.cabal b/vector/vector.cabal index 41a89142..7e780c0b 100644 --- a/vector/vector.cabal +++ b/vector/vector.cabal @@ -55,7 +55,7 @@ Tested-With: GHC == 9.4.6 GHC == 9.6.2 GHC == 9.8.1 - + Extra-doc-files: changelog.md @@ -63,7 +63,6 @@ Extra-doc-files: tests/LICENSE Extra-Source-Files: tests/Setup.hs - tests/Main.hs internal/GenUnboxTuple.hs internal/unbox-tuple-instances @@ -177,31 +176,26 @@ Library cpp-options: -DVECTOR_INTERNAL_CHECKS - -test-suite vector-tests-O0 +-- We want to build test suite in two variants. One built with -O0 +-- and another with -O2 in order to catch bugs caused by invalid +-- rewrite rules +common testlib import: flag-Wall Default-Language: Haskell2010 - type: exitcode-stdio-1.0 - Main-Is: Main.hs - - other-modules: Boilerplater - Tests.Bundle - Tests.Move - Tests.Vector - Tests.Vector.Property - Tests.Vector.Boxed - Tests.Vector.Storable - Tests.Vector.Primitive - Tests.Vector.Unboxed - Tests.Vector.UnitTests - Utilities - - hs-source-dirs: tests - Build-Depends: base >= 4.5 && < 5, template-haskell, base-orphans >= 0.6, vector, - primitive, random, - QuickCheck >= 2.9 && < 2.15, HUnit, tasty, - tasty-hunit, tasty-quickcheck, - transformers >= 0.2.0.0 + Ghc-Options: -fno-warn-missing-signatures + hs-source-dirs: tests + Build-Depends: base >= 4.5 && < 5 + , template-haskell + , base-orphans >= 0.6 + , vector + , primitive + , random + , QuickCheck >= 2.9 && < 2.15 + , HUnit + , tasty + , tasty-hunit + , tasty-quickcheck + , transformers >= 0.2.0.0 default-extensions: CPP, ScopedTypeVariables, @@ -213,46 +207,58 @@ test-suite vector-tests-O0 TypeFamilies, TemplateHaskell - Ghc-Options: -O0 -threaded - Ghc-Options: -fno-warn-missing-signatures +library tests-O0 + import: testlib + Exposed-Modules: + Boilerplater + Tests.Bundle + Tests.Move + Tests.Vector + Tests.Vector.Property + Tests.Vector.Boxed + Tests.Vector.Storable + Tests.Vector.Primitive + Tests.Vector.Unboxed + Tests.Vector.UnitTests + Utilities + Ghc-Options: -O0 + +library tests-O2 + import: testlib + Exposed-Modules: + Boilerplater + Tests.Bundle + Tests.Move + Tests.Vector + Tests.Vector.Property + Tests.Vector.Boxed + Tests.Vector.Storable + Tests.Vector.Primitive + Tests.Vector.Unboxed + Tests.Vector.UnitTests + Utilities + Ghc-Options: -O2 -test-suite vector-tests-O2 +common tests-exe import: flag-Wall Default-Language: Haskell2010 - type: exitcode-stdio-1.0 - Main-Is: Main.hs - - other-modules: Boilerplater - Tests.Bundle - Tests.Move - Tests.Vector - Tests.Vector.Property - Tests.Vector.Boxed - Tests.Vector.Storable - Tests.Vector.Primitive - Tests.Vector.Unboxed - Tests.Vector.UnitTests - Utilities - - hs-source-dirs: tests - Build-Depends: base >= 4.5 && < 5, template-haskell, base-orphans >= 0.6, vector, - primitive, random, - QuickCheck >= 2.9 && < 2.15, HUnit, tasty, - tasty-hunit, tasty-quickcheck, - transformers >= 0.2.0.0 + hs-source-dirs: tests-exe + Build-Depends: base >= 4.5 && < 5 + , tasty - default-extensions: CPP, - ScopedTypeVariables, - PatternGuards, - MultiParamTypeClasses, - FlexibleContexts, - RankNTypes, - TypeSynonymInstances, - TypeFamilies, - TemplateHaskell +test-suite vector-tests-O0 + import: tests-exe + type: exitcode-stdio-1.0 + Main-Is: Main.hs + Ghc-Options: -O0 -threaded + Build-Depends: vector:tests-O0 - Ghc-Options: -O2 -threaded - Ghc-Options: -fno-warn-missing-signatures +test-suite vector-tests-O2 + import: tests-exe + type: exitcode-stdio-1.0 + Main-Is: Main.hs + Ghc-Options: -O2 -threaded + Build-Depends: vector:tests-O2 test-suite vector-doctest type: exitcode-stdio-1.0