diff --git a/cabal-install/src/Distribution/Client/ProjectConfig.hs b/cabal-install/src/Distribution/Client/ProjectConfig.hs index 504d48b6e6e..1dfa1cbaac1 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig.hs @@ -858,7 +858,7 @@ readProjectFileSkeletonGen monitorFiles [monitorFileHashed extensionFile] pcs <- liftIO $ parseConfig extensionFile let paths = - [ projectConfigPathRoot path + [ currentProjectConfigPath path | (Nothing, path) <- projectSkeletonImports pcs ] for_ paths $ \p -> do diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index d87a79c34eb..0bc07c791a0 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -251,11 +251,6 @@ sanityCheckElaboratedConfiguredPackage ElabPackage pkg -> sanityCheckElaboratedPackage elab pkg ElabComponent comp -> sanityCheckElaboratedComponent elab comp ) - -- The assertion below fails occasionally for unknown reason - -- so it was muted until we figure it out, otherwise it severely - -- hinders our ability to share and test development builds of cabal-install. - -- Tracking issue: https://github.com/haskell/cabal/issues/6006 - -- -- either a package is being built inplace, or the -- 'installedPackageId' we assigned is consistent with -- the 'hashedInstalledPackageId' we would compute from diff --git a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.freeze-only.actual.txt b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.freeze-only.actual.txt deleted file mode 100644 index 7f95bff0e32..00000000000 --- a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.freeze-only.actual.txt +++ /dev/null @@ -1,5 +0,0 @@ -Monitor existing: /cabal.freeze-only.project -Monitor existing: /cabal.freeze-only.project.freeze -Monitor imported: cabal.freeze-only.project.freeze (/cabal.freeze-only.project.freeze) -Monitor imported: cabal.freeze-only.project.freeze (/cabal.freeze-only.project.freeze) -Monitor imported: cabal.freeze-only.project.freeze (/cabal.freeze-only.project.freeze) diff --git a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.local-only.actual.txt b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.local-only.actual.txt deleted file mode 100644 index 129fe366e5c..00000000000 --- a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.local-only.actual.txt +++ /dev/null @@ -1,6 +0,0 @@ -Monitor existing: /cabal.local-only.project -Monitor nonexistent: /cabal.local-only.project.freeze -Monitor existing: /cabal.local-only.project.local -Monitor imported: cabal.local-only.project.local (/cabal.local-only.project.local) -Monitor imported: cabal.local-only.project.local (/cabal.local-only.project.local) -Monitor imported: cabal.local-only.project.local (/cabal.local-only.project.local) diff --git a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.actual.txt b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.actual.txt deleted file mode 100644 index e9c9ab04020..00000000000 --- a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.actual.txt +++ /dev/null @@ -1,6 +0,0 @@ -Monitor existing: /cabal.project -Monitor imported: cabal.project (/cabal.project) -Monitor imported: cabal.project (/cabal.project) -Monitor imported: cabal.project (/cabal.project) -Monitor nonexistent: /cabal.project.freeze -Monitor nonexistent: /cabal.project.local diff --git a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.expect.txt b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.expect.txt index a1fdfd02b5f..0dbf31c7413 100644 --- a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.expect.txt +++ b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.main-project.expect.txt @@ -1,3 +1,6 @@ Monitor existing: /cabal.project +Monitor imported: nested/hop.config (/nested/hop.config) +Monitor imported: nested/deeply-nested/hop.config (/nested/deeply-nested/hop.config) +Monitor imported: test/tests-toggle.config (/test/tests-toggle.config) Monitor nonexistent: /cabal.project.freeze Monitor nonexistent: /cabal.project.local diff --git a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.test.hs b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.test.hs index 2cd9e59c5b2..e60129e5504 100644 --- a/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.test.hs +++ b/cabal-testsuite/PackageTests/ProjectImport/FileMonitoring/cabal.test.hs @@ -19,10 +19,7 @@ main = do cabalTest' "main-project" . recordMode DoNotRecord $ do let opts = ["--project-file=cabal.project"] expectedMonitoring <- - -- TODO: When fixed, use expected output, not the actual output and delete - -- the actual output file. - -- readFileVerbatim "cabal.main-project.expect.txt" - readFileVerbatim "cabal.main-project.actual.txt" + readFileVerbatim "cabal.main-project.expect.txt" runProjectTest expectedMonitoring opts runCommandTest opts runConfigureTest "cabal.project.local" opts @@ -32,20 +29,14 @@ main = do cabalTest' "local-only" . recordMode DoNotRecord $ do let opts = ["--project-file=cabal.local-only.project"] expectedMonitoring <- - -- TODO: When fixed, use expected output, not the actual output and delete - -- the actual output file. - -- readFileVerbatim "cabal.local-only.expect.txt" - readFileVerbatim "cabal.local-only.actual.txt" + readFileVerbatim "cabal.local-only.expect.txt" runProjectTest expectedMonitoring opts runCommandTest opts cabalTest' "freeze-only" . recordMode DoNotRecord $ do let opts = ["--project-file=cabal.freeze-only.project"] expectedMonitoring <- - -- TODO: When fixed, use expected output, not the actual output and delete - -- the actual output file. - -- readFileVerbatim "cabal.freeze-only.expect.txt" - readFileVerbatim "cabal.freeze-only.actual.txt" + readFileVerbatim "cabal.freeze-only.expect.txt" runProjectTest expectedMonitoring opts runCommandTest opts runConfigureTest "cabal.freeze-only.project.local" opts @@ -131,10 +122,10 @@ runProjectTest expectMsg projOpts = do cwd <- testCurrentDir <$> getTestEnv let configFile = cwd "test" "tests-toggle.config" liftIO $ writeFile configFile "package *\n tests: False" - -- TODO: If project imports were properly monitored, the build - -- should succeed without a clean. When fixed, remove the clean. + -- NOTE: When project imports are properly monitored, the build succeeds + -- without a clean or touching the root project file. The change to the + -- imported file is noticed. log "A clean should not be necessary with proper monitoring of files a project imports." - _ <- cabal' "clean" projOpts projDisabledTests <- cabal' "build" projOpts assertOutputDoesNotContain testNotYetImplementedMsg projDisabledTests assertOutputDoesNotContain failureMsg projDisabledTests diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index 3148629f627..75e83a353fb 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -2,12 +2,45 @@ {-# LANGUAGE NondecreasingIndentation #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} +{-# OPTIONS_GHC -Wno-duplicate-exports #-} {-# OPTIONS_GHC -Wno-redundant-constraints #-} -- | Generally useful definitions that we expect most test scripts -- to use. module Test.Cabal.Prelude - ( module Test.Cabal.Prelude + ( -- * Assertions + + -- ** Assert Marked Output + -- $marked-output + assertOutputContains + , assertOutputDoesNotContain + , assertOutputMatches + , assertOutputDoesNotMatch + , assertOn + + -- ** Assert File + , assertFileDoesContain + , assertFileDoesNotContain + , assertFindInFile + , assertAnyFileContains + , assertNoFileContains + + -- ** Assert Glob + , assertGlobMatches + , assertGlobDoesNotMatch + , assertGlobMatchesTestDir + , assertGlobDoesNotMatchTestDir + + -- ** Other Assertions + , assertBool + , assertEqual + , assertExitCode + , assertFailure + , assertNotEqual + , assertRegex + + -- * Re-exports + , module Test.Cabal.Prelude , module Test.Cabal.Monad , module Test.Cabal.NeedleHaystack , module Test.Cabal.Run @@ -36,9 +69,6 @@ import Distribution.Simple.Configure import Distribution.Simple.PackageDescription (readGenericPackageDescription) import Distribution.Simple.Program import Distribution.Simple.Utils - ( tryFindPackageDesc - , withFileContents - ) import Distribution.System (Arch (JavaScript), OS (Linux, OSX, Windows), buildArch, buildOS) import Distribution.Types.LocalBuildInfo import Distribution.Utils.Path @@ -67,7 +97,7 @@ import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Lazy as BSL import qualified Data.Char as Char -import Data.List (isInfixOf, isPrefixOf, stripPrefix) +import Data.List (isPrefixOf, stripPrefix) import Data.Maybe (fromMaybe, isJust, mapMaybe) import Network.Wait (waitTcpVerbose) import System.Directory @@ -85,6 +115,19 @@ import System.Process import System.Posix.Resource #endif +-- $marked-output +-- When asserting on the output of a command we only have access to the marked +-- output. That is the output between these markers: +-- +-- @ +-- -----BEGIN CABAL OUTPUT----- +-- -----END CABAL OUTPUT----- +-- @ +-- +-- This is the output from 'notice' and `warn` messages. It does not include the +-- output from `debug` or `info` messages. This is mostly because the output +-- from `debug` and `info` messages is not expected to be deterministic. + ------------------------------------------------------------------------ -- * Utilities diff --git a/changelog.d/12077.md b/changelog.d/12077.md new file mode 100644 index 00000000000..871a4e3441b --- /dev/null +++ b/changelog.d/12077.md @@ -0,0 +1,9 @@ +--- +synopsis: Fix monitoring of project file imports +packages: [cabal-install] +prs: 12077 +issues: [10255] +--- + +Watch for changes in all project files, the root `cabal.project` and all local +files it imports. We don't monitor remote URI imports.