Skip to content

Commit

Permalink
Move tests from Cabal to Cabal-tests package
Browse files Browse the repository at this point in the history
The are various motivation points:
- I'm not aware anyone third party running Cabal tests (maybe nixpkgs?)
- No need to do gen-extra-source-files, as Cabal-tests is not distributed
- No multiple rebuilds of Cabal-QuickCheck, Cabal-tree-diff
- Slightly smaller Cabal sdist (which is quite big still)
  • Loading branch information
phadej committed Oct 13, 2020
1 parent 2c86483 commit 579bff0
Show file tree
Hide file tree
Showing 326 changed files with 323 additions and 674 deletions.
1 change: 0 additions & 1 deletion .github/workflows/quick-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
- name: Regenerate files
run: |
make lexer
make gen-extra-source-files
make spdx
make templates
make github-actions
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
run: cabal v2-build Cabal --only-dependencies
- name: cabal v2-build
run: cabal v2-build all
- name: Cabal unit-tests
run: |
cabal v2-test Cabal-tests
- name: cabal-install memory-usage-tests
run: |
cd cabal-install
Expand All @@ -72,7 +75,7 @@ jobs:
cabal v2-run cabal-install:unit-tests -- --pattern "! (/FileMonitor/ || /VCS/ || /Get/)"
- name: cabal-tests
# Using only one job, -j1, to fail less.
run: cabal v2-run cabal-tests -- -j1 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-install-3.5.0.0\x\cabal\build\cabal\cabal.exe
run: cabal v2-run cabal-testsuite:cabal-tests -- -j1 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-install-3.5.0.0\x\cabal\build\cabal\cabal.exe
test-windows-8_8_4:
name: test ghc-8.8.4
runs-on: windows-latest
Expand Down Expand Up @@ -109,6 +112,9 @@ jobs:
run: cabal v2-build Cabal --only-dependencies
- name: cabal v2-build
run: cabal v2-build all
- name: Cabal unit-tests
run: |
cabal v2-test Cabal-tests
- name: cabal-install memory-usage-tests
run: |
cd cabal-install
Expand All @@ -127,4 +133,4 @@ jobs:
cabal v2-run cabal-install:unit-tests -- --pattern "! (/FileMonitor/ || /VCS/ || /Get/)"
- name: cabal-tests
# Using only one job, -j1, to fail less.
run: cabal v2-run cabal-tests -- -j1 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.8.4\cabal-install-3.5.0.0\x\cabal\build\cabal\cabal.exe
run: cabal v2-run cabal-testsuite:cabal-tests -- -j1 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.8.4\cabal-install-3.5.0.0\x\cabal\build\cabal\cabal.exe
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ library
, tasty-quickcheck
, transformers

if !impl(ghc >=7.10)
build-depends: void

if !impl(ghc >=7.8)
build-depends: tagged ^>=0.8.5

exposed-modules:
Distribution.Described
Distribution.Utils.CharSet
Expand Down
219 changes: 219 additions & 0 deletions Cabal-tests/Cabal-tests.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
cabal-version: >=1.10
name: Cabal-tests
version: 3
copyright: 2003-2020, Cabal Development Team (see AUTHORS file)
license: BSD3
license-file: LICENSE
author: Cabal Development Team <[email protected]>
maintainer: [email protected]
homepage: http://www.haskell.org/cabal/
bug-reports: https://github.com/haskell/cabal/issues
synopsis: Tests for Cabal library
description: The tests are external for development flows convinience.
category: Distribution
build-type: Simple

source-repository head
type: git
location: https://github.com/haskell/cabal/
subdir: Cabal-tests

-- Small, fast running tests.
test-suite unit-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
other-modules:
Test.Laws
Test.QuickCheck.Utils
UnitTests.Distribution.CabalSpecVersion
UnitTests.Distribution.Compat.CreatePipe
UnitTests.Distribution.Compat.Graph
UnitTests.Distribution.Compat.Time
UnitTests.Distribution.Described
UnitTests.Distribution.PkgconfigVersion
UnitTests.Distribution.Simple.Glob
UnitTests.Distribution.Simple.Program.GHC
UnitTests.Distribution.Simple.Program.Internal
UnitTests.Distribution.Simple.Utils
UnitTests.Distribution.SPDX
UnitTests.Distribution.System
UnitTests.Distribution.Types.GenericPackageDescription
UnitTests.Distribution.Utils.CharSet
UnitTests.Distribution.Utils.Generic
UnitTests.Distribution.Utils.NubList
UnitTests.Distribution.Utils.ShortText
UnitTests.Distribution.Utils.Structured
UnitTests.Distribution.Version
UnitTests.Orphans

main-is: UnitTests.hs
build-depends:
array
, async >=2.2.2 && <2.3
, base >=0 && <5
, binary
, bytestring
, Cabal
, Cabal-described
, Cabal-QuickCheck
, containers
, deepseq
, Diff >=0.4 && <0.5
, directory
, filepath
, integer-logarithms >=1.0.2 && <1.1
, pretty
, QuickCheck >=2.14 && <2.15
, rere >=0.1 && <0.2
, tagged
, tasty >=1.2.3 && <1.4
, tasty-hunit
, tasty-quickcheck
, temporary
, text
, transformers

ghc-options: -Wall
default-language: Haskell2010

if !impl(ghc >=7.10)
build-depends: void

if !impl(ghc >=8.0)
build-depends: semigroups

