[GRASS-SVN] r61657 - grass/trunk/lib/python/gunittest
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 15 13:34:08 PDT 2014
Author: wenzeslaus
Date: 2014-08-15 13:34:08 -0700 (Fri, 15 Aug 2014)
New Revision: 61657
Modified:
grass/trunk/lib/python/gunittest/invoker.py
Log:
gunittest: execute sh script using sh command with -e to always fail on error
This is independent on shebag and error handing in script but needs sh executable
Modified: grass/trunk/lib/python/gunittest/invoker.py
===================================================================
--- grass/trunk/lib/python/gunittest/invoker.py 2014-08-15 20:27:10 UTC (rev 61656)
+++ grass/trunk/lib/python/gunittest/invoker.py 2014-08-15 20:34:08 UTC (rev 61657)
@@ -151,11 +151,29 @@
# TODO: we might clean the directory here before test if non-empty
if module.file_type == 'py':
+ # ignoring shebang line to use current Python
+ # and also pass parameters to it
# add also '-Qwarn'?
p = subprocess.Popen([sys.executable, '-tt', '-3',
module.abs_file_path],
cwd=cwd, env=env,
stdout=stdout, stderr=stderr)
+ elif module.file_type == 'sh':
+ # ignoring shebang line to pass parameters to shell
+ # expecting system to have sh or something compatible
+ # TODO: add some special checks for MS Windows
+ # using -x to see commands in stderr
+ # using -e to terminate fast
+ # from dash manual:
+ # -e errexit If not interactive, exit immediately if any
+ # untested command fails. The exit status of a com‐
+ # mand is considered to be explicitly tested if the
+ # command is used to control an if, elif, while, or
+ # until; or if the command is the left hand operand
+ # of an '&&' or '||' operator.
+ p = subprocess.Popen(['sh', '-e', '-x', module.abs_file_path],
+ cwd=cwd, env=env,
+ stdout=stdout, stderr=stderr)
else:
p = subprocess.Popen([module.abs_file_path],
cwd=cwd, env=env,
More information about the grass-commit
mailing list