summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-07-06 12:08:08 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2021-07-06 12:13:16 +0100
commitc82f840c4b66dbefef4df60229449e7139065af5 (patch)
tree7fbf53b96eb03262f1b4d392b81c239d53ffdde1 /testsuite
parent9b1d9cbfa7a1beecc4125e35562f542b30ee4f2e (diff)
downloadhaskell-wip/unused-packages-reexport.tar.gz
driver: Fix interaction of -Wunused-packages and reexported-moduleswip/unused-packages-reexport
Spurious warnings were previously emitted if an import came from a reexport due to how -Wunused-packages were implemented. Removing the dependency would cause compilation to fail. The fix is to reimplement the warning a bit more directly, by searching for which package each import comes from using the normal module finding functions rather than consulting the EPS. This has the advantage that the check could be performed at any time after downsweep rather than also relying on a populated EPS. Fixes #19518 and #19777
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/cabal/t19518/Makefile44
-rw-r--r--testsuite/tests/cabal/t19518/Setup.hs2
-rw-r--r--testsuite/tests/cabal/t19518/all.T9
-rw-r--r--testsuite/tests/cabal/t19518/p/LICENSE0
-rw-r--r--testsuite/tests/cabal/t19518/p/P.hs3
-rw-r--r--testsuite/tests/cabal/t19518/p/P2.hs1
-rw-r--r--testsuite/tests/cabal/t19518/p/Setup.hs2
-rw-r--r--testsuite/tests/cabal/t19518/p/p.cabal11
-rw-r--r--testsuite/tests/cabal/t19518/q/LICENSE0
-rw-r--r--testsuite/tests/cabal/t19518/q/Q.hs4
-rw-r--r--testsuite/tests/cabal/t19518/q/Setup.hs2
-rw-r--r--testsuite/tests/cabal/t19518/q/q.cabal12
-rw-r--r--testsuite/tests/cabal/t19518/r/LICENSE0
-rw-r--r--testsuite/tests/cabal/t19518/r/R.hs3
-rw-r--r--testsuite/tests/cabal/t19518/r/Setup.hs2
-rw-r--r--testsuite/tests/cabal/t19518/r/r.cabal11
16 files changed, 106 insertions, 0 deletions
diff --git a/testsuite/tests/cabal/t19518/Makefile b/testsuite/tests/cabal/t19518/Makefile
new file mode 100644
index 0000000000..e5a282e13f
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/Makefile
@@ -0,0 +1,44 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+SETUP = ../Setup -v0
+
+# This test is for package reexports and -Wunused-packages working together
+# 1. install p
+# 2. install q (reexporting p modules)
+# 3. install r (using reexports from q)
+#
+# When building r, it should not suggest the import of q package is redundant
+
+t19518: clean
+ $(MAKE) -s --no-print-directory clean
+ '$(GHC_PKG)' init tmp.d
+ '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup
+ # build p
+ cd p && $(SETUP) clean
+ cd p && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d --prefix='$(PWD)/$$pkgid'
+ cd p && $(SETUP) build
+ cd p && $(SETUP) copy
+ cd p && $(SETUP) register
+ # build q
+ cd q && $(SETUP) clean
+ cd q && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d --prefix='$(PWD)/$$pkgid'
+ cd q && $(SETUP) build
+ cd q && $(SETUP) copy
+ cd q && $(SETUP) register
+ # build r
+ cd r && $(SETUP) clean
+ cd r && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS) -Wunused-packages' --package-db=../tmp.d --prefix='$(PWD)/$$pkgid'
+ cd r && $(SETUP) build
+ cd r && $(SETUP) copy
+ cd r && $(SETUP) register
+ifneq "$(CLEANUP)" ""
+ $(MAKE) -s --no-print-directory clean
+endif
+
+clean :
+ '$(GHC_PKG)' unregister --force p >/dev/null 2>&1 || true
+ '$(GHC_PKG)' unregister --force q >/dev/null 2>&1 || true
+ '$(GHC_PKG)' unregister --force r >/dev/null 2>&1 || true
+ $(RM) -r p-* q-* r-* s-* t-* tmp.d *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext)
diff --git a/testsuite/tests/cabal/t19518/Setup.hs b/testsuite/tests/cabal/t19518/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/t19518/all.T b/testsuite/tests/cabal/t19518/all.T
new file mode 100644
index 0000000000..a2cd241a70
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/all.T
@@ -0,0 +1,9 @@
+if config.cleanup:
+ cleanup = 'CLEANUP=1'
+else:
+ cleanup = 'CLEANUP=0'
+
+test('t19518',
+ extra_files(['Setup.hs', 'p/', 'q/', 'r/']),
+ run_command,
+ ['$MAKE -s --no-print-directory t19518 ' + cleanup])
diff --git a/testsuite/tests/cabal/t19518/p/LICENSE b/testsuite/tests/cabal/t19518/p/LICENSE
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/p/LICENSE
diff --git a/testsuite/tests/cabal/t19518/p/P.hs b/testsuite/tests/cabal/t19518/p/P.hs
new file mode 100644
index 0000000000..f8b82de2ca
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/p/P.hs
@@ -0,0 +1,3 @@
+module P where
+data P = P
+p = True
diff --git a/testsuite/tests/cabal/t19518/p/P2.hs b/testsuite/tests/cabal/t19518/p/P2.hs
new file mode 100644
index 0000000000..769760dff8
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/p/P2.hs
@@ -0,0 +1 @@
+module P2 where
diff --git a/testsuite/tests/cabal/t19518/p/Setup.hs b/testsuite/tests/cabal/t19518/p/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/p/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/t19518/p/p.cabal b/testsuite/tests/cabal/t19518/p/p.cabal
new file mode 100644
index 0000000000..989156c5be
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/p/p.cabal
@@ -0,0 +1,11 @@
+name: p
+version: 0.1.0.0
+license-file: LICENSE
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+cabal-version: >=1.21
+
+library
+ exposed-modules: P, P2
+ build-depends: base
diff --git a/testsuite/tests/cabal/t19518/q/LICENSE b/testsuite/tests/cabal/t19518/q/LICENSE
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/q/LICENSE
diff --git a/testsuite/tests/cabal/t19518/q/Q.hs b/testsuite/tests/cabal/t19518/q/Q.hs
new file mode 100644
index 0000000000..721b231aa1
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/q/Q.hs
@@ -0,0 +1,4 @@
+module Q where
+import P
+data Q = Q
+q = not p
diff --git a/testsuite/tests/cabal/t19518/q/Setup.hs b/testsuite/tests/cabal/t19518/q/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/q/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/t19518/q/q.cabal b/testsuite/tests/cabal/t19518/q/q.cabal
new file mode 100644
index 0000000000..c455f6ad44
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/q/q.cabal
@@ -0,0 +1,12 @@
+name: q
+version: 0.1.0.0
+license-file: LICENSE
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+cabal-version: >=1.21
+
+library
+ exposed-modules: Q
+ reexported-modules: P
+ build-depends: base, p
diff --git a/testsuite/tests/cabal/t19518/r/LICENSE b/testsuite/tests/cabal/t19518/r/LICENSE
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/r/LICENSE
diff --git a/testsuite/tests/cabal/t19518/r/R.hs b/testsuite/tests/cabal/t19518/r/R.hs
new file mode 100644
index 0000000000..ac9344a524
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/r/R.hs
@@ -0,0 +1,3 @@
+module R where
+import P
+r = p
diff --git a/testsuite/tests/cabal/t19518/r/Setup.hs b/testsuite/tests/cabal/t19518/r/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/r/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/cabal/t19518/r/r.cabal b/testsuite/tests/cabal/t19518/r/r.cabal
new file mode 100644
index 0000000000..f39aa659f7
--- /dev/null
+++ b/testsuite/tests/cabal/t19518/r/r.cabal
@@ -0,0 +1,11 @@
+name: r
+version: 0.1.0.0
+license-file: LICENSE
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+cabal-version: >=1.21
+
+library
+ exposed-modules: R
+ build-depends: base, q