Skip to content

Commit df57fb0

Browse files
committed
Have Cabal build a Setup executable and test with it.
I recently discovered that build-tools can be used to specify dependencies on internal executables (haskell#220). This means that we can make a nice improvement to the package-tests test suite: instead of manually building a Setup.hs script ourselves, we can add one to the Cabal file for Cabal, and have the test suite have a build-tools dependency on it. Perhaps the only objection to this is that the Cabal *library* now has an executable cabal-setup. Maybe with some buildable shenanigans we can make it so that we never build this executable unless the user asks for it, or the test suite is enabled. Alternately, cabal-setup is a generally handy executable to have around. Signed-off-by: Edward Z. Yang <[email protected]>
1 parent 4004b2c commit df57fb0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Cabal/Cabal.cabal

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ library
346346
if !impl(ghc >= 7.0)
347347
default-extensions: CPP
348348

349+
executable cabal-setup
350+
build-depends: base, Cabal
351+
main-is: Setup.hs
352+
-- Actually, we don't really want anything from tests; just
353+
-- want to make sure we don't pick up source files in .
354+
hs-source-dirs: tests
355+
default-language: Haskell98
356+
349357
-- Small, fast running tests.
350358
test-suite unit-tests
351359
type: exitcode-stdio-1.0
@@ -384,6 +392,7 @@ test-suite package-tests
384392
PackageTests.TestSuiteTests.ExeV10.Check
385393
PackageTests.PackageTester
386394
hs-source-dirs: tests
395+
build-tools: cabal-setup
387396
build-depends:
388397
base,
389398
containers,

Cabal/tests/PackageTests.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ main = do
227227
putStrLn $ "CABAL_PACKAGETESTS_DB_STACK=" ++ showDBStack packageDBStack0
228228
putStrLn $ "CABAL_PACKAGETESTS_WITH_DB_STACK=" ++ showDBStack withGhcDBStack0
229229

230-
-- Create a shared Setup executable to speed up Simple tests
231-
putStrLn $ "Building shared ./Setup executable"
232-
rawCompileSetup verbosity suite [] "tests"
233-
234230
defaultMainWithIngredients options $
235231
runTestTree "Package Tests" (tests suite)
236232

Cabal/tests/PackageTests/PackageTester.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ type PackageSpec = FilePath
277277
simpleSetupPath :: TestM FilePath
278278
simpleSetupPath = do
279279
(suite, _) <- ask
280-
return (absoluteCWD suite </> "tests/Setup")
280+
return (cabalDistPref suite </> "build" </> "cabal-setup" </> "cabal-setup")
281281

282282
-- | The absolute path to the directory containing the files for
283283
-- this tests; usually @Check.hs@ and any test packages.

0 commit comments

Comments
 (0)