diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding.hs b/cabal-install/src/Distribution/Client/ProjectBuilding.hs index 19a6661b6f6..0381af55004 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding.hs @@ -81,7 +81,7 @@ import Distribution.Types.BuildType import Distribution.Types.PackageDescription.Lens (componentModules) import Distribution.Simple.Program import qualified Distribution.Simple.Setup as Cabal -import Distribution.Simple.Command (CommandUI) +import Distribution.Simple.Command (CommandUI, commandName) import qualified Distribution.Simple.Register as Cabal import Distribution.Simple.LocalBuildInfo ( ComponentName(..), LibraryName(..) ) diff --git a/cabal-install/src/Distribution/Client/SetupWrapper.hs b/cabal-install/src/Distribution/Client/SetupWrapper.hs index e4885ed07c6..9453897e88e 100644 --- a/cabal-install/src/Distribution/Client/SetupWrapper.hs +++ b/cabal-install/src/Distribution/Client/SetupWrapper.hs @@ -145,6 +145,7 @@ data SetupMethod = InternalMethod -- child process | ExternalMethod FilePath -- ^ run Cabal commands through a custom \"Setup\" executable + deriving Show -- TODO: The 'setupWrapper' and 'SetupScriptOptions' should be split into two -- parts: one that has no policy and just does as it's told with all the diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index 65278bc12d1..c1527e0bda2 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -37,22 +37,26 @@ import Distribution.Solver.Types.ConstraintSource import Distribution.Solver.Types.PackageConstraint ( PackageProperty(PackagePropertySource) ) -import qualified Distribution.Client.CmdBuild as CmdBuild -import qualified Distribution.Client.CmdRepl as CmdRepl -import qualified Distribution.Client.CmdRun as CmdRun -import qualified Distribution.Client.CmdTest as CmdTest -import qualified Distribution.Client.CmdBench as CmdBench -import qualified Distribution.Client.CmdHaddock as CmdHaddock -import qualified Distribution.Client.CmdListBin as CmdListBin +import qualified Distribution.Client.CmdBuild as CmdBuild +import qualified Distribution.Client.CmdRepl as CmdRepl +import qualified Distribution.Client.CmdRun as CmdRun +import qualified Distribution.Client.CmdTest as CmdTest +import qualified Distribution.Client.CmdBench as CmdBench +import qualified Distribution.Client.CmdHaddock as CmdHaddock +import qualified Distribution.Client.CmdHaddockProject as CmdHaddockProject +import qualified Distribution.Client.CmdListBin as CmdListBin import Distribution.Package import Distribution.PackageDescription import Distribution.InstalledPackageInfo (InstalledPackageInfo) -import Distribution.Simple.Setup (toFlag, HaddockFlags(..), defaultHaddockFlags) -import Distribution.Client.Setup (globalCommand) +import Distribution.Simple.Setup + ( toFlag, HaddockFlags(..), HaddockProjectFlags (..) + , defaultHaddockFlags, defaultHaddockProjectFlags ) +import Distribution.Client.Setup (globalCommand, globalStoreDir) import Distribution.Client.Config (loadConfig, SavedConfig(savedGlobalFlags)) import Distribution.Simple.Compiler import Distribution.Simple.Command +import Distribution.Client.GlobalFlags (defaultGlobalFlags) import qualified Distribution.Simple.Flag as Flag import Distribution.System import Distribution.Version @@ -149,6 +153,13 @@ tests config = testCase "Test Nix Flag" testNixFlags, testCase "Test Ignore Project Flag" testIgnoreProjectFlag ] +-- `haddock-project` is only supported by `haddock-2.26.1` and above which is +-- shipped with `ghc-9.4` +#if __GLASGOW_HASKELL__ >= 904 + , testGroup "haddock-project" + [ testCase "dependencies" testHaddockProjectDependencies + ] +#endif ] testTargetSelectors :: (String -> IO ()) -> Assertion @@ -1968,3 +1979,34 @@ testIgnoreProjectFlag = do emptyConfig = mempty ignoreSetConfig :: ProjectConfig ignoreSetConfig = mempty { projectConfigShared = mempty { projectConfigIgnoreProject = Flag True } } + + +cleanHaddockProject :: FilePath -> IO () +cleanHaddockProject testdir = do + cleanProject testdir + let haddocksdir = basedir testdir "haddocks" + alreadyExists <- doesDirectoryExist haddocksdir + when alreadyExists $ removePathForcibly haddocksdir + let storedir = basedir testdir "store" + alreadyExists' <- doesDirectoryExist storedir + when alreadyExists' $ removePathForcibly storedir + + +#if __GLASGOW_HASKELL__ >= 904 +testHaddockProjectDependencies :: Assertion +testHaddockProjectDependencies = do + let dir = basedir testdir + cleanHaddockProject testdir + withCurrentDirectory dir $ do + CmdHaddockProject.haddockProjectAction + defaultHaddockProjectFlags { haddockProjectVerbosity = Flag verbosity } + ["all"] + defaultGlobalFlags { globalStoreDir = Flag "store" } + + let haddock = "haddocks" "async" "async.haddock" + hasHaddock <- doesFileExist haddock + unless hasHaddock $ assertFailure ("File `" ++ haddock ++ "` does not exist.") + cleanHaddockProject testdir + where + testdir = "haddock-project/dependencies" +#endif diff --git a/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/a.cabal b/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/a.cabal new file mode 100644 index 00000000000..831be636bec --- /dev/null +++ b/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/a.cabal @@ -0,0 +1,10 @@ +name: a +version: 0.1.0.0 +build-type: Simple +cabal-version: >= 1.10 + +library + exposed-modules: MyLib + build-depends: base, async + hs-source-dirs: src + default-language: Haskell2010 diff --git a/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/cabal.project b/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/cabal.project new file mode 100644 index 00000000000..052c3c8685d --- /dev/null +++ b/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/cabal.project @@ -0,0 +1,8 @@ +packages: . +-- `jobs` is necessary to use `InternalMethod :: SetupMethod`. +jobs: 1 + +documentation: True + +package async + documentation: True diff --git a/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/src/MyLib.hs b/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/src/MyLib.hs new file mode 100644 index 00000000000..b0b955743ad --- /dev/null +++ b/cabal-install/tests/IntegrationTests2/haddock-project/dependencies/src/MyLib.hs @@ -0,0 +1,6 @@ +module MyLib (someFunc) where + +import Control.Concurrent.Async + +someFunc :: IO (Async ()) +someFunc = async (return ())