From c359eca39b1243fc9f04c180465037f72a2f93ac Mon Sep 17 00:00:00 2001 From: brandon s allbery kf8nh Date: Tue, 20 Aug 2024 19:06:35 -0400 Subject: [PATCH 1/4] index Paths and Paths_ (resp. for PackageInfo) These can currently be found by searching the documentation for `Paths_pkgname` and `PackageInfo_pkgname`, but you pretty much need to know that to begin with to find them. Add Sphinx index entries to make them more discoverable. (cherry picked from commit d51c55494779a8c91b706a762b17c4a1b121b470) --- doc/cabal-package-description-file.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/cabal-package-description-file.rst b/doc/cabal-package-description-file.rst index c1566fe4e25..60902c36e21 100644 --- a/doc/cabal-package-description-file.rst +++ b/doc/cabal-package-description-file.rst @@ -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 @@ -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 `__ which is defined as the version of your package as specified in the From 3b1328899f8ea963f0fc7c1f638dbde82cf0c381 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 05:45:52 +0000 Subject: [PATCH 2/4] ci: Fix --index-state for hackage roundtrip tests (backport #10285) (#10305) * hackage-tests: Add --index-state argument to fix the cabal files We need to fix the index-state we test against so a new bad cabal file doesn't take down the CI for everyone. Towards #10284 (cherry picked from commit 8e4d16780ede40c73f1e9cc5777e30a4f8a8d34f) * ci: Fix --index-state for hackage roundtrip tests As a principle, tests which are required for CI to pass should be reproducible and not depending on external resources changes or being modified. The hackage tests currently violate this by depending on the latest index state from hackage. This is problematic because until the test is fixed all merges into master are blocked. Even though the patches in question have nothing to do with the test. It would be more suitable for a nightly job to run on the latest index and for normal CI to run with a fixed index which is updated periodically in a controlled manner. Fixes #10284 (cherry picked from commit 31507b1f7bbb142881ad1cd254f3827bd6f7ef07) * Re-enable Windows CI (cherry picked from commit 4aade2d8a17704cfcb2fa6cf9fb59478c17a0653) * CI: skip cli-suite on Windows due to #9571 (#10257) (cherry picked from commit 30d2a380cd67e8d3cab48169f0da62596ceccf36) --------- Co-authored-by: Matthew Pickering Co-authored-by: Javier Sagredo Co-authored-by: Artem Pelenitsyn --- .github/workflows/validate.yml | 5 +++ Cabal-tests/Cabal-tests.cabal | 1 + Cabal-tests/tests/HackageTests.hs | 53 ++++++++++++++++++++----------- validate.sh | 17 +++++++--- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index dd3f350db3a..b78e51a624c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -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' @@ -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 diff --git a/Cabal-tests/Cabal-tests.cabal b/Cabal-tests/Cabal-tests.cabal index 30cea4dc2b3..00f1f26258e 100644 --- a/Cabal-tests/Cabal-tests.cabal +++ b/Cabal-tests/Cabal-tests.cabal @@ -161,6 +161,7 @@ test-suite hackage-tests , deepseq , directory , filepath + , time build-depends: base-compat >=0.11.0 && <0.14 diff --git a/Cabal-tests/tests/HackageTests.hs b/Cabal-tests/tests/HackageTests.hs index 9bff0ce05cc..e400e73629d 100644 --- a/Cabal-tests/tests/HackageTests.hs +++ b/Cabal-tests/tests/HackageTests.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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)" @@ -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 @@ -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" @@ -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" ] @@ -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)) diff --git a/validate.sh b/validate.sh index e6cd603db41..c7c86f07633 100755 --- a/validate.sh +++ b/validate.sh @@ -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 ####################################################################### @@ -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 } From 15199f03654d97e5fcaae66583dbe0766842b681 Mon Sep 17 00:00:00 2001 From: Kristen Kozak Date: Mon, 29 Jul 2024 22:51:45 -0700 Subject: [PATCH 3/4] Add simple QuickCheck test for solver exceptions The solver QuickCheck tests can already detect exceptions, but this test is simpler and easier to debug. (cherry picked from commit 3347001cc460256cb4ece0cf9613a0616412248f) --- .../Distribution/Solver/Modular/QuickCheck.hs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/QuickCheck.hs b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/QuickCheck.hs index 114db775f21..2a15ec8b46c 100644 --- a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/QuickCheck.hs +++ b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/QuickCheck.hs @@ -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. @@ -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 From 226b0401c7930e00c446a932e682e81c627c2d46 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Fri, 2 Aug 2024 11:47:01 +0100 Subject: [PATCH 4/4] Filter out -dinitial-unique and -dunique-increment from hash flags These options shouldn't affect the output of the package and hence shouldn't affect the store hash of a package. (cherry picked from commit 4ce7bc4f9719e22e8b6dd90890a3cfcddbb862b9) --- Cabal/src/Distribution/Simple/Program/GHC.hs | 2 ++ changelog.d/pr-10240 | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 changelog.d/pr-10240 diff --git a/Cabal/src/Distribution/Simple/Program/GHC.hs b/Cabal/src/Distribution/Simple/Program/GHC.hs index 71a32c4f50c..8bd18d31298 100644 --- a/Cabal/src/Distribution/Simple/Program/GHC.hs +++ b/Cabal/src/Distribution/Simple/Program/GHC.hs @@ -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"] diff --git a/changelog.d/pr-10240 b/changelog.d/pr-10240 new file mode 100644 index 00000000000..9bd05100ab7 --- /dev/null +++ b/changelog.d/pr-10240 @@ -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. + +}