diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-10-28 10:42:34 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-10-28 10:42:34 +0100 |
commit | 63918e6d7f048597ae8f61c6297a7b700630a819 (patch) | |
tree | 7b6c1042d9f021e93e7576614ee14166df2211e4 /testsuite | |
parent | aa2ceba33a8b98a2e8020464684f2eef7c98acf1 (diff) | |
download | haskell-63918e6d7f048597ae8f61c6297a7b700630a819.tar.gz |
Add n-ary version of `two_normalisers` to testsuite lib
This is more readable than nesting `two_normalisers()`-invocations
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/driver/testlib.py | 27 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/check/pkg01/all.T | 12 |
2 files changed, 33 insertions, 6 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 19fd0f8056..17dbc6b044 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 8b33f27297..5b2839d9c1 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,10 +41,11 @@ 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))], - run_command, + normalise_fun(join_normalisers( + normaliseArrayPackage, + normaliseArrayPackageKey, + normaliseBytestringPackage))], + run_command, ['$MAKE -s --no-print-directory safePkg01 ' + make_args]) # Fail since we enable package trust |