1. Armin Rigo
  2. duhton

Commits

Armin Rigo  committed b08c139

Complain on any stderr output.

  • Participants
  • Parent commits a84b5fc
  • Branches default

Comments (0)

Files changed (1)

File test/support.py

View file
  • Ignore whitespace
 
 _compiled = False
 
-def execute(argv, stdin=''):
-    global _compiled
-    dir = py.path.local()
-    if dir.basename == 'test':
-        dir = dir.dirpath()
-    if not _compiled:
-        err = os.system("make -C '%s'" % dir)
-        if err:
-            raise OSError("*** make failed with exit code %r ***" % (err,))
-        _compiled = True
-    arg = str(dir.join('duhton_debug'))
-    popen = subprocess.Popen([arg] + argv,
+def _do(cmdargs, stdin=''):
+    popen = subprocess.Popen(cmdargs,
                              stdin  = subprocess.PIPE,
                              stdout = subprocess.PIPE,
                              stderr = subprocess.PIPE)
     error = popen.stderr.read()
     exitcode = popen.wait()
     if exitcode:
-        raise OSError("duhton failed (exit code %r)\n" % exitcode +
+        raise OSError("%r failed (exit code %r)\n" % (cmdargs[0], exitcode) +
                       error.rstrip())
+    if error:
+        raise OSError("%r got on stderr:\n" % (cmdargs[0],) + error.rstrip())
     return result
 
 
+def execute(argv, stdin=''):
+    global _compiled
+    dir = py.path.local()
+    if dir.basename == 'test':
+        dir = dir.dirpath()
+    if not _compiled:
+        _do(["make", "-C", str(dir)])
+        _compiled = True
+    arg = str(dir.join('duhton_debug'))
+    return _do([arg] + argv, stdin)
+
+
 def run(filecontent):
     return execute(['-'], stdin=filecontent)