summaryrefslogtreecommitdiff
path: root/testsuite/tests/cabal
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2015-12-27 23:57:18 +0100
committerBen Gamari <ben@smart-cactus.org>2015-12-27 23:57:19 +0100
commit1b0001680ef66a2853103974d3f3f956bb0560a3 (patch)
tree76462be00b762ae1ff08e024f76b93f534bba36e /testsuite/tests/cabal
parentc8d0af3107d4a01b73f813e31ac9b989772a2288 (diff)
downloadhaskell-1b0001680ef66a2853103974d3f3f956bb0560a3.tar.gz
The -package flag should select match from right-most package db.
The shadowing and default behavior (in the absence of -hide-all-packages) prefers packages that come from "later" package databases. So for example if tmp1.d and tmp2.d both expose p-1.0, then ghc -package-db tmp1.d -package-db tmp2.d brings the p-1.0 from tmp2.d into scope (and if they have the same IPID, tmp2.d shadows tmp1.d). HOWEVER, -package flags do NOT respect this behavior. ghc -package-db tmp1.d -package-db tmp2.d -package p-1.0 this will force the p-1.0 from tmp1.d to be exposed! This is confusing, so this patch makes the behavior of -package flags consistent. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1709
Diffstat (limited to 'testsuite/tests/cabal')
-rw-r--r--testsuite/tests/cabal/cabal08/Main.hs2
-rw-r--r--testsuite/tests/cabal/cabal08/Makefile32
-rw-r--r--testsuite/tests/cabal/cabal08/Setup.hs2
-rw-r--r--testsuite/tests/cabal/cabal08/all.T9
-rw-r--r--testsuite/tests/cabal/cabal08/cabal08.stdout6
-rw-r--r--testsuite/tests/cabal/cabal08/p1/ChangeLog.md5
-rw-r--r--testsuite/tests/cabal/cabal08/p1/LICENSE30
-rw-r--r--testsuite/tests/cabal/cabal08/p1/P.hs2
-rw-r--r--testsuite/tests/cabal/cabal08/p1/Setup.hs2
-rw-r--r--testsuite/tests/cabal/cabal08/p1/p.cabal14
-rw-r--r--testsuite/tests/cabal/cabal08/p2/ChangeLog.md5
-rw-r--r--testsuite/tests/cabal/cabal08/p2/LICENSE30
-rw-r--r--testsuite/tests/cabal/cabal08/p2/P.hs2
-rw-r--r--testsuite/tests/cabal/cabal08/p2/Setup.hs2
-rw-r--r--testsuite/tests/cabal/cabal08/p2/p.cabal14
15 files changed, 157 insertions, 0 deletions
diff --git a/testsuite/tests/cabal/cabal08/Main.hs b/testsuite/tests/cabal/cabal08/Main.hs
new file mode 100644
index 0000000000..f63ccafefb
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/Main.hs
@@ -0,0 +1,2 @@
+import P
+main = putStrLn p
diff --git a/testsuite/tests/cabal/cabal08/Makefile b/testsuite/tests/cabal/cabal08/Makefile
new file mode 100644
index 0000000000..06b98533c8
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/Makefile
@@ -0,0 +1,32 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+SETUP=../Setup -v0
+
+# in both cases, p2 should be preferred
+cabal08: clean
+ $(MAKE) clean
+ '$(GHC_PKG)' init tmp1.d
+ '$(GHC_PKG)' init tmp2.d
+ '$(TEST_HC)' -v0 --make Setup
+ cd p1 && $(SETUP) clean
+ cd p1 && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp1.d --prefix='$(PWD)/inst-p1'
+ cd p1 && $(SETUP) build
+ cd p1 && $(SETUP) copy
+ cd p1 && $(SETUP) register
+ cd p2 && $(SETUP) clean
+ cd p2 && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp2.d --prefix='$(PWD)/inst-p2'
+ cd p2 && $(SETUP) build
+ cd p2 && $(SETUP) copy
+ cd p2 && $(SETUP) register
+ '$(TEST_HC)' $(TEST_HC_OPTS) -package-db tmp1.d -package-db tmp2.d Main.hs
+ ./Main
+ '$(TEST_HC)' $(TEST_HC_OPTS) -package-db tmp1.d -package-db tmp2.d -hide-all-packages -package base -package p Main.hs
+ ./Main
+ifneq "$(CLEANUP)" ""
+ $(MAKE) clean
+endif
+
+clean :
+ $(RM) -r tmp*.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext)
diff --git a/testsuite/tests/cabal/cabal08/Setup.hs b/testsuite/tests/cabal/cabal08/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/cabal08/all.T b/testsuite/tests/cabal/cabal08/all.T
new file mode 100644
index 0000000000..fc4221a769
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/all.T
@@ -0,0 +1,9 @@
+if default_testopts.cleanup != '':
+ cleanup = 'CLEANUP=1'
+else:
+ cleanup = ''
+
+test('cabal08',
+ normal,
+ run_command,
+ ['$MAKE -s --no-print-directory cabal08 ' + cleanup])
diff --git a/testsuite/tests/cabal/cabal08/cabal08.stdout b/testsuite/tests/cabal/cabal08/cabal08.stdout
new file mode 100644
index 0000000000..8f97cd409f
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/cabal08.stdout
@@ -0,0 +1,6 @@
+[1 of 1] Compiling Main ( Main.hs, Main.o )
+Linking Main ...
+p2
+[1 of 1] Compiling Main ( Main.hs, Main.o )
+Linking Main ...
+p2
diff --git a/testsuite/tests/cabal/cabal08/p1/ChangeLog.md b/testsuite/tests/cabal/cabal08/p1/ChangeLog.md
new file mode 100644
index 0000000000..b454db5cb3
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p1/ChangeLog.md
@@ -0,0 +1,5 @@
+# Revision history for p
+
+## 0.1.0.0 -- YYYY-mm-dd
+
+* First version. Released on an unsuspecting world.
diff --git a/testsuite/tests/cabal/cabal08/p1/LICENSE b/testsuite/tests/cabal/cabal08/p1/LICENSE
new file mode 100644
index 0000000000..c8cc6abc28
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p1/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2015, Edward Z. Yang
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Edward Z. Yang nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/testsuite/tests/cabal/cabal08/p1/P.hs b/testsuite/tests/cabal/cabal08/p1/P.hs
new file mode 100644
index 0000000000..e3109b2ef0
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p1/P.hs
@@ -0,0 +1,2 @@
+module P where
+p = "p1"
diff --git a/testsuite/tests/cabal/cabal08/p1/Setup.hs b/testsuite/tests/cabal/cabal08/p1/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p1/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/cabal08/p1/p.cabal b/testsuite/tests/cabal/cabal08/p1/p.cabal
new file mode 100644
index 0000000000..8624a0497e
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p1/p.cabal
@@ -0,0 +1,14 @@
+name: p
+version: 0.1.0.0
+license: BSD3
+license-file: LICENSE
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+extra-source-files: ChangeLog.md
+cabal-version: >=1.10
+
+library
+ exposed-modules: P
+ build-depends: base, containers
+ default-language: Haskell2010
diff --git a/testsuite/tests/cabal/cabal08/p2/ChangeLog.md b/testsuite/tests/cabal/cabal08/p2/ChangeLog.md
new file mode 100644
index 0000000000..b454db5cb3
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p2/ChangeLog.md
@@ -0,0 +1,5 @@
+# Revision history for p
+
+## 0.1.0.0 -- YYYY-mm-dd
+
+* First version. Released on an unsuspecting world.
diff --git a/testsuite/tests/cabal/cabal08/p2/LICENSE b/testsuite/tests/cabal/cabal08/p2/LICENSE
new file mode 100644
index 0000000000..c8cc6abc28
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p2/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2015, Edward Z. Yang
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Edward Z. Yang nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/testsuite/tests/cabal/cabal08/p2/P.hs b/testsuite/tests/cabal/cabal08/p2/P.hs
new file mode 100644
index 0000000000..2f8fe77f25
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p2/P.hs
@@ -0,0 +1,2 @@
+module P where
+p = "p2"
diff --git a/testsuite/tests/cabal/cabal08/p2/Setup.hs b/testsuite/tests/cabal/cabal08/p2/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p2/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/cabal08/p2/p.cabal b/testsuite/tests/cabal/cabal08/p2/p.cabal
new file mode 100644
index 0000000000..dc88c82cbd
--- /dev/null
+++ b/testsuite/tests/cabal/cabal08/p2/p.cabal
@@ -0,0 +1,14 @@
+name: p
+version: 0.1.0.0
+license: BSD3
+license-file: LICENSE
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+extra-source-files: ChangeLog.md
+cabal-version: >=1.10
+
+library
+ exposed-modules: P
+ build-depends: base
+ default-language: Haskell2010