test-suite parser-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
main-is: ParserTests.hs
build-depends:
base
, base-compat >=0.11.0 && <0.12
, bytestring
, Cabal
, Cabal-tree-diff
, Diff >=0.4 && <0.5
, directory
, filepath
, tasty >=1.2.3 && <1.4
, tasty-golden >=2.3.1.1 && <2.4
, tasty-hunit
, tasty-quickcheck

ghc-options: -Wall
default-language: Haskell2010

if !impl(ghc >=8.0)
build-depends: semigroups

if impl(ghc >=7.8)
build-depends: tree-diff ==0.1.*

test-suite check-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
main-is: CheckTests.hs
build-depends:
base
, bytestring
, Cabal
, Diff >=0.4 && <0.5
, directory
, filepath
, tasty >=1.2.3 && <1.4
, tasty-golden >=2.3.1.1 && <2.4

ghc-options: -Wall
default-language: Haskell2010

if !impl(ghc >=8.0)
build-depends: semigroups

test-suite custom-setup-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests/custom-setup
main-is: CustomSetupTests.hs
other-modules:
CabalDoctestSetup
IdrisSetup

build-depends:
base
, Cabal
, directory
, filepath
, process

default-language: Haskell2010

test-suite hackage-tests
type: exitcode-stdio-1.0
main-is: HackageTests.hs

-- TODO: need to get 01-index.tar on appveyor
if os(windows)
buildable: False

hs-source-dirs: tests
build-depends:
base
, bytestring
, Cabal
, Cabal-tree-diff
, containers
, deepseq
, directory
, filepath

build-depends:
base-compat >=0.11.0 && <0.12
, base-orphans >=0.6 && <0.9
, clock >=0.8 && <0.9
, optparse-applicative >=0.13.2.0 && <0.17
, stm >=2.4.5.0 && <2.6
, tar >=0.5.0.3 && <0.6

if impl(ghc >=7.8)
build-depends: tree-diff ==0.1.*

ghc-options: -Wall -rtsopts -threaded
default-extensions: CPP
default-language: Haskell2010

test-suite rpmvercmp
type: exitcode-stdio-1.0
main-is: RPMVerCmp.hs
hs-source-dirs: tests
build-depends:
base
, bytestring
, Cabal

build-depends:
QuickCheck
, tasty >=1.2.3 && <1.4
, tasty-hunit
, tasty-quickcheck

c-sources: tests/cbits/rpmvercmp.c
cc-options: -Wall
ghc-options: -Wall
default-language: Haskell2010

test-suite no-thunks-test
default-language: Haskell2010
ghc-options: -Wall
type: exitcode-stdio-1.0
main-is: NoThunks.hs
hs-source-dirs: tests
build-depends:
base
, bytestring
, Cabal
, tasty >=1.2.3 && <1.4
, tasty-hunit

-- this is test is buildable on old GHCs
-- but it doesn't do anything.
if impl(ghc >=8.6)
build-depends: nothunks >=0.1.1.0 && <0.2
34 changes: 34 additions & 0 deletions Cabal-tests/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Copyright (c) 2003-2020, Cabal Development Team.
See the AUTHORS file for the full list of copyright holders.

See */LICENSE for the copyright holders of the subcomponents.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File renamed without changes.
File renamed without changes.
11 changes: 10 additions & 1 deletion Cabal/tests/NoThunks.hs → Cabal-tests/tests/NoThunks.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{-# LANGUAGE CPP #-}
#if !(__GLASGOW_HASKELL__ >= 806 && defined(MIN_VERSION_nothunks))
module Main (main) where
main :: IO ()
main = putStrLn "Old GHC, no nothunks"
#else

{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -36,7 +43,7 @@ main = defaultMain $ testGroup "nothunks"

noThunksParse :: IO ()
noThunksParse = do
bs <- BS.readFile "Cabal/Cabal.cabal" <|> BS.readFile "Cabal.cabal"
bs <- BS.readFile "Cabal/Cabal.cabal" <|> BS.readFile "../Cabal/Cabal.cabal"
let res = parseGenericPackageDescription bs
gpd <- either (assertFailure . show) return $ snd $
runParseResult res
Expand Down Expand Up @@ -130,3 +137,5 @@ newtype CheckFoldableNamed f a = CheckFoldableNamed (f a)
instance (NoThunks a, Foldable f, Typeable f) => NoThunks (CheckFoldableNamed f a) where
showTypeOf _ = show (typeRep (Proxy :: Proxy f))
wNoThunks ctxt (CheckFoldableNamed xs) = noThunksInValues ctxt (toList xs)

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import Distribution.Parsec
import Distribution.Pretty
import Distribution.System
import Test.Tasty
import Test.Tasty.QuickCheck
import Test.Tasty.QuickCheck (testProperty)
import Test.QuickCheck (Property, (===))
import Test.QuickCheck.Instances.Cabal ()

textRoundtrip :: (Show a, Eq a, Pretty a, Parsec a) => a -> Property
textRoundtrip x = simpleParsec (prettyShow x) === Just x
Expand All @@ -19,12 +21,3 @@ tests =
, testProperty "Text Arch round trip" (textRoundtrip :: Arch -> Property)
, testProperty "Text Platform round trip" (textRoundtrip :: Platform -> Property)
]

instance Arbitrary OS where
arbitrary = elements knownOSs

instance Arbitrary Arch where
arbitrary = elements knownArches

instance Arbitrary Platform where
arbitrary = liftM2 Platform arbitrary arbitrary
Loading

0 comments on commit 579bff0

Please sign in to comment.