diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-12-14 01:28:43 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-12-21 08:49:06 -0800 |
commit | ee4e1654c31b9c6f6ad9b19ece25f040bbbcbd72 (patch) | |
tree | 8f58c21ea66a817e384fceb01e930df00cb7e7a9 /testsuite/tests/cabal | |
parent | 2189239872322dc363cc5f82e14ab5fb1a6d5b8c (diff) | |
download | haskell-ee4e1654c31b9c6f6ad9b19ece25f040bbbcbd72.tar.gz |
Support for abi-depends for computing shadowing.
Summary:
This is a complete fix based off of
ed7af26606b3a605a4511065ca1a43b1c0f3b51d for handling
shadowing and out-of-order -package-db flags simultaneously.
The general strategy is we first put all databases together,
overriding packages as necessary. Once this is done, we successfully
prune out broken packages, including packages which depend on a package
whose ABI differs from the ABI we need.
Our check gracefully degrades in the absence of abi-depends, as
we only check deps which are recorded in abi-depends.
Contains time and Cabal submodule update.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: niteria, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2846
GHC Trac Issues: #12485
Diffstat (limited to 'testsuite/tests/cabal')
-rw-r--r-- | testsuite/tests/cabal/Makefile | 41 | ||||
-rw-r--r-- | testsuite/tests/cabal/T12485/Makefile | 4 | ||||
-rw-r--r-- | testsuite/tests/cabal/T12485/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/cabal/T12485a.stdout | 3 | ||||
-rw-r--r-- | testsuite/tests/cabal/T1750.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/all.T | 7 | ||||
-rw-r--r-- | testsuite/tests/cabal/shadow1.pkg | 1 | ||||
-rw-r--r-- | testsuite/tests/cabal/shadow2.pkg | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/shadow3.pkg | 1 |
9 files changed, 52 insertions, 12 deletions
diff --git a/testsuite/tests/cabal/Makefile b/testsuite/tests/cabal/Makefile index 45fb6ebb25..64034d4ac4 100644 --- a/testsuite/tests/cabal/Makefile +++ b/testsuite/tests/cabal/Makefile @@ -136,12 +136,14 @@ LOCAL_GHC_PKGSHADOW13 = '$(GHC_PKG)' --no-user-package-db -f $(PKGCONFSHADOW1) - # Test package shadowing behaviour. # -# localshadow1.package.conf: shadowdep-1-XXX <- shadow-1-XXX -# localshadow2.package.conf: shadow-1-XXX +# The general principle is that we shadow in order of declarations, +# but we determine what gets overridden based on ABI dependencies. # -# If the ABI hash of boths shadow-1s are the same, we'll just accept -# the later shadow version. However, if the ABIs are different, we -# should complain! +# Here is the structure of our databases (unitid=abi): +# +# localshadow1.package.conf: shadowdep-1-XXX=ddd -> shadow-1-XXX=aaa +# localshadow2.package.conf: shadow-1-XXX=bbb +# localshadow3.package.conf: shadow-1-XXX=aaa shadow: rm -rf $(PKGCONFSHADOW1) $(PKGCONFSHADOW2) $(PKGCONFSHADOW3) shadow.hs shadow.o shadow.hi shadow.out shadow.hs shadow.hi $(LOCAL_GHC_PKGSHADOW1) init $(PKGCONFSHADOW1) @@ -164,8 +166,8 @@ shadow: if '$(TEST_HC)' $(TEST_HC_OPTS) -package-db $(PKGCONFSHADOW1) -package-db $(PKGCONFSHADOW2) -package shadowdep -c shadow.hs -fno-code; then false; else true; fi # # Reversing the orders of the configs fixes the problem, because now -# the shadow-1-XXX defined in the same DB as shadowdep shadows -# shadow-1-XXX in localshadow2.package.conf +# we prefer the shadow-1 from the first database, which has the correct +# ABI hash for shadowdep-1. # @echo "should SUCCEED:" '$(TEST_HC)' $(TEST_HC_OPTS) -package-db $(PKGCONFSHADOW2) -package-db $(PKGCONFSHADOW1) -package shadowdep -c shadow.hs -fno-code @@ -175,6 +177,31 @@ shadow: @echo "should SUCCEED:" '$(TEST_HC)' $(TEST_HC_OPTS) -package-db $(PKGCONFSHADOW3) -package-db $(PKGCONFSHADOW1) -package shadowdep -c shadow.hs -fno-code +# Test that order we pass databases doesn't matter +# +# 1. shadow-1-XXX=aaa +# 2. shadowdep-1-XXX=ddd (shadow-1-XXX=aaa) +# 3. shadow-1-XXX=bbb +.PHONY: T12485a +T12485a: + rm -rf T12485a.package.conf T12485b.package.conf T12485c.package.conf + '$(GHC_PKG)' --no-user-package-db init T12485a.package.conf + '$(GHC_PKG)' --no-user-package-db init T12485b.package.conf + '$(GHC_PKG)' --no-user-package-db init T12485c.package.conf + '$(GHC_PKG)' --no-user-package-db -f T12485a.package.conf register -v0 --force shadow1.pkg + '$(GHC_PKG)' --no-user-package-db -f T12485b.package.conf register -v0 --force shadow2.pkg + '$(GHC_PKG)' --no-user-package-db -f T12485c.package.conf register -v0 --force shadow3.pkg + echo "main = return ()" > T12485a.hs + # Normal test + @echo "should SUCCEED" + '$(TEST_HC)' $(TEST_HC_OPTS) -package-db T12485a.package.conf -package-db T12485b.package.conf -package shadowdep -c T12485a.hs -fno-code + # Reversed test + @echo "should SUCCEED" + '$(TEST_HC)' $(TEST_HC_OPTS) -package-db T12485b.package.conf -package-db T12485a.package.conf -package shadowdep -c T12485a.hs -fno-code + # Shadow OK, as long as correct one is chosen eventually, even when reversed + @echo "should SUCCEED" + '$(TEST_HC)' $(TEST_HC_OPTS) -package-db T12485b.package.conf -package-db T12485c.package.conf -package-db T12485a.package.conf -package shadowdep -c T12485a.hs -fno-code + # If we pass --global, we should ignore instances in the user database T5442a: @rm -rf package.conf.T5442a.global package.conf.T5442a.user diff --git a/testsuite/tests/cabal/T12485/Makefile b/testsuite/tests/cabal/T12485/Makefile index fc8e9929e6..2ff0c3c0d0 100644 --- a/testsuite/tests/cabal/T12485/Makefile +++ b/testsuite/tests/cabal/T12485/Makefile @@ -9,6 +9,6 @@ T12485 : '$(GHC_PKG)' init b.db '$(GHC_PKG)' -f a.db/ -f b.db/ register b.pkg # register b.pkg in b.db # -package-db in dependency order - '$(TEST_HC)' -XNoImplicitPrelude -fforce-recomp -hide-all-packages -no-user-package-db -package-db a.db -package-db b.db -package-id a-1-XXX -package-id b-1-XXX Main.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -XNoImplicitPrelude -fforce-recomp -hide-all-packages -no-user-package-db -package-db a.db -package-db b.db -package-id a-1-XXX -package-id b-1-XXX Main.hs # -package-db in reverse dependency order - '$(TEST_HC)' -XNoImplicitPrelude -fforce-recomp -hide-all-packages -no-user-package-db -package-db b.db -package-db a.db -package-id a-1-XXX -package-id b-1-XXX Main.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -XNoImplicitPrelude -fforce-recomp -hide-all-packages -no-user-package-db -package-db b.db -package-db a.db -package-id a-1-XXX -package-id b-1-XXX Main.hs diff --git a/testsuite/tests/cabal/T12485/all.T b/testsuite/tests/cabal/T12485/all.T index 63f6d6a1ef..be817eb274 100644 --- a/testsuite/tests/cabal/T12485/all.T +++ b/testsuite/tests/cabal/T12485/all.T @@ -1,5 +1,4 @@ test('T12485', - [extra_clean(['a.db', 'b.db', 'Main.o', 'Main', 'Main.hi']), - expect_broken(12485)], + [extra_clean(['a.db', 'b.db', 'Main.o', 'Main', 'Main.hi'])], run_command, ['$MAKE -s --no-print-directory T12485']) diff --git a/testsuite/tests/cabal/T12485a.stdout b/testsuite/tests/cabal/T12485a.stdout new file mode 100644 index 0000000000..ee83ab293c --- /dev/null +++ b/testsuite/tests/cabal/T12485a.stdout @@ -0,0 +1,3 @@ +should SUCCEED +should SUCCEED +should SUCCEED diff --git a/testsuite/tests/cabal/T1750.stderr b/testsuite/tests/cabal/T1750.stderr index 1809d5b050..53c56714c3 100644 --- a/testsuite/tests/cabal/T1750.stderr +++ b/testsuite/tests/cabal/T1750.stderr @@ -1,5 +1,5 @@ WARNING: there are broken packages. Run 'ghc-pkg check' for more details. <command line>: cannot satisfy -package T1750A: - T1750A-1-XXX is unusable due to missing or recursive dependencies: + T1750A-1-XXX is unusable due to cyclic dependencies: T1750B-1-XXX (use -v for more information) diff --git a/testsuite/tests/cabal/all.T b/testsuite/tests/cabal/all.T index cc874c78c2..64f26396c4 100644 --- a/testsuite/tests/cabal/all.T +++ b/testsuite/tests/cabal/all.T @@ -101,3 +101,10 @@ test('shadow', 'local1shadow2.package.conf', 'local1shadow2.package.conf.old']), run_command, ['$MAKE -s --no-print-directory shadow']) + +test('T12485a', + extra_clean(['T12485a.hi', 'T1750.out', + 'T12485a.package.conf', + 'T12485b.package.conf', + 'T12485c.package.conf']), + run_command, ['$MAKE -s --no-print-directory T12485a']) diff --git a/testsuite/tests/cabal/shadow1.pkg b/testsuite/tests/cabal/shadow1.pkg index 1e3960202c..246d62b2d8 100644 --- a/testsuite/tests/cabal/shadow1.pkg +++ b/testsuite/tests/cabal/shadow1.pkg @@ -4,3 +4,4 @@ id: shadow-1-XXX key: shadow-1-XXX abi: aaa depends: +abi-depends: diff --git a/testsuite/tests/cabal/shadow2.pkg b/testsuite/tests/cabal/shadow2.pkg index 5cd54cca02..9f6410bc10 100644 --- a/testsuite/tests/cabal/shadow2.pkg +++ b/testsuite/tests/cabal/shadow2.pkg @@ -1,5 +1,7 @@ name: shadowdep version: 1 +abi: ddd id: shadowdep-1-XXX key: shadowdep-1-XXX depends: shadow-1-XXX +abi-depends: shadow-1-XXX=aaa diff --git a/testsuite/tests/cabal/shadow3.pkg b/testsuite/tests/cabal/shadow3.pkg index 6640e9da10..04cfb41ee1 100644 --- a/testsuite/tests/cabal/shadow3.pkg +++ b/testsuite/tests/cabal/shadow3.pkg @@ -4,3 +4,4 @@ id: shadow-1-XXX key: shadow-1-XXX abi: bbb depends: +abi-depends: |