Skip to content

Commit

Permalink
Merge branch '3.12' into mergify/bp/3.12/pr-10266
Browse files Browse the repository at this point in the history
  • Loading branch information
geekosaur authored Sep 13, 2024
2 parents 37ca5ba + 7b77a2d commit 44a88c4
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ jobs:
# support, so the PR *must* have a changelog entry.
ghc: ['9.10.1', '9.8.2', '9.6.4', '9.4.8', '9.2.8', '9.0.2', '8.10.7', '8.8.4', '8.6.5']
exclude:
# Throws fatal "cabal-tests.exe: fd:8: hGetLine: end of file" exception
# even with --io-manager=native
- os: windows-latest
ghc: "9.0.2"
# corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356
- os: windows-latest
ghc: '8.10.7'
Expand Down Expand Up @@ -204,6 +208,7 @@ jobs:
run: sh validate.sh $FLAGS -s cli-tests

- name: Validate cli-suite
if: runner.os != 'Windows'
run: sh validate.sh $FLAGS -s cli-suite

- name: Validate solver-benchmarks-tests
Expand Down
1 change: 1 addition & 0 deletions Cabal-tests/Cabal-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ test-suite hackage-tests
, deepseq
, directory
, filepath
, time

build-depends:
base-compat >=0.11.0 && <0.14
Expand Down
53 changes: 35 additions & 18 deletions Cabal-tests/tests/HackageTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import System.FilePath ((</>))
import Data.Orphans ()

import qualified Codec.Archive.Tar as Tar
import qualified Codec.Archive.Tar.Entry as Tar
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy as BSL
Expand All @@ -56,11 +57,14 @@ import Data.TreeDiff.Instances.Cabal ()
import Data.TreeDiff.Pretty (ansiWlEditExprCompact)
#endif

import Data.Time.Clock.System
import Data.Time.Format

-------------------------------------------------------------------------------
-- parseIndex: Index traversal
-------------------------------------------------------------------------------

parseIndex :: (Monoid a, NFData a) => (FilePath -> Bool)
parseIndex :: (Monoid a, NFData a) => (Tar.EpochTime -> FilePath -> Bool)
-> (FilePath -> B.ByteString -> IO a) -> IO a
parseIndex predicate action = do
configPath <- getCabalConfigPath
Expand Down Expand Up @@ -99,7 +103,7 @@ parseIndex predicate action = do

parseIndex'
:: (Monoid a, NFData a)
=> (FilePath -> Bool)
=> (Tar.EpochTime -> FilePath -> Bool)
-> (FilePath -> B.ByteString -> IO a) -> FilePath -> IO a
parseIndex' predicate action path = do
putStrLn $ "Reading index from: " ++ path
Expand All @@ -110,7 +114,7 @@ parseIndex' predicate action path = do

where
cons entry entries
| predicate (Tar.entryPath entry) = entry : entries
| predicate (Tar.entryTime entry) (Tar.entryPath entry) = entry : entries
| otherwise = entries

f entry = case Tar.entryContent entry of
Expand Down Expand Up @@ -320,6 +324,13 @@ main = join (O.execParser opts)
, O.progDesc "tests using Hackage's index"
]

indexP =
fmap cvt <$> O.optional (O.strOption (O.long "index-state" <> O.metavar "YYYY-MM-DD"))
where
cvt =
systemSeconds . utcToSystemTime .
parseTimeOrError False defaultTimeLocale "%Y-%m-%d"

