Skip to content

Commit

Permalink
Merge pull request #9565 from cabalism/import/pkg-groups
Browse files Browse the repository at this point in the history
Use package groups
  • Loading branch information
philderbeast committed Mar 26, 2024
2 parents 1c1230c + 72be26b commit 7e085fa
Show file tree
Hide file tree
Showing 29 changed files with 185 additions and 207 deletions.
2 changes: 2 additions & 0 deletions Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.QuickCheck.Instances.Cabal () where

#if !MIN_VERSION_base(4,18,0)
import Control.Applicative (liftA2)
#endif
import Data.Bits (shiftR)
import Data.Char (isAlphaNum, isDigit, toLower)
import Data.List (intercalate, (\\))
Expand Down
1 change: 0 additions & 1 deletion Cabal-tests/tests/CheckTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Main
) where

import Test.Tasty
import Test.Tasty.ExpectedFailure
import Test.Tasty.Golden.Advanced (goldenTest)

import Data.Algorithm.Diff (PolyDiff (..), getGroupedDiff)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- For the deprecated import of Distribution.Compat.Prelude.Internal
{-# OPTIONS_GHC -Wwarn=deprecations #-}

module UnitTests.Distribution.PackageDescription.Check (tests) where

import Distribution.Compat.Prelude.Internal
Expand Down
26 changes: 9 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

CABALBUILD := cabal build
CABALRUN := cabal run
DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --project-file=cabal.project.doctest

# The newer and prefered way to call the doctest tool is:
# $ cabal repl --with-ghc=doctest
# SEE: https://github.com/haskell/cabal/issues/8504
# There is but one caveat, we have to avoid allow-newer.
# SEE: https://github.com/haskell/cabal/issues/6859
DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --ghc-options="-Wwarn" --allow-newer=False

# default rules

Expand Down Expand Up @@ -65,8 +71,8 @@ doc/buildinfo-fields-reference.rst : \
$(wildcard Cabal-described/src/Distribution/Described.hs Cabal-described/src/Distribution/Utils/*.hs) \
buildinfo-reference-generator/src/Main.hs \
buildinfo-reference-generator/template.zinza
cabal build --project-file=cabal.project.buildinfo buildinfo-reference-generator
cabal run --project-file=cabal.project.buildinfo buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
cabal build buildinfo-reference-generator
cabal run buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
git diff --exit-code $@

# analyse-imports
Expand All @@ -81,15 +87,6 @@ ghcid-lib :
ghcid-cli :
ghcid -c 'cabal repl cabal-install'

# Artem, 2023-02-03, https://github.com/haskell/cabal/issues/8504
# The new and prefered way to call the doctest tool (as of now) is based on cabal repl --with-ghc=doctest.
# The call below reflects the current documentation of the doctest tool except one caveat,
# which is https://github.com/haskell/cabal/issues/6859, i.e. we have to hide allow-newer in our project
# file from cabal/doctest. This is easy: we just select a project file with no allow-newer (e.g. cabal.project.libonly).
#
# TODO: Cabal-described should be added here but its doctests currently broken, see:
# https://github.com/haskell/cabal/issues/8734
# Just as well, cabal-install(-solver) doctests (the target below) bitrotted and need some care.
doctest :
$(DOCTEST) Cabal-syntax
$(DOCTEST) Cabal-described
Expand Down Expand Up @@ -185,11 +182,6 @@ validate-via-docker-8.10.4:
validate-via-docker-old:
docker build $(DOCKERARGS) -t cabal-validate:older -f .docker/validate-old.dockerfile .

# Weeder
weeder :
cabal build all --project-file=cabal.project.weeder
weeder | less

# tags
.PHONY : tags
tags :
Expand Down
41 changes: 15 additions & 26 deletions cabal-install/tests/UnitTests/Distribution/Client/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ tests =
[ configureTests
]

defaultTestFlags :: NixStyleFlags ()
defaultTestFlags =
(defaultNixStyleFlags ())
{ projectFlags =
mempty
{ flagProjectDir = Flag projectDir
}
}

configureTests :: TestTree
configureTests =
testGroup
"Configure tests"
[ testCase "New config" $ do
let flags =
(defaultNixStyleFlags ())
defaultTestFlags
{ configFlags =
mempty
{ configOptimization = Flag MaximumOptimisation
Expand All @@ -42,7 +51,7 @@ configureTests =
@=? (packageConfigOptimization . projectConfigLocalPackages $ snd projConfig)
, testCase "Replacement + new config" $ do
let flags =
(defaultNixStyleFlags ())
defaultTestFlags
{ configExFlags =
mempty
{ configAppend = Flag True
Expand All @@ -52,18 +61,14 @@ configureTests =
{ configOptimization = Flag NoOptimisation
, configVerbosity = Flag silent
}
, projectFlags =
mempty
{ flagProjectDir = Flag projectDir
}
}
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags

Flag NoOptimisation @=? packageConfigOptimization projectConfigLocalPackages
Flag silent @=? projectConfigVerbosity projectConfigBuildOnly
, testCase "Old + new config" $ do
let flags =
(defaultNixStyleFlags ())
defaultTestFlags
{ configExFlags =
mempty
{ configAppend = Flag True
Expand All @@ -72,42 +77,30 @@ configureTests =
mempty
{ configVerbosity = Flag silent
}
, projectFlags =
mempty
{ flagProjectDir = Flag projectDir
}
}
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags

Flag MaximumOptimisation @=? packageConfigOptimization projectConfigLocalPackages
Flag silent @=? projectConfigVerbosity projectConfigBuildOnly
, testCase "Old + new config, no appending" $ do
let flags =
(defaultNixStyleFlags ())
defaultTestFlags
{ configFlags =
mempty
{ configVerbosity = Flag silent
}
, projectFlags =
mempty
{ flagProjectDir = Flag projectDir
}
}
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags

NoFlag @=? packageConfigOptimization projectConfigLocalPackages
Flag silent @=? projectConfigVerbosity projectConfigBuildOnly
, testCase "Old + new config, backup check" $ do
let flags =
(defaultNixStyleFlags ())
defaultTestFlags
{ configFlags =
mempty
{ configVerbosity = Flag silent
}
, projectFlags =
mempty
{ flagProjectDir = Flag projectDir
}
}
backup = projectDir </> "cabal.project.local~"

Expand All @@ -122,16 +115,12 @@ configureTests =
, testCase "Local program options" $ do
let ghcFlags = ["-fno-full-laziness"]
flags =
(defaultNixStyleFlags ())
defaultTestFlags
{ configFlags =
mempty
{ configVerbosity = Flag silent
, configProgramArgs = [("ghc", ghcFlags)]
}
, projectFlags =
mempty
{ flagProjectDir = Flag projectDir
}
}
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags

Expand Down
6 changes: 6 additions & 0 deletions cabal-testsuite/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- This intercepting project is here to avoid tests picking up a cabal.project
-- from a parent directory, such as the one in the root of the `haskell/cabal`
-- project itself. Having `optional-packages: .` avoids the folowing warning
-- being added to the `.out` file:
-- Warning: There are no packages or optional-packages in the project
optional-packages: .
1 change: 1 addition & 0 deletions cabal-testsuite/static/Main.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module Main where

main :: IO ()
main = return ()
27 changes: 4 additions & 23 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
import: cabal.project.latest-ghc

packages: Cabal/
packages: cabal-testsuite/
packages: Cabal-syntax/
packages: cabal-install/
packages: cabal-install-solver/
packages: solver-benchmarks/
import: project-cabal/ghc-options.config
import: project-cabal/ghc-latest.config
import: project-cabal/pkgs.config
import: project-cabal/constraints.config

tests: True

packages: Cabal-QuickCheck/
packages: Cabal-tree-diff/
packages: Cabal-described
packages: Cabal-tests/
packages: cabal-benchmarks/

optional-packages: ./vendored/*/*.cabal

-- avoiding extra dependencies
constraints: rere -rere-cfg
constraints: these -assoc

program-options
ghc-options: -fno-ignore-asserts
10 changes: 0 additions & 10 deletions cabal.project.buildinfo

This file was deleted.

24 changes: 0 additions & 24 deletions cabal.project.doctest

This file was deleted.

14 changes: 0 additions & 14 deletions cabal.project.libonly

This file was deleted.

1 change: 0 additions & 1 deletion cabal.project.meta
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
packages: cabal-dev-scripts
optional-packages:
11 changes: 4 additions & 7 deletions cabal.project.release
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
packages: Cabal-syntax/
packages: Cabal/
packages: cabal-install-solver/
packages: cabal-install/
tests: False
benchmarks: False
optimization: True
import: project-cabal/pkgs/cabal.config
import: project-cabal/pkgs/install.config
import: project-cabal/pkgs/tests.config

index-state: hackage.haskell.org 2024-02-13T10:16:13Z
35 changes: 4 additions & 31 deletions cabal.project.validate
Original file line number Diff line number Diff line change
@@ -1,34 +1,7 @@
import: cabal.project.latest-ghc

packages: Cabal-syntax/
packages: Cabal/
packages: cabal-testsuite/
packages: cabal-install/
packages: solver-benchmarks/

packages: cabal-install-solver/
packages: Cabal-QuickCheck/
packages: Cabal-tree-diff
packages: Cabal-described
packages: Cabal-tests
packages: cabal-benchmarks
import: project-cabal/ghc-options.config
import: project-cabal/ghc-latest.config
import: project-cabal/pkgs.config
import: project-cabal/constraints.config

tests: True

-- avoiding extra dependencies
constraints: rere -rere-cfg
constraints: these -assoc

write-ghc-environment-files: never

program-options
ghc-options: -fno-ignore-asserts

package Cabal-syntax
ghc-options: -Werror
package Cabal
ghc-options: -Werror
package cabal-testsuite
ghc-options: -Werror
package cabal-install
ghc-options: -Werror
30 changes: 5 additions & 25 deletions cabal.project.validate.libonly
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
packages: Cabal-syntax/
packages: Cabal/
packages: cabal-testsuite/
packages: Cabal-QuickCheck/
packages: Cabal-tree-diff
packages: Cabal-described
packages: Cabal-tests
import: project-cabal/ghc-options.config
import: project-cabal/pkgs/cabal.config
import: project-cabal/pkgs/tests.config
import: project-cabal/pkgs/integration-tests.config
import: project-cabal/constraints.config

tests: True

write-ghc-environment-files: never

-- avoiding extra dependencies
constraints: rere -rere-cfg
constraints: these -assoc

program-options
ghc-options: -fno-ignore-asserts

package Cabal-syntax
ghc-options: -Werror
package Cabal
ghc-options: -Werror
package cabal-testsuite
ghc-options: -Werror

-- https://github.com/haskell-hvr/cryptohash-sha256/issues/12
allow-newer: cryptohash-sha256:base
15 changes: 0 additions & 15 deletions cabal.project.weeder

This file was deleted.

0 comments on commit 7e085fa

Please sign in to comment.