diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-10-26 11:58:13 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-12-15 03:54:39 -0500 |
commit | 2eb0fb87b921efc8f107eb39a3d34dae08082a3c (patch) | |
tree | e9ea102c18ae826d28a1b0751d9af175fc9cea0a /testsuite/tests/cabal | |
parent | 9372329008143104b0ae5e8e792e957090dfa743 (diff) | |
download | haskell-2eb0fb87b921efc8f107eb39a3d34dae08082a3c.tar.gz |
Package Imports: Get candidate packages also from re-exported modules
Previously we were just looking at the direct imports to try and work
out what a package qualifier could apply to but #22333 pointed out we
also needed to look for reexported modules.
Fixes #22333
Diffstat (limited to 'testsuite/tests/cabal')
14 files changed, 132 insertions, 0 deletions
diff --git a/testsuite/tests/cabal/t22333/Makefile b/testsuite/tests/cabal/t22333/Makefile new file mode 100644 index 0000000000..da159a46ae --- /dev/null +++ b/testsuite/tests/cabal/t22333/Makefile @@ -0,0 +1,32 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 +CONFIGURE=$(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d --prefix='$(PWD)/../dist' + +T22333: clean + $(MAKE) -s --no-print-directory clean + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + # build b + cd my-package-b; $(CONFIGURE) --cid "my-package-b-0.1" my-package-b + cd my-package-b; $(SETUP) build + cd my-package-b; $(SETUP) copy + cd my-package-b; $(SETUP) register + # build a + cd my-package-a; $(CONFIGURE) --cid "my-package-a-0.1" my-package-a + cd my-package-a; $(SETUP) build + cd my-package-a; $(SETUP) copy + cd my-package-a; $(SETUP) register + # build my-exe + cd my-exe; $(CONFIGURE) --cid "my-exe-0.1" my-exe + cd my-exe; $(SETUP) build + cd my-exe; $(SETUP) copy + cd my-exe; $(SETUP) register +ifneq "$(CLEANUP)" "" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -r tmp.d dist Setup$(exeext) diff --git a/testsuite/tests/cabal/t22333/Setup.hs b/testsuite/tests/cabal/t22333/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/cabal/t22333/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/cabal/t22333/all.T b/testsuite/tests/cabal/t22333/all.T new file mode 100644 index 0000000000..5664400e4a --- /dev/null +++ b/testsuite/tests/cabal/t22333/all.T @@ -0,0 +1,4 @@ +test('T22333', + [extra_files(['Setup.hs', 'my-exe', 'my-package-a', 'my-package-b' ])], + makefile_test, + []) diff --git a/testsuite/tests/cabal/t22333/my-exe/CHANGELOG.md b/testsuite/tests/cabal/t22333/my-exe/CHANGELOG.md new file mode 100644 index 0000000000..0313224bbd --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-exe/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for my-exe + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/testsuite/tests/cabal/t22333/my-exe/app/Main.hs b/testsuite/tests/cabal/t22333/my-exe/app/Main.hs new file mode 100644 index 0000000000..777495202a --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-exe/app/Main.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE PackageImports #-} + +module Main (main) where + +import "my-package-a" LibB (someFuncB) +--import LibB (someFuncB) + +main :: IO () +main = print someFuncB diff --git a/testsuite/tests/cabal/t22333/my-exe/my-exe.cabal b/testsuite/tests/cabal/t22333/my-exe/my-exe.cabal new file mode 100644 index 0000000000..1a1c4c60cb --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-exe/my-exe.cabal @@ -0,0 +1,20 @@ +cabal-version: 3.8 +name: my-exe +version: 0.1.0.0 +license: NONE +author: a.pelenitsyn@gmail.com +maintainer: Artem Pelenitsyn +build-type: Simple +extra-doc-files: CHANGELOG.md + +common warnings + ghc-options: -Wall + +executable my-exe + import: warnings + main-is: Main.hs + build-depends: base + , my-package-a + , my-package-b + hs-source-dirs: app + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/t22333/my-package-a/CHANGELOG.md b/testsuite/tests/cabal/t22333/my-package-a/CHANGELOG.md new file mode 100644 index 0000000000..7507aa3dab --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-a/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for my-package-a + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/testsuite/tests/cabal/t22333/my-package-a/Setup.hs b/testsuite/tests/cabal/t22333/my-package-a/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-a/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/cabal/t22333/my-package-a/my-package-a.cabal b/testsuite/tests/cabal/t22333/my-package-a/my-package-a.cabal new file mode 100644 index 0000000000..bf46792df7 --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-a/my-package-a.cabal @@ -0,0 +1,20 @@ +cabal-version: 3.8 +name: my-package-a +version: 0.1.0.0 +license: NONE +author: a.pelenitsyn@gmail.com +maintainer: Artem Pelenitsyn +build-type: Simple +extra-doc-files: CHANGELOG.md + +common warnings + ghc-options: -Wall + +library + import: warnings + exposed-modules: MyLib + build-depends: base + , my-package-b + reexported-modules: LibB + hs-source-dirs: src + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/t22333/my-package-a/src/MyLib.hs b/testsuite/tests/cabal/t22333/my-package-a/src/MyLib.hs new file mode 100644 index 0000000000..e657c4403f --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-a/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/testsuite/tests/cabal/t22333/my-package-b/CHANGELOG.md b/testsuite/tests/cabal/t22333/my-package-b/CHANGELOG.md new file mode 100644 index 0000000000..b410066be6 --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for my-package-b + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/testsuite/tests/cabal/t22333/my-package-b/Setup.hs b/testsuite/tests/cabal/t22333/my-package-b/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/cabal/t22333/my-package-b/my-package-b.cabal b/testsuite/tests/cabal/t22333/my-package-b/my-package-b.cabal new file mode 100644 index 0000000000..7157b9be93 --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-b/my-package-b.cabal @@ -0,0 +1,18 @@ +cabal-version: 3.8 +name: my-package-b +version: 0.1.0.0 +license: NONE +author: a.pelenitsyn@gmail.com +maintainer: Artem Pelenitsyn +build-type: Simple +extra-doc-files: CHANGELOG.md + +common warnings + ghc-options: -Wall + +library + import: warnings + exposed-modules: LibB + build-depends: base + hs-source-dirs: src + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/t22333/my-package-b/src/LibB.hs b/testsuite/tests/cabal/t22333/my-package-b/src/LibB.hs new file mode 100644 index 0000000000..8e85cdcea3 --- /dev/null +++ b/testsuite/tests/cabal/t22333/my-package-b/src/LibB.hs @@ -0,0 +1,4 @@ +module LibB (someFuncB) where + +someFuncB :: Int +someFuncB = 42 |