Commit 8cbd7f5d authored by Edward Z. Yang's avatar Edward Z. Yang

Refactor testsuite with normalise_version()

Summary:
This function generalizes the normaliseBytestringPackage and other similar
one-off functions into normalise_version() with takes a package name to
normalize against.  This JUST manages package versions; we also could use
a normalize for keys.

In the process, I modified all the normalization functions to be accumulative;
I don't think this makes a difference for current test cases but I think it
makes things nicer.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Reviewers: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D725
parent 8a91079b
......@@ -489,22 +489,34 @@ def _check_stdout( name, opts, f ):
# ----
def normalise_slashes( name, opts ):
opts.extra_normaliser = normalise_slashes_
_normalise_fun(name, opts, normalise_slashes_)
def normalise_exe( name, opts ):
opts.extra_normaliser = normalise_exe_
_normalise_fun(name, opts, normalise_exe_)
def normalise_fun( *fs ):
return lambda name, opts: _normalise_fun(name, opts, fs)
def _normalise_fun( name, opts, *fs ):
opts.extra_normaliser = join_normalisers(fs)
opts.extra_normaliser = join_normalisers(opts.extra_normaliser, fs)
def normalise_errmsg_fun( *fs ):
return lambda name, opts: _normalise_errmsg_fun(name, opts, fs)
def _normalise_errmsg_fun( name, opts, *fs ):
opts.extra_errmsg_normaliser = join_normalisers(fs)
opts.extra_errmsg_normaliser = join_normalisers(opts.extra_errmsg_normaliser, fs)
def normalise_version_( *pkgs ):
def normalise_version__( str ):
return re.sub('(' + '|'.join(map(re.escape,pkgs)) + ')-[0-9.]+',
'\\1-<VERSION>', str)
return normalise_version__
def normalise_version( *pkgs ):
def normalise_version__( name, opts ):
_normalise_fun(name, opts, normalise_version_(*pkgs))
_normalise_errmsg_fun(name, opts, normalise_version_(*pkgs))
return normalise_version__
def join_normalisers(*a):
"""
......
......@@ -7,9 +7,6 @@ incr_ghc = '-package "ghc (HsTypes as MyHsTypes, HsUtils)" '
inc_ghc = '-package ghc '
hide_ghc = '-hide-package ghc '
def normaliseGhcVersion(str):
return re.sub('ghc-[0-9.]+', 'ghc-<VERSION>', str)
test('package01', normal, compile, [hide_all + incr_containers])
test('package01e', normal, compile_fail, [hide_all + incr_containers])
test('package02', normal, compile, [hide_all + inc_containers + incr_containers])
......@@ -17,8 +14,8 @@ test('package03', normal, compile, [hide_all + incr_containers + inc_conta
test('package04', normal, compile, [incr_containers])
test('package05', normal, compile, [incr_ghc + inc_ghc])
test('package06', normal, compile, [incr_ghc])
test('package06e', normalise_errmsg_fun(normaliseGhcVersion), compile_fail, [incr_ghc])
test('package07e', normalise_errmsg_fun(normaliseGhcVersion), compile_fail, [incr_ghc + inc_ghc + hide_ghc])
test('package08e', normalise_errmsg_fun(normaliseGhcVersion), compile_fail, [incr_ghc + hide_ghc])
test('package06e', normalise_version('ghc'), compile_fail, [incr_ghc])
test('package07e', normalise_version('ghc'), compile_fail, [incr_ghc + inc_ghc + hide_ghc])
test('package08e', normalise_version('ghc'), compile_fail, [incr_ghc + hide_ghc])
test('package09e', normal, compile_fail, ['-package "containers (Data.Map as M, Data.Set as M)"'])
test('package10', normal, compile, ['-hide-all-packages -package "ghc (UniqFM as Prelude)" '])
......@@ -7,9 +7,6 @@ def f( name, opts ):
setTestOpts(f)
def normaliseBytestringPackage(str):
return re.sub('bytestring-[0-9]+(\.[0-9]+)*', 'bytestring-<VERSION>', str)
test('CheckA', normal, compile, [''])
test('CheckB',
extra_clean(['CheckB_Aux.hi', 'CheckB_Aux.o']),
......@@ -62,7 +59,7 @@ test('Check08',
# check -distrust-all-packages flag works
test('Check09',
normalise_errmsg_fun(normaliseBytestringPackage),
normalise_version("bytestring"),
compile_fail,
['-fpackage-trust -distrust-all-packages'])
......
......@@ -2,15 +2,6 @@
def f( name, opts ):
opts.only_ways = ['normal']
def normaliseArrayPackage(str):
return re.sub('array-[0-9]+(\.[0-9]+)*', 'array-<VERSION>', str)
def normaliseBytestringPackage(str):
return re.sub('bytestring-[0-9]+(\.[0-9]+)*', 'bytestring-<VERSION>', str)
def normaliseIntegerPackage(str):
return re.sub('integer-(gmp|simple)-[0-9.]+', 'integer-<IMPL>-<VERSION>', str)
def ignoreLdOutput(str):
return re.sub('Creating library file: pdb.safePkg01/dist.build.libHSsafePkg01-1.0-ghc[0-9.]*.dll.a\n', '', str)
......@@ -38,10 +29,8 @@ make_args = 'VANILLA=' + vanilla + ' PROF=' + prof + ' DYN=' + dyn
test('safePkg01',
[clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.safePkg01'),
normalise_errmsg_fun(ignoreLdOutput),
normalise_fun(
normaliseArrayPackage,
normaliseIntegerPackage,
normaliseBytestringPackage)],
normalise_version("array", "integer-gmp", "integer-simple", "bytestring"),
],
run_command,
['$MAKE -s --no-print-directory safePkg01 ' + make_args])
......@@ -102,19 +91,19 @@ test('ImpSafeOnly06',
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)],
normalise_version("bytestring")],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly07/local.db -trust safePkg01 -distrust bytestring'])
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)],
normalise_version("bytestring")],
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)],
normalise_version("bytestring")],
compile_fail,
['-fpackage-trust -package-db pdb.ImpSafeOnly09/local.db -trust safePkg01'])
......
# Test GHCi works with Safe Haskell
def normaliseBytestringPackage(str):
return re.sub('bytestring-[0-9.]+', 'bytestring-<VERSION>', str)
test('p1', normal, ghci_script, ['p1.script'])
test('p2', normal, ghci_script, ['p2.script'])
test('p3', normalise_errmsg_fun(normaliseBytestringPackage),
ghci_script, ['p3.script'])
test('p3', normalise_version("bytestring"), ghci_script, ['p3.script'])
test('p4', normal, ghci_script, ['p4.script'])
test('p5', normal, ghci_script, ['p5.script'])
test('p6', normal, ghci_script, ['p6.script'])
......@@ -15,14 +11,11 @@ test('p8', normal, ghci_script, ['p8.script'])
test('p9', normal, ghci_script, ['p9.script'])
test('p10', normal, ghci_script, ['p10.script'])
test('p11', normal, ghci_script, ['p11.script'])
test('p12', normalise_errmsg_fun(normaliseBytestringPackage),
ghci_script, ['p12.script'])
test('p12', normalise_version("bytestring"), ghci_script, ['p12.script'])
test('p13', normal, ghci_script, ['p13.script'])
test('p14', normal, ghci_script, ['p14.script'])
test('p16', normal, ghci_script, ['p16.script'])
test('p17', normalise_errmsg_fun(normaliseBytestringPackage),
ghci_script, ['p17.script'])
test('p17', normalise_version("bytestring"), ghci_script, ['p17.script'])
# 7172
test('p18', normalise_fun(normaliseBytestringPackage),
ghci_script, ['p18.script'])
test('p18', normalise_version("bytestring"), ghci_script, ['p18.script'])
......@@ -289,7 +289,9 @@ test('T8028',
['T8028', '-v0 ' + config.ghc_th_way_flags])
test('TH_Roles1', normal, compile_fail, ['-v0'])
test('TH_Roles2', normal, compile, ['-v0 -ddump-tc'])
test('TH_Roles2', normalise_version('array', 'base', 'deepseq', 'ghc-prim',
'integer-gmp', 'pretty', 'template-haskell'
), compile, ['-v0 -ddump-tc'])
test('TH_Roles3', normal, compile, ['-v0 -dsuppress-uniques'])
test('TH_Roles4', normal, compile, ['-v0'])
......
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