optsP = subparser
[ command "read-fields" readFieldsP
"Parse outer format (to '[Field]', TODO: apply Quirks)"
Expand All @@ -330,20 +341,20 @@ main = join (O.execParser opts)

defaultA = do
putStrLn "Default action: parsec k"
parsecA (mkPredicate ["k"]) False
parsecA ["k"] False Nothing

readFieldsP = readFieldsA <$> prefixP
readFieldsA pfx = parseIndex pfx readFieldTest
readFieldsP = readFieldsA <$> prefixP <*> indexP
readFieldsA pfx idx = parseIndex (mkPredicate pfx idx) readFieldTest

parsecP = parsecA <$> prefixP <*> keepGoingP
parsecP = parsecA <$> prefixP <*> keepGoingP <*> indexP
keepGoingP =
O.flag' True (O.long "keep-going") <|>
O.flag' False (O.long "no-keep-going") <|>
pure False

parsecA pfx keepGoing = do
parsecA pfx keepGoing idx = do
begin <- Clock.getTime Clock.Monotonic
ParsecResult n w f <- parseIndex pfx (parseParsecTest keepGoing)
ParsecResult n w f <- parseIndex (mkPredicate pfx idx) (parseParsecTest keepGoing)
end <- Clock.getTime Clock.Monotonic
let diff = Clock.toNanoSecs $ Clock.diffTimeSpec end begin

Expand All @@ -353,14 +364,14 @@ main = join (O.execParser opts)
putStrLn $ showFFloat (Just 6) (fromInteger diff / 1e9 :: Double) " seconds elapsed"
putStrLn $ showFFloat (Just 6) (fromInteger diff / 1e6 / fromIntegral n :: Double) " milliseconds per file"

roundtripP = roundtripA <$> prefixP <*> testFieldsP
roundtripA pfx testFieldsTransform = do
Sum n <- parseIndex pfx (roundtripTest testFieldsTransform)
roundtripP = roundtripA <$> prefixP <*> testFieldsP <*> indexP
roundtripA pfx testFieldsTransform idx = do
Sum n <- parseIndex (mkPredicate pfx idx) (roundtripTest testFieldsTransform)
putStrLn $ show n ++ " files processed"

checkP = checkA <$> prefixP
checkA pfx = do
CheckResult n w x a b c d e <- parseIndex pfx parseCheckTest
checkP = checkA <$> prefixP <*> indexP
checkA pfx idx = do
CheckResult n w x a b c d e <- parseIndex (mkPredicate pfx idx) parseCheckTest
putStrLn $ show n ++ " files processed"
putStrLn $ show w ++ " files have lexer/parser warnings"
putStrLn $ show x ++ " files have check warnings"
Expand All @@ -370,7 +381,7 @@ main = join (O.execParser opts)
putStrLn $ show d ++ " build dist suspicious warning"
putStrLn $ show e ++ " build dist inexcusable"

prefixP = fmap mkPredicate $ many $ O.strArgument $ mconcat
prefixP = many $ O.strArgument $ mconcat
[ O.metavar "PREFIX"
, O.help "Check only files starting with a prefix"
]
Expand All @@ -380,8 +391,14 @@ main = join (O.execParser opts)
, O.help "Test also 'showFields . fromParsecFields . readFields' transform"
]

mkPredicate [] = const True
mkPredicate pfxs = \n -> any (`isPrefixOf` n) pfxs
indexPredicate :: Maybe Tar.EpochTime -> (k -> Bool) -> (Tar.EpochTime -> k -> Bool)
indexPredicate Nothing k = const k
indexPredicate (Just indexDate) k =
\e -> if (e <= indexDate) then k else const False

mkPredicate :: [String] -> Maybe Tar.EpochTime -> (Tar.EpochTime -> FilePath -> Bool)
mkPredicate [] idx = indexPredicate idx (const True)
mkPredicate pfxs idx = indexPredicate idx (\n -> any (`isPrefixOf` n) pfxs)

