From be95a40a62facfa940c036a49a2d57a670abf477 Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Wed, 27 May 2020 04:21:15 -0400 Subject: [PATCH 1/2] Refactor CI avoiding test circular dependencies Instead of running tests in the parent "bytestring" project, with circular dependencies from the test frameworks, build and run them in the child `bytestring-tests` project, which builds the parent as a dependency that does not run tests, avoiding all the loops. This requires cabal-install >= 2.4 with cabal.project doing most of the heavy lifting. --- .travis.yml | 58 ++++------ bytestring.cabal | 108 ------------------ cabal.project | 3 + .../builder/Data/ByteString/Builder/Tests.hs | 2 +- tests/bytestring-tests.cabal | 48 +++++--- tests/cabal.project | 2 + 6 files changed, 66 insertions(+), 155 deletions(-) create mode 100644 cabal.project create mode 100644 tests/cabal.project diff --git a/.travis.yml b/.travis.yml index afa8f0f10..60dfd553b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,23 @@ env: # Note: We have to use Cabal 2.4 with GHC 7.0 since for some reason # builds of "text" fail with GHC 7.0 and Cabal versions prior to 2.4 # https://github.com/haskell/bytestring/issues/213 + # With Cabal 2.4 we also get improved syntax in cabal.project files, + # supporting remote sources, and other goodies, so use it across the + # board. + # - GHCVER=7.0.4 CABALVER=2.4 - - GHCVER=7.2.2 CABALVER=1.16 - # we have to use CABALVER=1.16 for GHC<7.6 as well, as there's - # no package for earlier cabal versions in the PPA - - GHCVER=7.4.2 CABALVER=1.16 - - GHCVER=7.6.3 CABALVER=1.16 - - GHCVER=7.8.4 CABALVER=1.18 - - GHCVER=7.10.3 CABALVER=1.22 - - GHCVER=8.0.2 CABALVER=1.24 - - GHCVER=8.2.2 CABALVER=2.0 - - GHCVER=8.4.4 CABALVER=2.2 + - GHCVER=7.2.2 CABALVER=2.4 + - GHCVER=7.4.2 CABALVER=2.4 + - GHCVER=7.6.3 CABALVER=2.4 + - GHCVER=7.8.4 CABALVER=2.4 + - GHCVER=7.10.3 CABALVER=2.4 + - GHCVER=8.0.2 CABALVER=2.4 + - GHCVER=8.2.2 CABALVER=2.4 + - GHCVER=8.4.4 CABALVER=2.4 - GHCVER=8.6.5 CABALVER=2.4 - - GHCVER=8.8.3 CABALVER=2.4 - - GHCVER=8.10.1 CABALVER=2.4 + - GHCVER=8.8.3 CABALVER=3.0 + - GHCVER=8.10.1 CABALVER=3.2 + ### The head in "ppa", currently 8.7, is no longer worth testing. # - GHCVER=head CABALVER=2.4 @@ -32,31 +35,20 @@ before_install: install: - travis_retry cabal update - # can't use "cabal install --only-dependencies --enable-tests" due to dep-cycle - - cabal install - "QuickCheck >=2.10 && <2.14" - "byteorder ==1.0.*" - "dlist >=0.5 && <0.9" - "mtl >=2.0 && <2.3" - deepseq test-framework-hunit test-framework-quickcheck2 script: - - cabal configure --enable-tests -v2 - - cabal build - # --show-details=streaming is available for CABALVER>=1.20 only - - if [ "$(echo -e "1.20\n$CABALVER" | sort -rV | head -n1)" = "$CABALVER" ]; then - cabal test --show-details=streaming; - else - travis_wait cabal test --show-details=always; - fi - - cabal sdist + - cabal v2-configure; cabal v2-build + - cabal v2-sdist -o . + # Remove to enable build of sdist. + - rm -f cabal.project + - rm -f tests/test-builder.tix + - (cd tests; cabal v2-configure; cabal v2-test) # "cabal check" disabled due to -O2 warning - - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ; - cd dist/; - if [ -f "$SRC_TGZ" ]; then - cabal install --force-reinstalls "$SRC_TGZ"; + - export SRC=$(cabal info . | awk '{print $2; exit}'); + if [ -f "$SRC.tar.gz" ]; then + cabal get "./$SRC.tar.gz"; + (cd "$SRC"; cabal v2-build); else echo "expected '$SRC_TGZ' not found"; exit 1; fi - diff --git a/bytestring.cabal b/bytestring.cabal index 558e1ef69..59e7c61a8 100644 --- a/bytestring.cabal +++ b/bytestring.cabal @@ -146,111 +146,3 @@ library if impl(ghc >= 6.9) && impl(ghc < 6.11) cpp-options: -DINTEGER_GMP build-depends: integer >= 0.1 && < 0.2 - - --- QC properties, with GHC RULES disabled -test-suite prop-compiled - type: exitcode-stdio-1.0 - main-is: Properties.hs - other-modules: Rules - QuickCheckUtils - TestFramework - Data.ByteString - Data.ByteString.Char8 - Data.ByteString.Internal - Data.ByteString.Lazy - Data.ByteString.Lazy.Char8 - Data.ByteString.Lazy.Internal - Data.ByteString.Short - Data.ByteString.Short.Internal - Data.ByteString.Unsafe - hs-source-dirs: . tests - build-depends: base, ghc-prim, deepseq, random, directory, - test-framework, test-framework-quickcheck2, - QuickCheck >= 2.10 && < 2.15 - c-sources: cbits/fpstring.c - include-dirs: include - ghc-options: -fwarn-unused-binds - -fno-enable-rewrite-rules - -threaded -rtsopts - cpp-options: -DHAVE_TEST_FRAMEWORK=1 - default-language: Haskell98 - -- older ghc had issues with language pragmas guarded by cpp - if impl(ghc < 7) - default-extensions: CPP, MagicHash, UnboxedTuples, - DeriveDataTypeable, BangPatterns, - NamedFieldPuns - -test-suite regressions - -- temporarily disabled as it allocates too much memory - buildable: False - type: exitcode-stdio-1.0 - main-is: Regressions.hs - hs-source-dirs: . tests - build-depends: base, ghc-prim, deepseq, random, directory, - test-framework, test-framework-hunit, HUnit - c-sources: cbits/fpstring.c - include-dirs: include - ghc-options: -fwarn-unused-binds - -fno-enable-rewrite-rules - -threaded -rtsopts - default-language: Haskell98 - -- older ghc had issues with language pragmas guarded by cpp - if impl(ghc < 7) - default-extensions: CPP, MagicHash, UnboxedTuples, - DeriveDataTypeable, BangPatterns, - NamedFieldPuns - -test-suite test-builder - type: exitcode-stdio-1.0 - hs-source-dirs: . tests tests/builder - main-is: TestSuite.hs - other-modules: Data.ByteString - Data.ByteString.Internal - Data.ByteString.Lazy - Data.ByteString.Lazy.Internal - Data.ByteString.Short - Data.ByteString.Short.Internal - Data.ByteString.Unsafe - Data.ByteString.Builder - Data.ByteString.Builder.ASCII - Data.ByteString.Builder.Extra - Data.ByteString.Builder.Internal - Data.ByteString.Builder.Prim - Data.ByteString.Builder.Prim.ASCII - Data.ByteString.Builder.Prim.Binary - Data.ByteString.Builder.Prim.Internal - Data.ByteString.Builder.Prim.Internal.Base16 - Data.ByteString.Builder.Prim.Internal.Floating - Data.ByteString.Builder.Prim.Internal.UncheckedShifts - Data.ByteString.Builder.Prim.TestUtils - Data.ByteString.Builder.Prim.Tests - Data.ByteString.Builder.Tests - TestFramework - build-depends: base, ghc-prim, - deepseq, - QuickCheck >= 2.10 && < 2.15, - byteorder == 1.0.*, - dlist >= 0.5 && < 0.9, - directory, - mtl >= 2.0 && < 2.3, - HUnit, - test-framework, - test-framework-hunit, - test-framework-quickcheck2 - - ghc-options: -Wall -fwarn-tabs -threaded -rtsopts - cpp-options: -DHAVE_TEST_FRAMEWORK=1 - - default-language: Haskell98 - -- older ghc had issues with language pragmas guarded by cpp - if impl(ghc < 7) - default-extensions: CPP, MagicHash, UnboxedTuples, - DeriveDataTypeable, BangPatterns, - NamedFieldPuns - - c-sources: cbits/fpstring.c - cbits/itoa.c - include-dirs: include - includes: fpstring.h - install-includes: fpstring.h diff --git a/cabal.project b/cabal.project new file mode 100644 index 000000000..37455ba81 --- /dev/null +++ b/cabal.project @@ -0,0 +1,3 @@ +packages: bytestring.cabal +tests: False +benchmarks: False diff --git a/tests/builder/Data/ByteString/Builder/Tests.hs b/tests/builder/Data/ByteString/Builder/Tests.hs index b28848c46..adae7b9af 100644 --- a/tests/builder/Data/ByteString/Builder/Tests.hs +++ b/tests/builder/Data/ByteString/Builder/Tests.hs @@ -21,7 +21,7 @@ import Control.Monad.Writer import Foreign (Word, Word8, minusPtr) import System.IO.Unsafe (unsafePerformIO) -import Data.Char (ord, chr) +import Data.Char (chr) import qualified Data.DList as D import Data.Foldable (asum, foldMap) diff --git a/tests/bytestring-tests.cabal b/tests/bytestring-tests.cabal index 503d7bb14..c59710d3b 100644 --- a/tests/bytestring-tests.cabal +++ b/tests/bytestring-tests.cabal @@ -20,10 +20,20 @@ flag integer-simple default: False -- QC properties, with GHC RULES disabled -executable prop-compiled +test-suite prop-compiled + type: exitcode-stdio-1.0 main-is: Properties.hs other-modules: Rules QuickCheckUtils + Data.ByteString + Data.ByteString.Char8 + Data.ByteString.Internal + Data.ByteString.Lazy + Data.ByteString.Lazy.Char8 + Data.ByteString.Lazy.Internal + Data.ByteString.Short + Data.ByteString.Short.Internal + Data.ByteString.Unsafe hs-source-dirs: . .. build-depends: base, ghc-prim, deepseq, random, directory, test-framework, test-framework-quickcheck2, @@ -37,13 +47,14 @@ executable prop-compiled extensions: BangPatterns UnliftedFFITypes, MagicHash, - UnboxedTuples, - DeriveDataTypeable ScopedTypeVariables NamedFieldPuns executable regressions main-is: Regressions.hs + other-modules: Data.ByteString + Data.ByteString.Internal + Data.ByteString.Unsafe hs-source-dirs: . .. build-depends: base, ghc-prim, deepseq, random, directory, test-framework, test-framework-hunit, HUnit @@ -56,18 +67,34 @@ executable regressions extensions: BangPatterns UnliftedFFITypes, MagicHash, - UnboxedTuples, - DeriveDataTypeable ScopedTypeVariables NamedFieldPuns -executable test-builder +test-suite test-builder + type: exitcode-stdio-1.0 hs-source-dirs: . .. builder main-is: TestSuite.hs other-modules: Data.ByteString.Builder.Tests Data.ByteString.Builder.Prim.Tests Data.ByteString.Builder.Prim.TestUtils - + Data.ByteString + Data.ByteString.Builder + Data.ByteString.Builder.ASCII + Data.ByteString.Builder.Extra + Data.ByteString.Builder.Internal + Data.ByteString.Builder.Prim + Data.ByteString.Builder.Prim.ASCII + Data.ByteString.Builder.Prim.Binary + Data.ByteString.Builder.Prim.Internal + Data.ByteString.Builder.Prim.Internal.Base16 + Data.ByteString.Builder.Prim.Internal.Floating + Data.ByteString.Builder.Prim.Internal.UncheckedShifts + Data.ByteString.Internal + Data.ByteString.Lazy + Data.ByteString.Lazy.Internal + Data.ByteString.Short + Data.ByteString.Short.Internal + Data.ByteString.Unsafe build-depends: base, ghc-prim, deepseq, QuickCheck >= 2.10 && < 2.15, @@ -79,20 +106,15 @@ executable test-builder test-framework, test-framework-hunit, test-framework-quickcheck2 >= 0.3 - cpp-options: -DHAVE_TEST_FRAMEWORK=1 - ghc-options: -Wall -fwarn-tabs -fhpc -threaded -rtsopts - + ghc-options: -Wall -fwarn-tabs -threaded -rtsopts extensions: CPP, ForeignFunctionInterface UnliftedFFITypes, MagicHash, - UnboxedTuples, - DeriveDataTypeable ScopedTypeVariables Rank2Types BangPatterns NamedFieldPuns - c-sources: ../cbits/fpstring.c ../cbits/itoa.c include-dirs: ../include diff --git a/tests/cabal.project b/tests/cabal.project new file mode 100644 index 000000000..edc082c9c --- /dev/null +++ b/tests/cabal.project @@ -0,0 +1,2 @@ +packages: bytestring-tests.cabal +tests: True From ddf8d43fbe6d791a4e14281f453147733f4ef791 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Thu, 2 Jul 2020 11:53:25 +0200 Subject: [PATCH 2/2] .travis.yml: Remove unnecessary .tix file deletion step --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 60dfd553b..802d85612 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,6 @@ script: - cabal v2-sdist -o . # Remove to enable build of sdist. - rm -f cabal.project - - rm -f tests/test-builder.tix - (cd tests; cabal v2-configure; cabal v2-test) # "cabal check" disabled due to -O2 warning - export SRC=$(cabal info . | awk '{print $2; exit}');