File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 77# Base regression exceptions
88#
99
10+ import contextlib
1011import inspect
1112import os
1213import sys
@@ -156,12 +157,23 @@ class ContainerError(ReframeError):
156157class BuildError (ReframeError ):
157158 '''Raised when a build fails.'''
158159
159- def __init__ (self , stdout , stderr ):
160+ def __init__ (self , stdout , stderr , prefix = None ):
160161 super ().__init__ ()
161- self ._message = (
162- "standard error can be found in `%s', "
163- "standard output can be found in `%s'" % (stderr , stdout )
164- )
162+ num_lines = 10
163+ prefix = prefix or '.'
164+ lines = [
165+ f'stdout: { stdout !r} , stderr: { stderr !r} ' ,
166+ f'--- { stderr } (first { num_lines } lines) ---'
167+ ]
168+ with contextlib .suppress (OSError ):
169+ with open (os .path .join (prefix , stderr )) as fp :
170+ for i , line in enumerate (fp ):
171+ if i < num_lines :
172+ # Remove trailing '\n'
173+ lines .append (line [:- 1 ])
174+
175+ lines += [f'--- { stderr } --- ' ]
176+ self ._message = '\n ' .join (lines )
165177
166178
167179class SpawnedProcessError (ReframeError ):
Original file line number Diff line number Diff line change @@ -1294,7 +1294,8 @@ def compile_wait(self):
12941294
12951295 # We raise a BuildError when we an exit code and it is non zero
12961296 if self ._build_job .exitcode :
1297- raise BuildError (self ._build_job .stdout , self ._build_job .stderr )
1297+ raise BuildError (self ._build_job .stdout ,
1298+ self ._build_job .stderr , self ._stagedir )
12981299
12991300 self .build_system .post_build (self ._build_job )
13001301
You can’t perform that action at this time.
0 commit comments