Skip to content

Commit 7e085fa

Browse files
authored
Merge pull request #9565 from cabalism/import/pkg-groups
Use package groups
2 parents 1c1230c + 72be26b commit 7e085fa

29 files changed

+185
-207
lines changed

Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
{-# OPTIONS_GHC -fno-warn-orphans #-}
44
module Test.QuickCheck.Instances.Cabal () where
55

6+
#if !MIN_VERSION_base(4,18,0)
67
import Control.Applicative (liftA2)
8+
#endif
79
import Data.Bits (shiftR)
810
import Data.Char (isAlphaNum, isDigit, toLower)
911
import Data.List (intercalate, (\\))

Cabal-tests/tests/CheckTests.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Main
33
) where
44

55
import Test.Tasty
6-
import Test.Tasty.ExpectedFailure
76
import Test.Tasty.Golden.Advanced (goldenTest)
87

98
import Data.Algorithm.Diff (PolyDiff (..), getGroupedDiff)

Cabal-tests/tests/UnitTests/Distribution/PackageDescription/Check.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- For the deprecated import of Distribution.Compat.Prelude.Internal
2+
{-# OPTIONS_GHC -Wwarn=deprecations #-}
3+
14
module UnitTests.Distribution.PackageDescription.Check (tests) where
25

36
import Distribution.Compat.Prelude.Internal

Makefile

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33

44
CABALBUILD := cabal build
55
CABALRUN := cabal run
6-
DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --project-file=cabal.project.doctest
6+
7+
# The newer and prefered way to call the doctest tool is:
8+
# $ cabal repl --with-ghc=doctest
9+
# SEE: https://github.com/haskell/cabal/issues/8504
10+
# There is but one caveat, we have to avoid allow-newer.
11+
# SEE: https://github.com/haskell/cabal/issues/6859
12+
DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --ghc-options="-Wwarn" --allow-newer=False
713

814
# default rules
915

@@ -65,8 +71,8 @@ doc/buildinfo-fields-reference.rst : \
6571
$(wildcard Cabal-described/src/Distribution/Described.hs Cabal-described/src/Distribution/Utils/*.hs) \
6672
buildinfo-reference-generator/src/Main.hs \
6773
buildinfo-reference-generator/template.zinza
68-
cabal build --project-file=cabal.project.buildinfo buildinfo-reference-generator
69-
cabal run --project-file=cabal.project.buildinfo buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
74+
cabal build buildinfo-reference-generator
75+
cabal run buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
7076
git diff --exit-code $@
7177

7278
# analyse-imports
@@ -81,15 +87,6 @@ ghcid-lib :
8187
ghcid-cli :
8288
ghcid -c 'cabal repl cabal-install'
8389

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

188-
# Weeder
189-
weeder :
190-
cabal build all --project-file=cabal.project.weeder
191-
weeder | less
192-
193185
# tags
194186
.PHONY : tags
195187
tags :

cabal-install/tests/UnitTests/Distribution/Client/Configure.hs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ tests =
2323
[ configureTests
2424
]
2525

26+
defaultTestFlags :: NixStyleFlags ()
27+
defaultTestFlags =
28+
(defaultNixStyleFlags ())
29+
{ projectFlags =
30+
mempty
31+
{ flagProjectDir = Flag projectDir
32+
}
33+
}
34+
2635
configureTests :: TestTree
2736
configureTests =
2837
testGroup
2938
"Configure tests"
3039
[ testCase "New config" $ do
3140
let flags =
32-
(defaultNixStyleFlags ())
41+
defaultTestFlags
3342
{ configFlags =
3443
mempty
3544
{ configOptimization = Flag MaximumOptimisation
@@ -42,7 +51,7 @@ configureTests =
4251
@=? (packageConfigOptimization . projectConfigLocalPackages $ snd projConfig)
4352
, testCase "Replacement + new config" $ do
4453
let flags =
45-
(defaultNixStyleFlags ())
54+
defaultTestFlags
4655
{ configExFlags =
4756
mempty
4857
{ configAppend = Flag True
@@ -52,18 +61,14 @@ configureTests =
5261
{ configOptimization = Flag NoOptimisation
5362
, configVerbosity = Flag silent
5463
}
55-
, projectFlags =
56-
mempty
57-
{ flagProjectDir = Flag projectDir
58-
}
5964
}
6065
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags
6166

6267
Flag NoOptimisation @=? packageConfigOptimization projectConfigLocalPackages
6368
Flag silent @=? projectConfigVerbosity projectConfigBuildOnly
6469
, testCase "Old + new config" $ do
6570
let flags =
66-
(defaultNixStyleFlags ())
71+
defaultTestFlags
6772
{ configExFlags =
6873
mempty
6974
{ configAppend = Flag True
@@ -72,42 +77,30 @@ configureTests =
7277
mempty
7378
{ configVerbosity = Flag silent
7479
}
75-
, projectFlags =
76-
mempty
77-
{ flagProjectDir = Flag projectDir
78-
}
7980
}
8081
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags
8182

8283
Flag MaximumOptimisation @=? packageConfigOptimization projectConfigLocalPackages
8384
Flag silent @=? projectConfigVerbosity projectConfigBuildOnly
8485
, testCase "Old + new config, no appending" $ do
8586
let flags =
86-
(defaultNixStyleFlags ())
87+
defaultTestFlags
8788
{ configFlags =
8889
mempty
8990
{ configVerbosity = Flag silent
9091
}
91-
, projectFlags =
92-
mempty
93-
{ flagProjectDir = Flag projectDir
94-
}
9592
}
9693
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags
9794

9895
NoFlag @=? packageConfigOptimization projectConfigLocalPackages
9996
Flag silent @=? projectConfigVerbosity projectConfigBuildOnly
10097
, testCase "Old + new config, backup check" $ do
10198
let flags =
102-
(defaultNixStyleFlags ())
99+
defaultTestFlags
103100
{ configFlags =
104101
mempty
105102
{ configVerbosity = Flag silent
106103
}
107-
, projectFlags =
108-
mempty
109-
{ flagProjectDir = Flag projectDir
110-
}
111104
}
112105
backup = projectDir </> "cabal.project.local~"
113106

@@ -122,16 +115,12 @@ configureTests =
122115
, testCase "Local program options" $ do
123116
let ghcFlags = ["-fno-full-laziness"]
124117
flags =
125-
(defaultNixStyleFlags ())
118+
defaultTestFlags
126119
{ configFlags =
127120
mempty
128121
{ configVerbosity = Flag silent
129122
, configProgramArgs = [("ghc", ghcFlags)]
130123
}
131-
, projectFlags =
132-
mempty
133-
{ flagProjectDir = Flag projectDir
134-
}
135124
}
136125
(_, ProjectConfig{..}) <- configureAction' flags [] defaultGlobalFlags
137126

cabal-testsuite/cabal.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- This intercepting project is here to avoid tests picking up a cabal.project
2+
-- from a parent directory, such as the one in the root of the `haskell/cabal`
3+
-- project itself. Having `optional-packages: .` avoids the folowing warning
4+
-- being added to the `.out` file:
5+
-- Warning: There are no packages or optional-packages in the project
6+
optional-packages: .

cabal-testsuite/static/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module Main where
22

3+
main :: IO ()
34
main = return ()

cabal.project

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
1-
import: cabal.project.latest-ghc
2-
3-
packages: Cabal/
4-
packages: cabal-testsuite/
5-
packages: Cabal-syntax/
6-
packages: cabal-install/
7-
packages: cabal-install-solver/
8-
packages: solver-benchmarks/
1+
import: project-cabal/ghc-options.config
2+
import: project-cabal/ghc-latest.config
3+
import: project-cabal/pkgs.config
4+
import: project-cabal/constraints.config
95

106
tests: True
11-
12-
packages: Cabal-QuickCheck/
13-
packages: Cabal-tree-diff/
14-
packages: Cabal-described
15-
packages: Cabal-tests/
16-
packages: cabal-benchmarks/
17-
18-
optional-packages: ./vendored/*/*.cabal
19-
20-
-- avoiding extra dependencies
21-
constraints: rere -rere-cfg
22-
constraints: these -assoc
23-
24-
program-options
25-
ghc-options: -fno-ignore-asserts

cabal.project.buildinfo

Lines changed: 0 additions & 10 deletions
This file was deleted.

cabal.project.doctest

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)