[commit: ghc] ghc-7.10: testsuite: format commands using config dict (4ce0453)
git at git.haskell.org
git at git.haskell.org
Wed Mar 11 21:06:58 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/4ce0453f306e11c79da1ddd60a3c3cec021be8ac/ghc
>---------------------------------------------------------------
commit 4ce0453f306e11c79da1ddd60a3c3cec021be8ac
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Fri Mar 6 20:17:41 2015 +0100
testsuite: format commands using config dict
Allow `cmd_wrapper` to return a format string that can refer to config values.
Very useful! This allows for many tests to be defined in pure Python, instead
of in an additional script or Makefile.
Example:
def Thpc(cmd):
return(cmd + ' && {hpc} report Thpc.tix')
test('Thpc', [cmd_wrapper(Thpc), only_ways['hpc']), compile_and_run, [''])
The `{hpc}` is replaced by the value of `config.hpc`. The result is that the
module `Thpc` first gets compiled, then the binary `Thpc` is run, and then the
`hpc report` command is run. The output of all of this is redirected
(and later appended) to Thpc.run.stdout/stderr as normally.
(cherry picked from commit 91c11feacc4c66a7ebcf8a88ab1cb851ce48142a)
>---------------------------------------------------------------
4ce0453f306e11c79da1ddd60a3c3cec021be8ac
testsuite/driver/testlib.py | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 6fc86e4..d359fe3 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -1314,11 +1314,11 @@ def simple_run( name, way, prog, args ):
stdin_comes_from = ' <' + use_stdin
if opts.combined_output:
- redirection = ' >' + run_stdout \
- + ' 2>&1'
+ redirection = ' > {} 2>&1'.format(run_stdout)
+ redirection_append = ' >> {} 2>&1'.format(run_stdout)
else:
- redirection = ' >' + run_stdout \
- + ' 2>' + run_stderr
+ redirection = ' > {} 2> {}'.format(run_stdout, run_stderr)
+ redirection_append = ' >> {} 2>> {}'.format(run_stdout, run_stderr)
cmd = prog + ' ' + args + ' ' \
+ my_rts_flags + ' ' \
@@ -1326,7 +1326,7 @@ def simple_run( name, way, prog, args ):
+ redirection
if opts.cmd_wrapper != None:
- cmd = opts.cmd_wrapper(cmd);
+ cmd = opts.cmd_wrapper(cmd) + redirection_append
cmd = 'cd ' + opts.testdir + ' && ' + cmd
@@ -1426,16 +1426,23 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
if getTestOpts().outputdir != None:
flags.extend(["-outputdir", getTestOpts().outputdir])
+ if getTestOpts().combined_output:
+ redirection = ' > {} 2>&1'.format(outname)
+ redirection_append = ' >> {} 2>&1'.format(outname)
+ else:
+ redirection = ' > {} 2> {}'.format(outname, errname)
+ redirection_append = ' >> {} 2>> {}'.format(outname, errname)
+
cmd = "'" + config.compiler + "' " \
+ ' '.join(flags) + ' ' \
+ srcname + ' ' \
+ ' '.join(config.way_flags(name)[way]) + ' ' \
+ extra_hc_opts + ' ' \
+ getTestOpts().extra_hc_opts + ' ' \
- + '<' + scriptname + ' 1>' + outname + ' 2>' + errname
+ + '<' + scriptname + redirection
if getTestOpts().cmd_wrapper != None:
- cmd = getTestOpts().cmd_wrapper(cmd);
+ cmd = getTestOpts().cmd_wrapper(cmd) + redirection_append;
cmd = 'cd ' + getTestOpts().testdir + " && " + cmd
@@ -1830,6 +1837,9 @@ def runCmd( cmd ):
return r << 8
def runCmdFor( name, cmd, timeout_multiplier=1.0 ):
+ # Format cmd using config. Example: cmd='{hpc} report A.tix'
+ cmd = cmd.format(**config.__dict__)
+
if_verbose( 3, cmd )
r = 0
if config.os == 'mingw32':
More information about the ghc-commits
mailing list