aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2020-01-11 07:46:33 +0100
committerDaniel Gröber <dxld@darkboxed.org>2020-05-02 15:44:26 +0200
commit852dbc69d276e19add3917d17dff5541d84e29d4 (patch)
treeb01a16ee9a03fb491dfdf50a7bc717b76e95d445 /tests
parentf0741c61bd82ec0f94edcfa8d950f349eac86c33 (diff)
Fix Cabal version selection for build-type:Custom
Previously we would pick up Stack's Cabal version with ghc-pkg on the global package-db. This however ignores that Stack also supports custom Setup.hs with the Cabal version from the snapshot instead. In cabal v2-build we have a similar problem. We used to assume that plan.json's cabal-lib-version is used uniformly across units but this is similarly untrue. To fix both of these we re-stage the cabal version query to after reconfiguring a unit, then we can just lookup the Cabal version in setup-config. Fixes #95
Diffstat (limited to 'tests')
-rw-r--r--tests/CompileTest.hs6
-rw-r--r--tests/GhcSession.hs34
-rw-r--r--tests/custom-setup/Lib.hs8
-rw-r--r--tests/custom-setup/Setup.hs2
-rw-r--r--tests/custom-setup/custom-setup.cabal13
-rw-r--r--tests/custom-setup/packages.list1
-rw-r--r--tests/custom-setup/stack.yaml3
7 files changed, 56 insertions, 11 deletions
diff --git a/tests/CompileTest.hs b/tests/CompileTest.hs
index 02580f8..e77e3de 100644
--- a/tests/CompileTest.hs
+++ b/tests/CompileTest.hs
@@ -155,11 +155,11 @@ testCabalVersions versions = do
mcabalVersions <- runMaybeT $ listCabalVersions (Just db)
case mcabalVersions of
Just [hdver] ->
- return $ che0 (CabalVersion hdver) (Just db)
+ return $ che0 (CabalVersion hdver) [db]
_ ->
- return $ che0 (CabalHEAD ()) Nothing
+ return $ che0 (CabalHEAD ()) []
(CabalVersion ver) ->
- return $ che0 (CabalVersion ver) Nothing
+ return $ che0 (CabalVersion ver) []
compileHelper che
diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs
index a4e7d62..c776164 100644
--- a/tests/GhcSession.hs
+++ b/tests/GhcSession.hs
@@ -2,8 +2,8 @@
DataKinds, ExistentialQuantification, PolyKinds, ViewPatterns,
DeriveFunctor, MonoLocalBinds, GADTs, MultiWayIf #-}
-{-| This test ensures we can get a GHC API session up and running in a variety of
- project environments.
+{-| This test ensures we can get a GHC API session up and running in a
+ variety of project environments.
-}
module Main where
@@ -126,13 +126,31 @@ main = do
-- fucking awesome store cache to keep CI times down.
--
-- TODO: Better test coverage for helper compilation with the other two!
- [ TC (TN "exelib") (parseVer "1.10") (parseVer "0") []
- , TC (TN "exeintlib") (parseVer "2.0") (parseVer "0") []
- , TC (TN "fliblib") (parseVer "2.0") (parseVer "0") []
- , TC (TN "bkpregex") (parseVer "2.0") (parseVer "8.1") [Cabal CV2, Cabal CV1]
- , TC (TN "src-repo") (parseVer "2.4") (parseVer "0") [Cabal CV2]
+ [ TC (TN "exelib") (parseVer "1.10") (parseVer "0") []
+ , TC (TN "exeintlib") (parseVer "2.0") (parseVer "0") []
+ , TC (TN "fliblib") (parseVer "2.0") (parseVer "0") []
+ , TC (TN "custom-setup") (parseVer "1.24") (parseVer "0") [Cabal CV2, Stack]
+ -- ^ Custom setup has issues in v1. Specifically we can get into the
+ -- situation where v1-configure --with-ghc=... will pick one Cabal
+ -- lib version but then v1-build (without --with-ghc) will pick
+ -- another because the system ghc has different packages available
+ -- than the --with-ghc one.
+ --
+ -- At this point a setup recompile happens and hell breaks loose
+ -- because setup-config is mismatched. The reason we can't just pass
+ -- --with-ghc to v1-build to fix this is that it will actually ignore
+ -- it as far as setup compilation is concerned while v1-configure
+ -- will pick it up.
+ --
+ -- We could fuck around with $PATH in the v1-build case too but I
+ -- really don't think that many people use v1 still and with
+ -- built-type:custom no less.
+ --
+ -- See haskell/cabal#6749
+ , TC (TN "bkpregex") (parseVer "2.0") (parseVer "8.1") [Cabal CV2, Cabal CV1]
+ , TC (TN "src-repo") (parseVer "2.4") (parseVer "0") [Cabal CV2]
, let multipkg_loc = TF "tests/multipkg/" "proj/" "proj/proj.cabal" in
- TC multipkg_loc (parseVer "1.10") (parseVer "0") [Cabal CV2, Stack]
+ TC multipkg_loc (parseVer "1.10") (parseVer "0") [Cabal CV2, Stack]
-- min Cabal lib ver -^ min GHC ver -^
]
diff --git a/tests/custom-setup/Lib.hs b/tests/custom-setup/Lib.hs
new file mode 100644
index 0000000..417a0ad
--- /dev/null
+++ b/tests/custom-setup/Lib.hs
@@ -0,0 +1,8 @@
+module Lib where
+
+import System.Directory
+import System.FilePath
+
+filepath = "a" </> "b"
+directory = doesFileExist "Exe.hs"
+foo = 1
diff --git a/tests/custom-setup/Setup.hs b/tests/custom-setup/Setup.hs
new file mode 100644
index 0000000..9a994af
--- /dev/null
+++ b/tests/custom-setup/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/tests/custom-setup/custom-setup.cabal b/tests/custom-setup/custom-setup.cabal
new file mode 100644
index 0000000..63410ac
--- /dev/null
+++ b/tests/custom-setup/custom-setup.cabal
@@ -0,0 +1,13 @@
+name: custom-setup
+version: 0
+build-type: Custom
+cabal-version: >=1.10
+extra-source-files: stack.yaml
+
+custom-setup
+ setup-depends: base, Cabal
+
+library
+ exposed-modules: Lib
+ build-depends: base, filepath, directory
+ default-language: Haskell2010
diff --git a/tests/custom-setup/packages.list b/tests/custom-setup/packages.list
new file mode 100644
index 0000000..80e52ce
--- /dev/null
+++ b/tests/custom-setup/packages.list
@@ -0,0 +1 @@
+./
diff --git a/tests/custom-setup/stack.yaml b/tests/custom-setup/stack.yaml
new file mode 100644
index 0000000..27cc995
--- /dev/null
+++ b/tests/custom-setup/stack.yaml
@@ -0,0 +1,3 @@
+resolver: lts-0.0 # will be overridden on the commandline
+packages:
+- ./