[commit: testsuite] master: generalise cmd_prefix to a general function to transform the command (dac5424)
Simon Marlow
marlowsd at gmail.com
Tue Oct 18 17:28:11 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/dac5424b8d45f2c7c51b794741f648ab568535e8
>---------------------------------------------------------------
commit dac5424b8d45f2c7c51b794741f648ab568535e8
Author: Simon Marlow <marlowsd at gmail.com>
Date: Tue Oct 18 16:17:41 2011 +0100
generalise cmd_prefix to a general function to transform the command
>---------------------------------------------------------------
driver/testglobals.py | 4 ++--
driver/testlib.py | 36 +++++++++++++++++++++---------------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/driver/testglobals.py b/driver/testglobals.py
index bdd44a3..671d6e0 100644
--- a/driver/testglobals.py
+++ b/driver/testglobals.py
@@ -216,8 +216,8 @@ class TestOptions:
# Command to run for extra cleaning
self.clean_cmd = None
- # Prefix to put on the command before running it
- self.cmd_prefix = ''
+ # Command wrapper: a function to apply to the command before running it
+ self.cmd_wrapper = None
# Prefix to put on the command before compiling it
self.compile_cmd_prefix = ''
diff --git a/driver/testlib.py b/driver/testlib.py
index 3ed5b82..02c3d82 100644
--- a/driver/testlib.py
+++ b/driver/testlib.py
@@ -420,7 +420,15 @@ def cmd_prefix( prefix ):
return lambda opts, p=prefix: _cmd_prefix(opts, prefix)
def _cmd_prefix( opts, prefix ):
- opts.cmd_prefix = prefix
+ opts.cmd_wrapper = lambda cmd, p=prefix: p + ' ' + cmd;
+
+# ----
+
+def cmd_wrapper( fun ):
+ return lambda opts, f=fun: _cmd_wrapper(opts, fun)
+
+def _cmd_wrapper( opts, fun ):
+ opts.cmd_wrapper = fun
# ----
@@ -802,9 +810,6 @@ def ghci_script( name, way, script ):
' --interactive -v0 -ignore-dot-ghci ' + \
join(flags,' ')
- if getTestOpts().cmd_prefix != '':
- cmd = getTestOpts().cmd_prefix + ' ' + cmd;
-
getTestOpts().stdin = script
return simple_run( name, way, cmd, getTestOpts().extra_run_opts )
@@ -899,8 +904,6 @@ def compile_and_run__( name, way, top_mod, extra_mods, extra_hc_opts ):
return result
cmd = './' + name;
- if getTestOpts().cmd_prefix != '':
- cmd = getTestOpts().cmd_prefix + ' ' + cmd;
# we don't check the compiler's stderr for a compile-and-run test
return simple_run( name, way, cmd, getTestOpts().extra_run_opts )
@@ -1077,13 +1080,17 @@ def simple_run( name, way, prog, args ):
stdin_comes_from = ''
else:
stdin_comes_from = ' <' + use_stdin
- cmd = 'cd ' + getTestOpts().testdir + ' && ' \
- + prog + ' ' + args + ' ' \
+ cmd = prog + ' ' + args + ' ' \
+ my_rts_flags + ' ' \
+ stdin_comes_from \
+ ' >' + run_stdout \
+ ' 2>' + run_stderr
+ if getTestOpts().cmd_wrapper != None:
+ cmd = getTestOpts().cmd_wrapper(cmd);
+
+ cmd = 'cd ' + getTestOpts().testdir + ' && ' + cmd
+
# run the command
result = runCmdFor(name, cmd)
@@ -1134,11 +1141,6 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
rm_no_fail(errname)
rm_no_fail(name)
- if getTestOpts().cmd_prefix == '':
- cmd_prefix = ''
- else:
- cmd_prefix = getTestOpts().cmd_prefix + ' '
-
if (top_mod == ''):
srcname = add_hs_lhs_suffix(name)
else:
@@ -1179,8 +1181,7 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
script.close()
- cmd = 'cd ' + getTestOpts().testdir + " && " + cmd_prefix + "'" \
- + config.compiler + "' " \
+ cmd = "'" + config.compiler + "' " \
+ join(config.compiler_always_flags,' ') + ' ' \
+ srcname + ' ' \
+ join(config.way_flags[way],' ') + ' ' \
@@ -1188,6 +1189,11 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
+ getTestOpts().extra_hc_opts + ' ' \
+ '<' + scriptname + ' 1>' + outname + ' 2>' + errname
+ if getTestOpts().cmd_wrapper != None:
+ cmd = getTestOpts().cmd_wrapper(cmd);
+
+ cmd = 'cd ' + getTestOpts().testdir + " && " + cmd
+
result = runCmdFor(name, cmd)
exit_code = result >> 8
More information about the Cvs-ghc
mailing list