summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorscheibelp <scheibel1@llnl.gov>2018-09-19 17:29:15 -0700
committerGitHub <noreply@github.com>2018-09-19 17:29:15 -0700
commit95850a7a5e5a77f6543cdc8d8ee8265ad021489a (patch)
tree19f2ceba76138cc03094d21f1d1894b92eac40c1 /lib
parent7b2b2fb96957b9ea94ddb0656fd047724564f31d (diff)
downloadspack-95850a7a5e5a77f6543cdc8d8ee8265ad021489a.tar.gz
spack-95850a7a5e5a77f6543cdc8d8ee8265ad021489a.tar.bz2
spack-95850a7a5e5a77f6543cdc8d8ee8265ad021489a.tar.xz
spack-95850a7a5e5a77f6543cdc8d8ee8265ad021489a.zip
report error if failed process captures stderr (#9293)
When a Spack Executable was configured to capture stderr and the process failed, the error messages of the process were discarded. This made it difficult to understand why the process failed. The exception is now updated to include the stderr of the process when the Executable captures stderr.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/util/executable.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index 1817d0a77b..e64845f0ef 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -186,18 +186,28 @@ class Executable(object):
env=env)
out, err = proc.communicate()
- rc = self.returncode = proc.returncode
- if fail_on_error and rc != 0 and (rc not in ignore_errors):
- raise ProcessError('Command exited with status %d:' %
- proc.returncode, cmd_line)
-
+ result = None
if output is str or error is str:
result = ''
if output is str:
result += to_str(out)
if error is str:
result += to_str(err)
- return result
+
+ rc = self.returncode = proc.returncode
+ if fail_on_error and rc != 0 and (rc not in ignore_errors):
+ long_msg = cmd_line
+ if result:
+ # If the output is not captured in the result, it will have
+ # been stored either in the specified files (e.g. if
+ # 'output' specifies a file) or written to the parent's
+ # stdout/stderr (e.g. if 'output' is not specified)
+ long_msg += '\n' + result
+
+ raise ProcessError('Command exited with status %d:' %
+ proc.returncode, long_msg)
+
+ return result
except OSError as e:
raise ProcessError(