diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-03-10 14:10:26 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-03-10 15:20:43 -0700 |
commit | 8cbd7f5d97cdc0f4cd6b8baaa999f990533dc801 (patch) | |
tree | c795fdea467ce91690f6090dbb1bbe01ba610ccd /testsuite/driver | |
parent | 8a91079b5895c1505717b5d401617269720ad8ab (diff) | |
download | haskell-8cbd7f5d97cdc0f4cd6b8baaa999f990533dc801.tar.gz |
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: Edward Z. Yang <ezyang@cs.stanford.edu>
Reviewers: austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D725
Diffstat (limited to 'testsuite/driver')
-rw-r--r-- | testsuite/driver/testlib.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index a4e7d96404..38107af026 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -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): """ |