Commit 5cabf9ab authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Fix safeHaskell/check/pkg01 tests

They depended on the precise version of bytestring.

Also made them able to be run in parallel.
parent 14c4520d
......@@ -2,23 +2,11 @@ TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
cleanSafePkg01:
rm -rf setup a.out
rm -rf dist
find . -name "*.o" | xargs rm -f
find . -name "*.hi" | xargs rm -f
rm -rf local.db
rm -rf install
cleanPackageDatabase.%:
rm -rf pdb.$*
# We use the global package database as there's no easy way to tell
# ghc-pkg (via Cabal) to use one in ., and the global one at least
# won't affect the installed GHC and is more likely to work
PREFIX := $(abspath install)
$(eval $(call canonicalise,PREFIX))
PKGCONF = local.db
LGHC_PKG = '$(GHC_PKG)' --no-user-package-db -f '$(PKGCONF)'
HERE := $(abspath .)
$(eval $(call canonicalise,HERE))
ifeq "$(GhcDynamicByDefault)" "YES"
HI_SUF = dyn_hi
......@@ -26,51 +14,63 @@ else
HI_SUF = hi
endif
safePkg01:
'$(MAKE)' cleanSafePkg01
'$(TEST_HC)' --make -o setup Setup.hs -v0
mkPackageDatabase.%:
'$(MAKE)' cleanPackageDatabase.$*
mkdir pdb.$*
'$(GHC_PKG)' init local.db
'$(TEST_HC)' -outputdir pdb.$* -o pdb.$*/setup Setup.hs -v0
'$(GHC_PKG)' init pdb.$*/local.db
# We don't make use of -rtsopts in this test, and if it's enabled then
# we get a warning if dynlibs are enabled by default that:
# Warning: -rtsopts and -with-rtsopts have no effect with -shared.
# Warning: -rtsopts and -with-rtsopts have no effect with -shared.
# so we filter the flag out
./setup configure -v0 --prefix='$(PREFIX)' --with-compiler='$(TEST_HC)' --ghc-options='$(filter-out -rtsopts,$(TEST_HC_OPTS)) -fpackage-trust -trust base -trust bytestring' --with-hc-pkg='$(GHC_PKG)' --package-db='$(PKGCONF)' $(VANILLA) $(PROF) $(DYN)
./setup build -v0
./setup copy -v0
./setup register --inplace -v0
$(LGHC_PKG) list
$(LGHC_PKG) field safePkg01-1.0 trusted
pdb.$*/setup configure -v0 --dist pdb.$*/dist --prefix='$(HERE)/pdb.$*/install' --with-compiler='$(TEST_HC)' --ghc-options='$(filter-out -rtsopts,$(TEST_HC_OPTS)) -fpackage-trust -trust base -trust bytestring' --with-hc-pkg='$(GHC_PKG)' --package-db='pdb.$*/local.db' $(VANILLA) $(PROF) $(DYN)
pdb.$*/setup build -v0 --dist pdb.$*/dist
pdb.$*/setup copy -v0 --dist pdb.$*/dist
pdb.$*/setup register -v0 --dist pdb.$*/dist --inplace
# We use the global package database as there's no easy way to tell
# ghc-pkg (via Cabal) to use one in ., and the global one at least
# won't affect the installed GHC and is more likely to work
safePkg01_GHC_PKG = '$(GHC_PKG)' --no-user-package-db -f pdb.safePkg01/local.db
safePkg01:
'$(MAKE)' mkPackageDatabase.safePkg01
$(safePkg01_GHC_PKG) list
$(safePkg01_GHC_PKG) field safePkg01-1.0 trusted
echo
echo 'M_SafePkg'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg2'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg2.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg2.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg3'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg3.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg3.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg4'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg4.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg4.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg5'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg5.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg5.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg6'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg6.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg6.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg7'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg7.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg7.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg8'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg8.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
'$(TEST_HC)' --show-iface pdb.safePkg01/dist/build/M_SafePkg8.$(HI_SUF) | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'Testing setting trust'
$(LGHC_PKG) trust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
$(LGHC_PKG) distrust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
$(LGHC_PKG) distrust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
$(safePkg01_GHC_PKG) trust safePkg01-1.0
$(safePkg01_GHC_PKG) field safePkg01-1.0 trusted
$(safePkg01_GHC_PKG) distrust safePkg01-1.0
$(safePkg01_GHC_PKG) field safePkg01-1.0 trusted
$(safePkg01_GHC_PKG) distrust safePkg01-1.0
$(safePkg01_GHC_PKG) field safePkg01-1.0 trusted
......@@ -2,6 +2,9 @@
def f( opts ):
opts.only_ways = ['normal']
def normaliseBytestringPackage(str):
return re.sub('bytestring-[0-9]+(\.[0-9]+)*', 'bytestring-<VERSION>', str)
setTestOpts(f)
if config.have_vanilla:
......@@ -19,14 +22,15 @@ if config.have_shared_libs:
else:
dyn = '--disable-shared'
make_args = 'VANILLA=' + vanilla + ' PROF=' + prof + ' DYN=' + dyn
# Test building a package, that trust values are set correctly
# and can be changed correctly
test('safePkg01',
[# TODO: The other tests in here depend on this one not being cleaned
# clean_cmd('$MAKE -s --no-print-directory cleanSafePkg01'),
alone],
[clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.safePkg01'),
normalise_fun(normaliseBytestringPackage)],
run_command,
['$MAKE -s --no-print-directory safePkg01 VANILLA=' + vanilla + ' PROF=' + prof + ' DYN=' + dyn])
['$MAKE -s --no-print-directory safePkg01 ' + make_args])
# Fail since we enable package trust
test('ImpSafe01', normal, compile_fail, ['-fpackage-trust -distrust base'])
......@@ -34,25 +38,68 @@ test('ImpSafe01', normal, compile_fail, ['-fpackage-trust -distrust base'])
# Succeed since we don't enable package trust
test('ImpSafe02', normal, compile, ['-distrust base'])
test('ImpSafeOnly01', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust base'])
test('ImpSafeOnly01',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly01 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly01')],
compile,
['-fpackage-trust -package-db pdb.ImpSafeOnly01/local.db -trust base'])
test('ImpSafeOnly02', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust base -trust safePkg01'])
test('ImpSafeOnly02',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly02 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly02')],
compile,
['-fpackage-trust -package-db pdb.ImpSafeOnly02/local.db -trust base -trust safePkg01'])
# Fail since we enable package trust (and still need safePkg01 trusted)
test('ImpSafeOnly03', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust base'])
test('ImpSafeOnly03',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly03 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly03')],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly03/local.db -trust base'])
# Succeed since we don't enable package trust
test('ImpSafeOnly04', [normal, alone], compile, ['-package-db local.db -trust base'])
test('ImpSafeOnly04',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly04 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly04')],
compile,
['-package-db pdb.ImpSafeOnly04/local.db -trust base'])
# fail due to missing trust of safePkg01, next test succeeds.
test('ImpSafeOnly05', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust base'])
test('ImpSafeOnly06', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust base -trust safePkg01'])
test('ImpSafeOnly05',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly05 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly05')],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly05/local.db -trust base'])
test('ImpSafeOnly06',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly06 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly06')],
compile,
['-fpackage-trust -package-db pdb.ImpSafeOnly06/local.db -trust base -trust safePkg01'])
# fail due to missing trust
test('ImpSafeOnly07', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust safePkg01'])
test('ImpSafeOnly08', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust safePkg01'])
test('ImpSafeOnly09', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust safePkg01'])
test('ImpSafeOnly07',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly07 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly07'),
normalise_errmsg_fun(normaliseBytestringPackage)],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly07/local.db -trust safePkg01'])
test('ImpSafeOnly08',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly08 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly08'),
normalise_errmsg_fun(normaliseBytestringPackage)],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly08/local.db -trust safePkg01'])
test('ImpSafeOnly09',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly09 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly09'),
normalise_errmsg_fun(normaliseBytestringPackage)],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly09/local.db -trust safePkg01'])
# finally succeed
test('ImpSafeOnly10', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust safePkg01 -trust base -trust bytestring'])
test('ImpSafeOnly10',
[pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly10 ' + make_args),
clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly10')],
compile,
['-fpackage-trust -package-db pdb.ImpSafeOnly10/local.db -trust safePkg01 -trust base -trust bytestring'])
local.db:
pdb.safePkg01/local.db:
safePkg01-1.0
trusted: False
......
# Test GHCi works with Safe Haskell
def normaliseBytestringPackage(str):
return re.sub('bytestring-[0-9.]+', 'bytestring-<VERSION>.', str)
return re.sub('bytestring-[0-9.]+', 'bytestring-<VERSION>', str)
test('p1', normal, ghci_script, ['p1.script'])
test('p2', normal, ghci_script, ['p2.script'])
......
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