Skip to content

Commit 2603ac6

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 d9011ab commit 2603ac6

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
@@ -342,6 +342,14 @@ library
342342
if !impl(ghc >= 7.0)
343343
default-extensions: CPP
344344

345+
executable cabal-setup
346+
build-depends: base, Cabal
347+
main-is: Setup.hs
348+
-- Actually, we don't really want anything from tests; just
349+
-- want to make sure we don't pick up source files in .
350+
hs-source-dirs: tests
351+
default-language: Haskell98
352+
345353
-- Small, fast running tests.
346354
test-suite unit-tests
347355
type: exitcode-stdio-1.0
@@ -380,6 +388,7 @@ test-suite package-tests
380388
PackageTests.TestSuiteTests.ExeV10.Check
381389
PackageTests.PackageTester
382390
hs-source-dirs: tests
391+
build-tools: cabal-setup
383392
build-depends:
384393
base,
385394
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)