summaryrefslogtreecommitdiff
path: root/testsuite/tests/cabal/Makefile
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2014-07-21 05:50:19 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-07-21 05:54:50 -0700
commitd7c807f7975c13444e1ce79e4c36dd802321cf40 (patch)
treec85f47a4b74d7d36d344042927c5cc23441702ed /testsuite/tests/cabal/Makefile
parentbb06e2a8ae38f0fcfbd2cdfa1f42dfa1e252c939 (diff)
downloadhaskell-d7c807f7975c13444e1ce79e4c36dd802321cf40.tar.gz
[ghc-pkg] Fix #5442 by using the flag db stack to modify packages.
Summary: Previously, the full database stack was used for ghc-pkg to modify packages, which meant that commands like 'ghc-pkg unregister --user' worked the same as 'ghc-pkg unregister'. Since package modification is a "read and write" operation, we should use the flag db stack (which is currently used for reads) to determine which database to update. There is also a new flag --user-package-db, which lets you explicitly set the user database (as seen by --user). This was mostly added to aid in testing, but could be useful for end users as well. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonmar, hvr, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D84
Diffstat (limited to 'testsuite/tests/cabal/Makefile')
-rw-r--r--testsuite/tests/cabal/Makefile54
1 files changed, 54 insertions, 0 deletions
diff --git a/testsuite/tests/cabal/Makefile b/testsuite/tests/cabal/Makefile
index f0091bceeb..e8ed2bd817 100644
--- a/testsuite/tests/cabal/Makefile
+++ b/testsuite/tests/cabal/Makefile
@@ -165,6 +165,60 @@ shadow:
@echo "should SUCCEED:"
'$(TEST_HC)' $(TEST_HC_OPTS) -package-db $(PKGCONFSHADOW1) -package-db $(PKGCONFSHADOW2) -package-id shadowdep-1-XXX -c shadow.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
+ '$(GHC_PKG)' init package.conf.T5442a.global
+ '$(GHC_PKG)' init package.conf.T5442a.user
+ '$(GHC_PKG)' -f package.conf.T5442a.global register --force-files test.pkg 2>/dev/null
+ '$(GHC_PKG)' -f package.conf.T5442a.user register --force-files test.pkg 2>/dev/null
+ '$(GHC_PKG)' --global-package-db=package.conf.T5442a.global --user-package-db=package.conf.T5442a.user --global unregister testpkg
+ @echo "global (should be empty):"
+ '$(GHC_PKG)' -f package.conf.T5442a.global list --simple-output
+ @echo "user:"
+ '$(GHC_PKG)' -f package.conf.T5442a.user list --simple-output
+
+# If we pass --user, we should ignore instances in the global database
+T5442b:
+ @rm -rf package.conf.T5442b.global package.conf.T5442b.user
+ '$(GHC_PKG)' init package.conf.T5442b.global
+ '$(GHC_PKG)' init package.conf.T5442b.user
+ '$(GHC_PKG)' -f package.conf.T5442b.global register --force-files test.pkg 2>/dev/null
+ ! '$(GHC_PKG)' --global-package-db=package.conf.T5442b.global --user-package-db=package.conf.T5442b.user --user unregister testpkg
+ @echo "global (should have testpkg):"
+ '$(GHC_PKG)' -f package.conf.T5442b.global list --simple-output
+
+# If we pass -f, we should ignore the user and global databases
+T5442c:
+ @rm -rf package.conf.T5442c.global package.conf.T5442c.user package.conf.T5442c.extra
+ '$(GHC_PKG)' init package.conf.T5442c.global
+ '$(GHC_PKG)' init package.conf.T5442c.user
+ '$(GHC_PKG)' init package.conf.T5442c.extra
+ '$(GHC_PKG)' -f package.conf.T5442c.global register --force-files test.pkg 2>/dev/null
+ '$(GHC_PKG)' -f package.conf.T5442c.user register --force-files test.pkg 2>/dev/null
+ ! '$(GHC_PKG)' --global-package-db=package.conf.T5442c.global --user-package-db=package.conf.T5442c.user -f package.conf.T5442c.extra unregister testpkg
+ @echo "global (should have testpkg):"
+ '$(GHC_PKG)' -f package.conf.T5442c.global list --simple-output
+ @echo "use (should have testpkg):"
+ '$(GHC_PKG)' -f package.conf.T5442c.user list --simple-output
+
+# If we pass --global and -f, we remove from the global database, but
+# warn about possible breakage in the full package stack
+T5442d:
+ @rm -rf package.conf.T5442d.global package.conf.T5442d.user package.conf.T5442d.extra
+ '$(GHC_PKG)' init package.conf.T5442d.global
+ '$(GHC_PKG)' init package.conf.T5442d.user
+ '$(GHC_PKG)' init package.conf.T5442d.extra
+ '$(GHC_PKG)' -f package.conf.T5442d.global register --force-files shadow1.pkg 2>/dev/null
+ '$(GHC_PKG)' -f package.conf.T5442d.user register --force-files shadow3.pkg 2>/dev/null
+ '$(GHC_PKG)' --global-package-db=package.conf.T5442d.global -f package.conf.T5442d.extra register --force-files shadow2.pkg 2>/dev/null
+ '$(GHC_PKG)' --global-package-db=package.conf.T5442d.global --user-package-db=package.conf.T5442d.user -f package.conf.T5442d.extra --global unregister shadow --force
+ @echo "global (should be empty):"
+ '$(GHC_PKG)' -f package.conf.T5442d.global list --simple-output
+ @echo "user:"
+ '$(GHC_PKG)' -f package.conf.T5442d.user list --simple-output
+ @echo "extra:"
+ '$(GHC_PKG)' -f package.conf.T5442d.extra list --simple-output
# -----------------------------------------------------------------------------
# Try piping the output of "ghc-pkg describe" into "ghc-pkg update" for