浏览代码

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

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61657 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 10 年之前
父节点
当前提交
41d0afd58a
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      lib/python/gunittest/invoker.py

+ 18 - 0
lib/python/gunittest/invoker.py

@@ -151,11 +151,29 @@ class GrassTestFilesInvoker(object):
         # 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,