Skip to content

Commit ac33796

Browse files
committed
test fixups
1 parent d13e968 commit ac33796

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

cabal-install/src/Distribution/Client/InLibrary.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ where
2020
import Distribution.Client.Compat.Prelude
2121
import Prelude ()
2222

23+
import Distribution.Backpack.DescribeUnitId (setupMessage')
2324
import Distribution.Client.ProjectPlanning.Types
2425
import Distribution.Client.RebuildMonad
2526
import qualified Distribution.Client.SetupHooks.CallHooksExe as ExternalHooksExe
@@ -136,6 +137,17 @@ configure
136137
confHooks = configureHooks $ ExternalHooksExe.buildTypeSetupHooks mbWorkDir distPref bt
137138

138139
-- Configure package
140+
let pkgId :: PD.PackageIdentifier
141+
pkgId = PD.package pkgDesc
142+
case mbComp of
143+
Nothing -> setupMessage verbosity "Configuring" pkgId
144+
Just cname ->
145+
setupMessage'
146+
verbosity
147+
"Configuring"
148+
pkgId
149+
cname
150+
(Just (Cabal.configInstantiateWith cfg))
139151

140152
-- SetupHooks TODO: we should avoid re-doing package-wide things
141153
-- over and over in the per-component world, e.g.

cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/SetupHooksRecompilation.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ custom-setup
1212

1313
library
1414
exposed-modules: MyLib
15-
build-depends: base ^>=4.19.1.0
15+
build-depends: base >= 4.12 && < 5.0
1616
hs-source-dirs: src
1717
default-language: Haskell2010
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import Test.Cabal.Prelude
22

3+
import System.Directory ( doesFileExist )
4+
35
main = cabalTest $ do
4-
mpkgdb <- testPackageDbPath <$> getTestEnv
5-
case mpkgdb of
6+
env <- getTestEnv
7+
case testPackageDbPath env of
68
Nothing -> skip "Cabal-hooks library unavailable."
79
Just pkgdb -> recordMode DoNotRecord $ do
810
cabal "build" [ "--package-db=" ++ pkgdb ]
9-
liftIO $ appendFile "SetupHooks.hs" "definitely-wrong!"
11+
let setupHooksPath = testCurrentDir env </> "SetupHooks.hs"
12+
setupHooksExists <- liftIO $ doesFileExist setupHooksPath
13+
unless setupHooksExists $
14+
error "Broken test: tried to write to a SetupHooks.hs file that doesn't exist."
15+
liftIO $ appendFile setupHooksPath "this should fail to compile!"
1016
-- If this doesn't fail, it's because we didn't re-build.
1117
fails $ cabal "build" [ "--package-db=" ++ pkgdb ]

cabal-testsuite/main/cabal-tests.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ buildCabalLibsProject projString verb mbGhc dir = do
142142
, "--project-file=" ++ dir </> "cabal.project-test"
143143
, "build"
144144
, "-w", programPath ghc
145-
, "Cabal", "Cabal-syntax", "Cabal-hooks"
145+
, "Cabal", "Cabal-syntax", "Cabal-hooks", "hooks-exe"
146146
] ) { progInvokeCwd = Just dir })
147147
return final_package_db
148148

@@ -169,7 +169,8 @@ buildCabalLibsSpecific ver verb mbGhc builddir_rel = do
169169
buildCabalLibsIntree :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO FilePath
170170
buildCabalLibsIntree root verb mbGhc builddir_rel = do
171171
dir <- canonicalizePath (builddir_rel </> "intree")
172-
buildCabalLibsProject ("packages: " ++ root </> "Cabal" ++ " " ++ root </> "Cabal-syntax" ++ " " ++ root </> "Cabal-hooks") verb mbGhc dir
172+
let libs = [ "Cabal", "Cabal-syntax", "Cabal-hooks", "hooks-exe", "../process" ]
173+
buildCabalLibsProject ("packages: " ++ unwords ( map ( root </> ) libs ) ) verb mbGhc dir
173174

174175
main :: IO ()
175176
main = do

0 commit comments

Comments
 (0)