command name p desc = O.command name
(O.info (p <**> O.helper) (O.progDesc desc))
Expand Down
2 changes: 2 additions & 0 deletions Cabal/src/Distribution/Simple/Program/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ normaliseGhcArgs (Just ghcVersion) PackageDescription{..} ghcArgs
, "-ddpr-cols"
, "-dtrace-level"
, "-fghci-hist-size"
, "-dinitial-unique"
, "-dunique-increment"
]
, from [8, 2] ["-fmax-uncovered-patterns", "-fmax-errors"]
, from [8, 4] $ to [8, 6] ["-fmax-valid-substitutions"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,20 @@ import UnitTests.Distribution.Solver.Modular.QuickCheck.Utils

tests :: [TestTree]
tests =
[ -- This test checks that certain solver parameters do not affect the
[ testPropertyWithSeed "solver does not throw exceptions" $
\test goalOrder reorderGoals indepGoals prefOldest ->
let r =
solve
(EnableBackjumping True)
(FineGrainedConflicts True)
reorderGoals
(CountConflicts True)
indepGoals
prefOldest
(getBlind <$> goalOrder)
test
in resultPlan r `seq` ()
, -- This test checks that certain solver parameters do not affect the
-- existence of a solution. It runs the solver twice, and only sets those
-- parameters on the second run. The test also applies parameters that
-- can affect the existence of a solution to both runs.
Expand Down Expand Up @@ -516,6 +529,11 @@ instance Arbitrary IndependentGoals where

shrink (IndependentGoals indep) = [IndependentGoals False | indep]

instance Arbitrary PreferOldest where
arbitrary = PreferOldest <$> arbitrary

shrink (PreferOldest prefOldest) = [PreferOldest False | prefOldest]

instance Arbitrary Component where
arbitrary =
oneof
Expand Down
13 changes: 13 additions & 0 deletions changelog.d/pr-10240
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
synopsis: Filter out dinitial-unique and dunique-increment from package hash
packages: cabal-install
prs: #10122

description: {

`-dinitial-unique` and `-dunique-increment` are now filtered out when computing the
store hash of a package.

These options shouldn't affect the output of the package and hence
shouldn't affect the store hash of a package.

}
6 changes: 6 additions & 0 deletions doc/cabal-package-description-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2965,6 +2965,9 @@ Right now :pkg-field:`executable:main-is` modules are not supported on
Accessing data files from package code
--------------------------------------

.. index:: Paths
.. index:: Paths_

The placement on the target system of files listed in
the :pkg-field:`data-files` field varies between systems, and in some cases
one can even move packages around after installation
Expand Down Expand Up @@ -3020,6 +3023,9 @@ the configured data directory for ``pretty-show`` is controlled with the
Accessing the package version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. index:: PackageInfo
.. index:: PackageInfo_

The auto generated :file:`PackageInfo_{pkgname}` module exports the constant
``version ::`` `Version <http://hackage.haskell.org/package/base/docs/Data-Version.html>`__
which is defined as the version of your package as specified in the
Expand Down
17 changes: 12 additions & 5 deletions validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ CABAL_TESTSUITE_BDIR="$(pwd)/$BUILDDIR/build/$ARCH/$BASEHC/cabal-testsuite-3"
CABALNEWBUILD="${CABAL} build $JOBS -w $HC --builddir=$BUILDDIR --project-file=$PROJECTFILE"
CABALLISTBIN="${CABAL} list-bin --builddir=$BUILDDIR --project-file=$PROJECTFILE"

# See https://github.com/haskell/cabal/issues/9571 for why we set this for Windows
RTSOPTS="$([ $ARCH = "x86_64-windows" ] && [ "$($HC --numeric-version)" != "9.0.2" ] && [ "$(echo -e "$(ghc --numeric-version)\n9.0.2" | sort -V | head -n1)" = "9.0.2" ] && echo "+RTS --io-manager=native" || echo "")"

# header
#######################################################################

Expand Down Expand Up @@ -409,14 +412,18 @@ CMD="$($CABALLISTBIN Cabal-tests:test:rpmvercmp) $TESTSUITEJOBS --hide-successes
CMD="$($CABALLISTBIN Cabal-tests:test:no-thunks-test) $TESTSUITEJOBS --hide-successes"
(cd Cabal-tests && timed $CMD) || exit 1


# See #10284 for why this value is pinned.
HACKAGE_TESTS_INDEX_STATE="--index-state=2024-08-25"

CMD=$($CABALLISTBIN Cabal-tests:test:hackage-tests)
(cd Cabal-tests && timed $CMD read-fields) || exit 1
(cd Cabal-tests && timed $CMD read-fields $HACKAGE_TESTS_INDEX_STATE) || exit 1
if $HACKAGETESTSALL; then
(cd Cabal-tests && timed $CMD parsec) || exit 1
(cd Cabal-tests && timed $CMD roundtrip) || exit 1
(cd Cabal-tests && timed $CMD parsec $HACKAGE_TESTS_INDEX_STATE) || exit 1
(cd Cabal-tests && timed $CMD roundtrip $HACKAGE_TESTS_INDEX_STATE) || exit 1
else
(cd Cabal-tests && timed $CMD parsec d) || exit 1
(cd Cabal-tests && timed $CMD roundtrip k) || exit 1
(cd Cabal-tests && timed $CMD parsec d $HACKAGE_TESTS_INDEX_STATE) || exit 1
(cd Cabal-tests && timed $CMD roundtrip k $HACKAGE_TESTS_INDEX_STATE) || exit 1
fi
}

Expand Down

0 comments on commit 44a88c4

Please sign in to comment.