Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions reframe/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Base regression exceptions
#

import contextlib
import inspect
import os
import sys
Expand Down Expand Up @@ -156,12 +157,23 @@ class ContainerError(ReframeError):
class BuildError(ReframeError):
'''Raised when a build fails.'''

def __init__(self, stdout, stderr):
def __init__(self, stdout, stderr, prefix=None):
super().__init__()
self._message = (
"standard error can be found in `%s', "
"standard output can be found in `%s'" % (stderr, stdout)
)
num_lines = 10
prefix = prefix or '.'
lines = [
f'stdout: {stdout!r}, stderr: {stderr!r}',
f'--- {stderr} (first {num_lines} lines) ---'
]
with contextlib.suppress(OSError):
with open(os.path.join(prefix, stderr)) as fp:
for i, line in enumerate(fp):
if i < num_lines:
# Remove trailing '\n'
lines.append(line[:-1])

lines += [f'--- {stderr} --- ']
self._message = '\n'.join(lines)


class SpawnedProcessError(ReframeError):
Expand Down
3 changes: 2 additions & 1 deletion reframe/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,8 @@ def compile_wait(self):

# We raise a BuildError when we an exit code and it is non zero
if self._build_job.exitcode:
raise BuildError(self._build_job.stdout, self._build_job.stderr)
raise BuildError(self._build_job.stdout,
self._build_job.stderr, self._stagedir)

self.build_system.post_build(self._build_job)

Expand Down