[commit: ghc] master: Add n-ary version of `two_normalisers` to testsuite lib (63918e6)
git at git.haskell.org
git at git.haskell.org
Tue Oct 28 09:44:33 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/63918e6d7f048597ae8f61c6297a7b700630a819/ghc
>---------------------------------------------------------------
commit 63918e6d7f048597ae8f61c6297a7b700630a819
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Tue Oct 28 10:42:34 2014 +0100
Add n-ary version of `two_normalisers` to testsuite lib
This is more readable than nesting `two_normalisers()`-invocations
>---------------------------------------------------------------
63918e6d7f048597ae8f61c6297a7b700630a819
testsuite/driver/testlib.py | 27 +++++++++++++++++++++++++--
testsuite/tests/safeHaskell/check/pkg01/all.T | 10 +++++++---
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 19fd0f8..17dbc6b 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -506,8 +506,29 @@ def _normalise_errmsg_fun( name, opts, f ):
opts.extra_errmsg_normaliser = f
def two_normalisers(f, g):
+ """
+ See also `join_normalisers` for a n-ary version of `two_normalisers`
+ """
return lambda x, f=f, g=g: f(g(x))
+def join_normalisers(*a):
+ """
+ Compose functions, e.g.
+
+ join_normalisers(f1,f2,f3)
+
+ is the same as
+
+ lambda x: f1(f2(f3(x)))
+ """
+
+ assert all(callable(f) for f in a)
+
+ fn = lambda x:x # identity function
+ for f in a:
+ fn = lambda x,f=f,fn=fn: fn(f(x))
+ return fn
+
# ----
# Function for composing two opt-fns together
@@ -1004,8 +1025,10 @@ def do_compile( name, way, should_fail, top_mod, extra_mods, extra_hc_opts, over
(platform_specific, expected_stderr_file) = platform_wordsize_qualify(namebase, 'stderr')
actual_stderr_file = qualify(name, 'comp.stderr')
- if not compare_outputs('stderr', \
- two_normalisers(two_normalisers(getTestOpts().extra_errmsg_normaliser, normalise_errmsg), normalise_whitespace), \
+ if not compare_outputs('stderr',
+ join_normalisers(getTestOpts().extra_errmsg_normaliser,
+ normalise_errmsg,
+ normalise_whitespace),
expected_stderr_file, actual_stderr_file):
return failBecause('stderr mismatch')
diff --git a/testsuite/tests/safeHaskell/check/pkg01/all.T b/testsuite/tests/safeHaskell/check/pkg01/all.T
index 8b33f27..5b2839d 100644
--- a/testsuite/tests/safeHaskell/check/pkg01/all.T
+++ b/testsuite/tests/safeHaskell/check/pkg01/all.T
@@ -8,6 +8,9 @@ def normaliseArrayPackage(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 normaliseArrayPackageKey(str):
return re.sub('array_[A-Za-z0-9]+', 'array_<HASH>', str)
@@ -38,9 +41,10 @@ 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(two_normalisers(two_normalisers(normaliseArrayPackage,
- normaliseArrayPackageKey),
- normaliseBytestringPackage))],
+ normalise_fun(join_normalisers(
+ normaliseArrayPackage,
+ normaliseArrayPackageKey,
+ normaliseBytestringPackage))],
run_command,
['$MAKE -s --no-print-directory safePkg01 ' + make_args])
More information about the ghc-commits
mailing list