diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-07-06 12:08:08 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-13 15:16:19 -0400 |
commit | aef7d51350feebfb29a011361d03b249049a2a0b (patch) | |
tree | 3eb11cf34b63bedb0323bee82da49590b00a5a45 /testsuite/tests/cabal | |
parent | a181313e9205fe289bedf6c8931eb2933490625c (diff) | |
download | haskell-aef7d51350feebfb29a011361d03b249049a2a0b.tar.gz |
driver: Fix interaction of -Wunused-packages and reexported-modules
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/tests/cabal')
-rw-r--r-- | testsuite/tests/cabal/t19518/Makefile | 44 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/Setup.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/all.T | 9 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/p/LICENSE | 0 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/p/P.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/p/P2.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/p/Setup.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/p/p.cabal | 11 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/q/LICENSE | 0 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/q/Q.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/q/Setup.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/q/q.cabal | 12 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/r/LICENSE | 0 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/r/R.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/r/Setup.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/t19518/r/r.cabal | 11 |
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 |