diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-11-17 22:30:35 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-11-26 16:51:30 -0800 |
commit | b19845db926632c4be7b1e52fe2aa01d26ac3af3 (patch) | |
tree | 1cc3eee96471998fbd98ad7ac3fd55a6f0f6017c | |
parent | 4897e7056e7b34c42ba5c0b1fa28ea547b8085b3 (diff) | |
download | haskell-b19845db926632c4be7b1e52fe2aa01d26ac3af3.tar.gz |
Cabal submodule update: hole support and tests.
Depends on D485
Summary: Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin
Subscribers: thomie, carter
Differential Revision: https://phabricator.haskell.org/D487
25 files changed, 180 insertions, 6 deletions
@@ -47,7 +47,7 @@ "makefiles": { "type": "text", "include": [ "(Makefile$)", "(\\.mk$)" ], - "text.max-line-length": 200, + "text.max-line-length": 400, "severity": { "2": "disabled" } diff --git a/libraries/Cabal b/libraries/Cabal -Subproject f54e7f95412c2ee9ee76ce9517b7d8aa769bdcf +Subproject 6c395bb8f22961ce5267df64e6d9351c310fcbb diff --git a/libraries/bin-package-db/GHC/PackageDb.hs b/libraries/bin-package-db/GHC/PackageDb.hs index e1715e69e5..870abd45ec 100644 --- a/libraries/bin-package-db/GHC/PackageDb.hs +++ b/libraries/bin-package-db/GHC/PackageDb.hs @@ -89,6 +89,7 @@ data InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename haddockHTMLs :: [FilePath], exposedModules :: [ExposedModule instpkgid modulename], hiddenModules :: [modulename], + instantiatedWith :: [(modulename,OriginalModule instpkgid modulename)], exposed :: Bool, trusted :: Bool } @@ -165,6 +166,7 @@ emptyInstalledPackageInfo = haddockHTMLs = [], exposedModules = [], hiddenModules = [], + instantiatedWith = [], exposed = False, trusted = False } @@ -320,7 +322,7 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, ldOptions ccOptions includes includeDirs haddockInterfaces haddockHTMLs - exposedModules hiddenModules + exposedModules hiddenModules instantiatedWith exposed trusted) = do put (toStringRep installedPackageId) put (toStringRep sourcePackageId) @@ -343,6 +345,7 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, put haddockHTMLs put exposedModules put (map toStringRep hiddenModules) + put (map (\(k,v) -> (toStringRep k, v)) instantiatedWith) put exposed put trusted @@ -368,6 +371,7 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, haddockHTMLs <- get exposedModules <- get hiddenModules <- get + instantiatedWith <- get exposed <- get trusted <- get return (InstalledPackageInfo @@ -384,6 +388,7 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, haddockInterfaces haddockHTMLs exposedModules (map fromStringRep hiddenModules) + (map (\(k,v) -> (fromStringRep k, v)) instantiatedWith) exposed trusted) instance Binary Version where diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 705306c3ef..8ebe1531ba 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -114,6 +114,12 @@ mk/ghcconfig*_inplace_bin_ghc-stage2.exe.mk /tests/cabal/cabal05/r-0.1.0.0/ /tests/cabal/cabal06/inst-*/ /tests/cabal/cabal06/tmp* +/tests/cabal/sigcabal01/Main +/tests/cabal/sigcabal01/tmp* +/tests/cabal/sigcabal01/inst-* +/tests/cabal/sigcabal01/p_lazy +/tests/cabal/sigcabal01/p_strict +/tests/cabal/sigcabal01/containers /tests/cabal/local01.package.conf/ /tests/cabal/local03.package.conf/ /tests/cabal/local04.package.conf/ diff --git a/testsuite/tests/cabal/Makefile b/testsuite/tests/cabal/Makefile index 1e4cd6970d..47cd95d010 100644 --- a/testsuite/tests/cabal/Makefile +++ b/testsuite/tests/cabal/Makefile @@ -243,9 +243,9 @@ ghcpkg07: @rm -rf $(PKGCONF07) $(LOCAL_GHC_PKG07) init $(PKGCONF07) $(LOCAL_GHC_PKG07) register --force test.pkg 2>/dev/null - $(LOCAL_GHC_PKG07) register --force test7a.pkg 2>/dev/null + $(LOCAL_GHC_PKG07) register --force test7a.pkg 2>&1 | grep "module" || : $(LOCAL_GHC_PKG07) field testpkg7a exposed-modules - $(LOCAL_GHC_PKG07) register --force test7b.pkg 2>/dev/null + $(LOCAL_GHC_PKG07) register --force test7b.pkg 2>&1 | grep "module" || : $(LOCAL_GHC_PKG07) field testpkg7b exposed-modules recache_reexport: diff --git a/testsuite/tests/cabal/cabal07/Makefile b/testsuite/tests/cabal/cabal07/Makefile new file mode 100644 index 0000000000..1dfed8aad1 --- /dev/null +++ b/testsuite/tests/cabal/cabal07/Makefile @@ -0,0 +1,21 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +# This test is for a Cabal package with thinning and renaming + +cabal07: clean + $(MAKE) clean + '$(TEST_HC)' -v0 --make Setup + cd p && $(SETUP) clean + cd p && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --prefix='$(PWD)/inst-p' --constraint="containers>=0" + cd p && ! $(SETUP) build +ifneq "$(CLEANUP)" "" + $(MAKE) clean +endif + +clean : + '$(GHC_PKG)' unregister --force p >/dev/null 2>&1 || true + $(RM) -r tmp.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) diff --git a/testsuite/tests/cabal/cabal07/Setup.hs b/testsuite/tests/cabal/cabal07/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/cabal/cabal07/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/cabal/cabal07/all.T b/testsuite/tests/cabal/cabal07/all.T new file mode 100644 index 0000000000..b2d26809d3 --- /dev/null +++ b/testsuite/tests/cabal/cabal07/all.T @@ -0,0 +1,12 @@ +if default_testopts.cleanup != '': + cleanup = 'CLEANUP=1' +else: + cleanup = '' + +def normaliseContainersPackage(str): + return re.sub('containers-[^@]+@conta_[A-Za-z0-9]+', 'containers-<VERSION>@conta_<HASH>', str) + +test('cabal07', + normalise_errmsg_fun(normaliseContainersPackage), + run_command, + ['$MAKE -s --no-print-directory cabal07 ' + cleanup]) diff --git a/testsuite/tests/cabal/cabal07/cabal07.stderr b/testsuite/tests/cabal/cabal07/cabal07.stderr new file mode 100644 index 0000000000..ded86e1e21 --- /dev/null +++ b/testsuite/tests/cabal/cabal07/cabal07.stderr @@ -0,0 +1,6 @@ + +Q.hs:3:8: + Could not find module ‘Data.Set’ + It is a member of the hidden package ‘containers-<VERSION>@conta_<HASH>’. + Perhaps you need to add ‘containers’ to the build-depends in your .cabal file. + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/cabal/cabal07/p/LICENSE b/testsuite/tests/cabal/cabal07/p/LICENSE new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/cabal/cabal07/p/LICENSE diff --git a/testsuite/tests/cabal/cabal07/p/P.hs b/testsuite/tests/cabal/cabal07/p/P.hs new file mode 100644 index 0000000000..c9458ddae3 --- /dev/null +++ b/testsuite/tests/cabal/cabal07/p/P.hs @@ -0,0 +1,5 @@ +module P where +import qualified Set +import qualified Seq +import qualified Seq2 +import qualified Control.DeepSeq diff --git a/testsuite/tests/cabal/cabal07/p/Q.hs b/testsuite/tests/cabal/cabal07/p/Q.hs new file mode 100644 index 0000000000..488793979f --- /dev/null +++ b/testsuite/tests/cabal/cabal07/p/Q.hs @@ -0,0 +1,3 @@ +module Q where +import P +import Data.Set diff --git a/testsuite/tests/cabal/cabal07/p/p.cabal b/testsuite/tests/cabal/cabal07/p/p.cabal new file mode 100644 index 0000000000..2699e93d5a --- /dev/null +++ b/testsuite/tests/cabal/cabal07/p/p.cabal @@ -0,0 +1,12 @@ +name: p +version: 1.0 +license-file: LICENSE +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: >=1.20 + +library + exposed-modules: P, Q + build-depends: base, containers >= 0.1 (Data.Set as Set), deepseq (> 0.2 && > 0.1) with (Control.DeepSeq as Seq, Control.DeepSeq as Seq2) + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/ghcpkg07.stdout b/testsuite/tests/cabal/ghcpkg07.stdout index 717a9971a1..627b381e8f 100644 --- a/testsuite/tests/cabal/ghcpkg07.stdout +++ b/testsuite/tests/cabal/ghcpkg07.stdout @@ -1,9 +1,10 @@ Reading package info from "test.pkg" ... done. -Reading package info from "test7a.pkg" ... done. exposed-modules: E, A from testpkg-1.2.3.4-XXX:A, A1 from testpkg-1.2.3.4-XXX:A, E2 from testpkg7a-1.0-XXX:E -Reading package info from "test7b.pkg" ... done. +testpkg7b-1.0: module reexport refers to a module A that is reexported but not defined in the defining package testpkg7a-1.0-XXX (ignoring) +testpkg7b-1.0: module reexport refers to a module A1 that is reexported but not defined in the defining package testpkg7a-1.0-XXX (ignoring) +testpkg7b-1.0: module reexport refers to a module E2 that is reexported but not defined in the defining package testpkg7a-1.0-XXX (ignoring) exposed-modules: F1 from testpkg-1.2.3.4-XXX:A, F2 from testpkg7a-1.0-XXX:A, F3 from testpkg7a-1.0-XXX:A1, F4 from testpkg7a-1.0-XXX:E, diff --git a/testsuite/tests/cabal/sigcabal01/Main.hs b/testsuite/tests/cabal/sigcabal01/Main.hs new file mode 100644 index 0000000000..537b5c9443 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/Main.hs @@ -0,0 +1,3 @@ +import qualified P.Lazy +import qualified P.Strict +main = P.Lazy.foo >> P.Strict.foo diff --git a/testsuite/tests/cabal/sigcabal01/Makefile b/testsuite/tests/cabal/sigcabal01/Makefile new file mode 100644 index 0000000000..c284842bdd --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/Makefile @@ -0,0 +1,33 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +# This test is for a Cabal package with holes + +sigcabal01: + $(MAKE) clean + '$(GHC_PKG)' field containers id | sed 's/^.*: *//' > containers + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' -v0 --make Setup + 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)/inst-p' --ghc-pkg-options="--enable-multi-instance" + cd p && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d --prefix='$(PWD)/inst-p' --instantiate-with="Map=Data.Map.Lazy@`cat ../containers`" --ghc-pkg-options="--enable-multi-instance" + cd p && $(SETUP) build + cd p && $(SETUP) copy + cd p && $(SETUP) register --print-ipid > ../p_lazy + 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)/inst-p' --instantiate-with="Map=Data.Map.Strict@`cat ../containers`" --ghc-pkg-options="--enable-multi-instance" + cd p && $(SETUP) build + cd p && $(SETUP) copy + cd p && $(SETUP) register --print-ipid > ../p_strict + '$(TEST_HC)' $(TEST_HC_OPTS) -package-db=tmp.d -hide-all-packages -package base -package-id "`cat p_lazy` (P as P.Lazy)" -package-id "`cat p_strict` (P as P.Strict)" --make Main.hs + ! ./Main +ifneq "$(CLEANUP)" "" + $(MAKE) clean +endif + +clean : + '$(GHC_PKG)' unregister --force p >/dev/null 2>&1 || true + $(RM) -r tmp.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) diff --git a/testsuite/tests/cabal/sigcabal01/Setup.hs b/testsuite/tests/cabal/sigcabal01/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/cabal/sigcabal01/all.T b/testsuite/tests/cabal/sigcabal01/all.T new file mode 100644 index 0000000000..a797c0890d --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/all.T @@ -0,0 +1,9 @@ +if default_testopts.cleanup != '': + cleanup = 'CLEANUP=1' +else: + cleanup = '' + +test('sigcabal01', + normal, + run_command, + ['$MAKE -s --no-print-directory sigcabal01 ' + cleanup]) diff --git a/testsuite/tests/cabal/sigcabal01/p/LICENSE b/testsuite/tests/cabal/sigcabal01/p/LICENSE new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/p/LICENSE diff --git a/testsuite/tests/cabal/sigcabal01/p/Map.hsig b/testsuite/tests/cabal/sigcabal01/p/Map.hsig new file mode 100644 index 0000000000..5c00a194de --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/p/Map.hsig @@ -0,0 +1,19 @@ +{-# LANGUAGE RoleAnnotations #-} +module Map where + +type role Map nominal representational +data Map k a + +instance (Show k, Show a) => Show (Map k a) + +null :: Map k a -> Bool +size :: Map k a -> Int +member :: Ord k => k -> Map k a -> Bool +lookup :: Ord k => k -> Map k a -> Maybe a +empty :: Map k a +singleton :: k -> a -> Map k a +insert :: Ord k => k -> a -> Map k a -> Map k a +delete :: Ord k => k -> Map k a -> Map k a + +toList :: Map k a -> [(k, a)] +fromList :: Ord k => [(k, a)] -> Map k a diff --git a/testsuite/tests/cabal/sigcabal01/p/P.hs b/testsuite/tests/cabal/sigcabal01/p/P.hs new file mode 100644 index 0000000000..64fe354899 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/p/P.hs @@ -0,0 +1,13 @@ +module P where + +import Map + +foo = do + let x = insert 0 "foo" + . delete 1 + . insert 1 undefined + . insert (6 :: Int) "foo" + $ empty + print (member 1 x) + print (toList x) + print x diff --git a/testsuite/tests/cabal/sigcabal01/p/p.cabal b/testsuite/tests/cabal/sigcabal01/p/p.cabal new file mode 100644 index 0000000000..a3d3312c61 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/p/p.cabal @@ -0,0 +1,13 @@ +name: p +version: 1.0 +license-file: LICENSE +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: >=1.20 + +library + exposed-modules: P + required-signatures: Map + build-depends: base + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/sigcabal01/sigcabal01.stderr b/testsuite/tests/cabal/sigcabal01/sigcabal01.stderr new file mode 100644 index 0000000000..7d391ad02f --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/sigcabal01.stderr @@ -0,0 +1,2 @@ +Setup: Missing signature implementations for these modules: Map +Main: Prelude.undefined diff --git a/testsuite/tests/cabal/sigcabal01/sigcabal01.stdout b/testsuite/tests/cabal/sigcabal01/sigcabal01.stdout new file mode 100644 index 0000000000..159c6576c9 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal01/sigcabal01.stdout @@ -0,0 +1,5 @@ +[1 of 1] Compiling Main ( Main.hs, Main.o ) +Linking Main ... +False +[(0,"foo"),(6,"foo")] +fromList [(0,"foo"),(6,"foo")] diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index 2b0b4ccf66..0493866e32 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -1023,6 +1023,7 @@ convertPackageInfoToCacheFormat pkg = GhcPkg.haddockHTMLs = haddockHTMLs pkg, GhcPkg.exposedModules = map convertExposed (exposedModules pkg), GhcPkg.hiddenModules = hiddenModules pkg, + GhcPkg.instantiatedWith = map convertInst (instantiatedWith pkg), GhcPkg.exposed = exposed pkg, GhcPkg.trusted = trusted pkg } @@ -1031,6 +1032,7 @@ convertPackageInfoToCacheFormat pkg = (fmap convertOriginal sig) convertOriginal (OriginalModule ipid m) = GhcPkg.OriginalModule (display ipid) m + convertInst (m, o) = (m, convertOriginal o) instance GhcPkg.BinaryStringRep ModuleName where fromStringRep = ModuleName.fromString . fromUTF8 . BS.unpack |