Skip to content

Have Cabal build a Setup executable and test with it. #3260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that cabal install Cabal will now also install cabal-setup. Would be nice to avoid that, perhaps by building cabal-setup only when a flag is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still testing, but how does something like this look:

diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal
index 494eb97..b182bc6 100644
--- a/Cabal/Cabal.cabal
+++ b/Cabal/Cabal.cabal
@@ -212,6 +212,9 @@ source-repository head
 flag bundled-binary-generic
   default: False

+flag cabal-setup-buildable
+  default: False
+
 library
   build-depends:
     array      >= 0.1 && < 0.6,
@@ -347,6 +350,10 @@ library
     default-extensions: CPP

 executable cabal-setup
+  if flag(cabal-setup-buildable)
+    buildable: True
+  else
+    buildable: False
   build-depends: base, Cabal
   main-is: Setup.hs
   -- Actually, we don't really want anything from tests; just
@@ -392,7 +399,11 @@ test-suite package-tests
     PackageTests.TestSuiteTests.ExeV10.Check
     PackageTests.PackageTester
   hs-source-dirs: tests
-  build-tools: cabal-setup
+  if flag(cabal-setup-buildable)
+    buildable: True
+    build-tools: cabal-setup
+  else
+    buildable: False
   build-depends:
     base,
     containers,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's what I had I mind. Is Cabal smart enough to see that --enable-tests must imply cabal-setup-buildable: True? Then maybe the second conditional could be elided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, because build-tools are not considered during dependency resolution; this is bug #220

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, this interacts poorly with new-build, now it thinks that the package has no component named package-tests. Reported in #3262.

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 @@ -187,10 +187,6 @@ main = do
(showPackageDbList (uninterpretPackageDBFlags
packageDBStack0)))

-- 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 @@ -204,7 +204,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