Commit b19845db authored by Edward Z. Yang's avatar Edward Z. Yang

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
parent 4897e705
......@@ -47,7 +47,7 @@
"makefiles": {
"type": "text",
"include": [ "(Makefile$)", "(\\.mk$)" ],
"text.max-line-length": 200,
"text.max-line-length": 400,
"severity": {
"2": "disabled"
}
......
Subproject commit f54e7f95412c2ee9ee76ce9517b7d8aa769bdcfa
Subproject commit 6c395bb8f22961ce5267df64e6d9351c310fcbb3
......@@ -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
......
......@@ -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/
......
......@@ -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:
......
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)
import Distribution.Simple
main = defaultMain
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])
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.
module P where
import qualified Set
import qualified Seq
import qualified Seq2
import qualified Control.DeepSeq
module Q where
import P
import Data.Set
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
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,
......
import qualified P.Lazy
import qualified P.Strict
main = P.Lazy.foo >> P.Strict.foo
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)
import Distribution.Simple
main = defaultMain
if default_testopts.cleanup != '':
cleanup = 'CLEANUP=1'
else:
cleanup = ''
test('sigcabal01',
normal,
run_command,
['$MAKE -s --no-print-directory sigcabal01 ' + cleanup])
{-# 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
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
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
Setup: Missing signature implementations for these modules: Map
Main: Prelude.undefined
[1 of 1] Compiling Main ( Main.hs, Main.o )
Linking Main ...
False
[(0,"foo"),(6,"foo")]
fromList [(0,"foo"),(6,"foo")]
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment