summaryrefslogtreecommitdiff
path: root/testsuite/tests/driver
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-12-06 11:44:18 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-09 04:27:11 -0500
commit803eefb1109564f4dbabd80721cd45ce7268c4a2 (patch)
treecc7bcc8ece06758953dbae423ed9553b1f0ab156 /testsuite/tests/driver
parentaafa5079bd49a55f5c71664ddb95ffcb9d8ca102 (diff)
downloadhaskell-803eefb1109564f4dbabd80721cd45ce7268c4a2.tar.gz
package imports: Take into account package visibility when renaming
In 806e49ae the package imports refactoring code was modified to rename package imports. There was a small oversight which meant the code didn't account for module visibility. This patch fixes that oversight. In general the "lookupPackageName" function is unsafe to use as it doesn't account for package visiblity/thinning/renaming etc, there is just one use in the compiler which would be good to audit. Fixes #20779
Diffstat (limited to 'testsuite/tests/driver')
-rw-r--r--testsuite/tests/driver/package-imports-t20779/Makefile33
-rw-r--r--testsuite/tests/driver/package-imports-t20779/Setup.hs2
-rw-r--r--testsuite/tests/driver/package-imports-t20779/all.T4
-rw-r--r--testsuite/tests/driver/package-imports-t20779/p/LICENSE1
-rw-r--r--testsuite/tests/driver/package-imports-t20779/p/PLib.hs5
-rw-r--r--testsuite/tests/driver/package-imports-t20779/p/p.cabal25
-rw-r--r--testsuite/tests/driver/package-imports-t20779/q-1/LICENSE1
-rw-r--r--testsuite/tests/driver/package-imports-t20779/q-1/QLib.hs3
-rw-r--r--testsuite/tests/driver/package-imports-t20779/q-1/q.cabal25
-rw-r--r--testsuite/tests/driver/package-imports-t20779/q-2/LICENSE1
-rw-r--r--testsuite/tests/driver/package-imports-t20779/q-2/QLib.hs3
-rw-r--r--testsuite/tests/driver/package-imports-t20779/q-2/q.cabal25
12 files changed, 128 insertions, 0 deletions
diff --git a/testsuite/tests/driver/package-imports-t20779/Makefile b/testsuite/tests/driver/package-imports-t20779/Makefile
new file mode 100644
index 0000000000..451a1a8739
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/Makefile
@@ -0,0 +1,33 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+SETUP='$(PWD)/Setup' -v0
+CONFIGURE=$(SETUP) configure --with-ghc='$(TEST_HC)' --ghc-options='$(filter-out -rtsopts,$(TEST_HC_OPTS))' --package-db='$(PWD)/tmp.d' --prefix='$(PWD)/inst'
+
+package-imports-20779:
+ '$(GHC_PKG)' init tmp.d
+ '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup
+ # build q1
+ rm -rf q-1/dist
+ (cd q-1; $(CONFIGURE) --ipid "q-1")
+ (cd q-1; $(SETUP) build)
+ (cd q-1; $(SETUP) copy)
+ (cd q-1; $(SETUP) register)
+
+ # build q2
+ rm -rf q-2/dist
+ (cd q-2; $(CONFIGURE) --ipid "q-2")
+ (cd q-2; $(SETUP) build)
+ (cd q-2; $(SETUP) copy)
+ (cd q-2; $(SETUP) register)
+
+ # build p
+ rm -rf p/dist
+ (cd p; $(CONFIGURE) --ipid "p-1")
+ (cd p; $(SETUP) build)
+ (cd p; $(SETUP) copy)
+ (cd p; $(SETUP) register)
+
+
+
diff --git a/testsuite/tests/driver/package-imports-t20779/Setup.hs b/testsuite/tests/driver/package-imports-t20779/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/driver/package-imports-t20779/all.T b/testsuite/tests/driver/package-imports-t20779/all.T
new file mode 100644
index 0000000000..2d7fb3f8ea
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/all.T
@@ -0,0 +1,4 @@
+test('package-imports-20779', [extra_files(['q-1', 'q-2', 'p', 'Setup.hs']),
+ when(fast(), skip)],
+ makefile_test,
+ [])
diff --git a/testsuite/tests/driver/package-imports-t20779/p/LICENSE b/testsuite/tests/driver/package-imports-t20779/p/LICENSE
new file mode 100644
index 0000000000..bca70f3531
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/p/LICENSE
@@ -0,0 +1 @@
+q
diff --git a/testsuite/tests/driver/package-imports-t20779/p/PLib.hs b/testsuite/tests/driver/package-imports-t20779/p/PLib.hs
new file mode 100644
index 0000000000..a4b1f46b94
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/p/PLib.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE PackageImports #-}
+module PLib where
+
+import "q" QLib
+
diff --git a/testsuite/tests/driver/package-imports-t20779/p/p.cabal b/testsuite/tests/driver/package-imports-t20779/p/p.cabal
new file mode 100644
index 0000000000..b9d25f155c
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/p/p.cabal
@@ -0,0 +1,25 @@
+cabal-version: >=1.10
+-- Initial package description 'q.cabal' generated by 'cabal init'. For
+-- further documentation, see http://haskell.org/cabal/users-guide/
+
+name: p
+version: 1
+-- synopsis:
+-- description:
+-- bug-reports:
+-- license:
+license-file: LICENSE
+author: Matthew Pickering
+maintainer: matthewtpickering@gmail.com
+-- copyright:
+-- category:
+build-type: Simple
+extra-source-files: CHANGELOG.md
+
+library
+ exposed-modules: PLib
+ -- other-modules:
+ -- other-extensions:
+ build-depends: base >=4 && <5, q == 1
+ -- hs-source-dirs:
+ default-language: Haskell2010
diff --git a/testsuite/tests/driver/package-imports-t20779/q-1/LICENSE b/testsuite/tests/driver/package-imports-t20779/q-1/LICENSE
new file mode 100644
index 0000000000..bca70f3531
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/q-1/LICENSE
@@ -0,0 +1 @@
+q
diff --git a/testsuite/tests/driver/package-imports-t20779/q-1/QLib.hs b/testsuite/tests/driver/package-imports-t20779/q-1/QLib.hs
new file mode 100644
index 0000000000..b98aa33300
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/q-1/QLib.hs
@@ -0,0 +1,3 @@
+module QLib where
+
+q = 'q'
diff --git a/testsuite/tests/driver/package-imports-t20779/q-1/q.cabal b/testsuite/tests/driver/package-imports-t20779/q-1/q.cabal
new file mode 100644
index 0000000000..b7c6dc56ef
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/q-1/q.cabal
@@ -0,0 +1,25 @@
+cabal-version: >=1.10
+-- Initial package description 'q.cabal' generated by 'cabal init'. For
+-- further documentation, see http://haskell.org/cabal/users-guide/
+
+name: q
+version: 1
+-- synopsis:
+-- description:
+-- bug-reports:
+-- license:
+license-file: LICENSE
+author: Matthew Pickering
+maintainer: matthewtpickering@gmail.com
+-- copyright:
+-- category:
+build-type: Simple
+extra-source-files: CHANGELOG.md
+
+library
+ exposed-modules: QLib
+ -- other-modules:
+ -- other-extensions:
+ build-depends: base >=4 && <5
+ -- hs-source-dirs:
+ default-language: Haskell2010
diff --git a/testsuite/tests/driver/package-imports-t20779/q-2/LICENSE b/testsuite/tests/driver/package-imports-t20779/q-2/LICENSE
new file mode 100644
index 0000000000..bca70f3531
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/q-2/LICENSE
@@ -0,0 +1 @@
+q
diff --git a/testsuite/tests/driver/package-imports-t20779/q-2/QLib.hs b/testsuite/tests/driver/package-imports-t20779/q-2/QLib.hs
new file mode 100644
index 0000000000..b98aa33300
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/q-2/QLib.hs
@@ -0,0 +1,3 @@
+module QLib where
+
+q = 'q'
diff --git a/testsuite/tests/driver/package-imports-t20779/q-2/q.cabal b/testsuite/tests/driver/package-imports-t20779/q-2/q.cabal
new file mode 100644
index 0000000000..4f64e1ae2e
--- /dev/null
+++ b/testsuite/tests/driver/package-imports-t20779/q-2/q.cabal
@@ -0,0 +1,25 @@
+cabal-version: >=1.10
+-- Initial package description 'q.cabal' generated by 'cabal init'. For
+-- further documentation, see http://haskell.org/cabal/users-guide/
+
+name: q
+version: 2
+-- synopsis:
+-- description:
+-- bug-reports:
+-- license:
+license-file: LICENSE
+author: Matthew Pickering
+maintainer: matthewtpickering@gmail.com
+-- copyright:
+-- category:
+build-type: Simple
+extra-source-files: CHANGELOG.md
+
+library
+ exposed-modules: QLib
+ -- other-modules:
+ -- other-extensions:
+ build-depends: base >=4 && <5
+ -- hs-source-dirs:
+ default-language: Haskell2010