Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
0e746bc3
Commit
0e746bc3
authored
Jan 22, 2008
by
Simon Marlow
Browse files
allow extra normalisation to be applied to the output on a per-test basis
parent
630fabfa
Changes
3
Hide whitespace changes
Inline
Side-by-side
testsuite/driver/testglobals.py
View file @
0e746bc3
...
...
@@ -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
()
...
...
testsuite/driver/testlib.py
View file @
0e746bc3
...
...
@@ -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.
...
...
testsuite/driver/testutil.py
View file @
0e746bc3
# -----------------------------------------------------------------------------
# Utils
def
id
(
a
):
return
a
def
eq
(
x
):
return
lambda
y
,
z
=
x
:
y
==
z
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment