Commit 0e746bc3 authored by Simon Marlow's avatar Simon Marlow
Browse files

allow extra normalisation to be applied to the output on a per-test basis

parent 630fabfa
......@@ -187,6 +187,9 @@ class TestOptions:
# Prefix to put on the command before running it
self.cmd_prefix = ''
# Extra output normalisation
self.extra_normaliser = lambda x: x
# The default set of options
global default_testopts
default_testopts = TestOptions()
......
......@@ -335,6 +335,11 @@ def cmd_prefix( prefix ):
def _cmd_prefix( opts, prefix ):
opts.cmd_prefix = prefix
# ----
def normalise_slashes( opts ):
opts.extra_normaliser = normalise_slashes_
# ----
# Function for composing two opt-fns together
......@@ -984,7 +989,7 @@ def check_stdout_ok( name ):
else:
return normalise_output(str)
return compare_outputs('stdout', norm, id, \
return compare_outputs('stdout', norm, getTestOpts().extra_normaliser, \
expected_stdout_file, actual_stdout_file)
def dump_stdout( name ):
......@@ -1006,7 +1011,7 @@ def check_stderr_ok( name ):
else:
return normalise_output(str)
return compare_outputs('stderr', norm, id, \
return compare_outputs('stderr', norm, getTestOpts().extra_normaliser, \
expected_stderr_file, actual_stderr_file)
def dump_stderr( name ):
......@@ -1094,9 +1099,6 @@ def compare_outputs( kind, normaliser, extra_normaliser,
return 0
return 1
def id(str):
return str
def normalise_whitespace( str ):
# Merge contiguous whitespace characters into a single space.
str = re.sub('[ \t\n]+', ' ', str)
......@@ -1113,6 +1115,10 @@ def normalise_errmsg( str ):
str = re.sub('([^\\s])\\.exe', '\\1', str)
return str
def normalise_slashes_( str ):
str = re.sub('\\\\', '/', str)
return str
def normalise_output( str ):
# Remove a .exe extension (for Windows)
# This can occur in error messages generated by the program.
......
# -----------------------------------------------------------------------------
# Utils
def id(a):
return a
def eq(x):
return lambda y,z=x: y == z
......
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