Skip to content

Commit

Permalink
Have Cabal build a Setup executable and test with it.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ezyang committed Mar 31, 2016
1 parent ef00fc4 commit 3523af5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ library
if !impl(ghc >= 7.0)
default-extensions: CPP

executable cabal-setup
build-depends: base, Cabal
main-is: Setup.hs
-- Actually, we don't really want anything from tests; just
-- want to make sure we don't pick up source files in .
hs-source-dirs: tests
default-language: Haskell98

-- Small, fast running tests.
test-suite unit-tests
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -380,6 +388,7 @@ test-suite package-tests
PackageTests.TestSuiteTests.ExeV10.Check
PackageTests.PackageTester
hs-source-dirs: tests
build-tools: cabal-setup
build-depends:
base,
containers,
Expand Down
4 changes: 0 additions & 4 deletions Cabal/tests/PackageTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ main = do
putStrLn $ "CABAL_PACKAGETESTS_DB_STACK=" ++ showDBStack packageDBStack0
putStrLn $ "CABAL_PACKAGETESTS_WITH_DB_STACK=" ++ showDBStack withGhcDBStack0

-- Create a shared Setup executable to speed up Simple tests
putStrLn $ "Building shared ./Setup executable"
rawCompileSetup verbosity suite [] "tests"

defaultMainWithIngredients options $
runTestTree "Package Tests" (tests suite)

Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/PackageTests/PackageTester.hs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ type PackageSpec = FilePath
simpleSetupPath :: TestM FilePath
simpleSetupPath = do
(suite, _) <- ask
return (absoluteCWD suite </> "tests/Setup")
return (cabalDistPref suite </> "build" </> "cabal-setup" </> "cabal-setup")

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

0 comments on commit 3523af5

Please sign in to comment.