Cabal submodule update: hole support and tests.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Tue, 18 Nov 2014 06:30:35 +0000 (22:30 -0800)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Thu, 27 Nov 2014 00:51:30 +0000 (16:51 -0800)
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:
.arclint
libraries/Cabal
libraries/bin-package-db/GHC/PackageDb.hs
testsuite/.gitignore
testsuite/tests/cabal/Makefile
testsuite/tests/cabal/cabal07/Makefile [new file with mode: 0644]
testsuite/tests/cabal/cabal07/Setup.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal07/all.T [new file with mode: 0644]
testsuite/tests/cabal/cabal07/cabal07.stderr [new file with mode: 0644]
testsuite/tests/cabal/cabal07/p/LICENSE [new file with mode: 0644]
testsuite/tests/cabal/cabal07/p/P.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal07/p/Q.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal07/p/p.cabal [new file with mode: 0644]
testsuite/tests/cabal/ghcpkg07.stdout
testsuite/tests/cabal/sigcabal01/Main.hs [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/Makefile [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/Setup.hs [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/all.T [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/p/LICENSE [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/p/Map.hsig [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/p/P.hs [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/p/p.cabal [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/sigcabal01.stderr [new file with mode: 0644]
testsuite/tests/cabal/sigcabal01/sigcabal01.stdout [new file with mode: 0644]
utils/ghc-pkg/Main.hs

index 1310973..5642c63 100644 (file)
--- a/.arclint
+++ b/.arclint
@@ -47,7 +47,7 @@
     "makefiles": {
       "type": "text",
       "include": [ "(Makefile$)", "(\\.mk$)" ],
-      "text.max-line-length": 200,
+      "text.max-line-length": 400,
       "severity": {
         "2": "disabled"
       }
index f54e7f9..6c395bb 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f54e7f95412c2ee9ee76ce9517b7d8aa769bdcfa
+Subproject commit 6c395bb8f22961ce5267df64e6d9351c310fcbb3
index e1715e6..870abd4 100644 (file)
@@ -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
index 705306c..8ebe153 100644 (file)
@@ -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/
index 1e4cd69..47cd95d 100644 (file)
@@ -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 (file)
index 0000000..1dfed8a
--- /dev/null
@@ -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 (file)
index 0000000..9a994af
--- /dev/null
@@ -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 (file)
index 0000000..b2d2680
--- /dev/null
@@ -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 (file)
index 0000000..ded86e1
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/testsuite/tests/cabal/cabal07/p/P.hs b/testsuite/tests/cabal/cabal07/p/P.hs
new file mode 100644 (file)
index 0000000..c9458dd
--- /dev/null
@@ -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 (file)
index 0000000..4887939
--- /dev/null
@@ -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 (file)
index 0000000..2699e93
--- /dev/null
@@ -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
index 717a997..627b381 100644 (file)
@@ -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 (file)
index 0000000..537b5c9
--- /dev/null
@@ -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 (file)
index 0000000..c284842
--- /dev/null
@@ -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 (file)
index 0000000..9a994af
--- /dev/null
@@ -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 (file)
index 0000000..a797c08
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/testsuite/tests/cabal/sigcabal01/p/Map.hsig b/testsuite/tests/cabal/sigcabal01/p/Map.hsig
new file mode 100644 (file)
index 0000000..5c00a19
--- /dev/null
@@ -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 (file)
index 0000000..64fe354
--- /dev/null
@@ -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 (file)
index 0000000..a3d3312
--- /dev/null
@@ -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 (file)
index 0000000..7d391ad
--- /dev/null
@@ -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 (file)
index 0000000..159c657
--- /dev/null
@@ -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")]
index 2b0b4cc..0493866 100644 (file)
@@ -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