Skip to content

Commit 0b7f351

Browse files
committed
catch RunShellCmdError in EasyBlock.run_all_steps to do more meaningful error reporting incl. step name and easyconfig filename
1 parent df3b72c commit 0b7f351

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

easybuild/framework/easyblock.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
from easybuild.tools.hooks import MODULE_STEP, MODULE_WRITE, PACKAGE_STEP, PATCH_STEP, PERMISSIONS_STEP, POSTITER_STEP
8888
from easybuild.tools.hooks import POSTPROC_STEP, PREPARE_STEP, READY_STEP, SANITYCHECK_STEP, SOURCE_STEP
8989
from easybuild.tools.hooks import SINGLE_EXTENSION, TEST_STEP, TESTCASES_STEP, load_hooks, run_hook
90-
from easybuild.tools.run import check_async_cmd, run_cmd
90+
from easybuild.tools.run import RunShellCmdError, check_async_cmd, print_run_shell_cmd_error, run_cmd
9191
from easybuild.tools.jenkins import write_to_xml
9292
from easybuild.tools.module_generator import ModuleGeneratorLua, ModuleGeneratorTcl, module_generator, dependencies_for
9393
from easybuild.tools.module_naming_scheme.utilities import det_full_ec_version
@@ -4124,6 +4124,11 @@ def run_all_steps(self, run_test_cases):
41244124
start_time = datetime.now()
41254125
try:
41264126
self.run_step(step_name, step_methods)
4127+
except RunShellCmdError as err:
4128+
print_run_shell_cmd_error(err)
4129+
ec_path = os.path.basename(self.cfg.path)
4130+
error_msg = f"shell command '{err.cmd_name} ...' failed in {step_name} step for {ec_path}"
4131+
raise EasyBuildError(error_msg)
41274132
finally:
41284133
if not self.dry_run:
41294134
step_duration = datetime.now() - start_time
@@ -4225,7 +4230,7 @@ def build_and_install_one(ecdict, init_env):
42254230
app.cfg['skip'] = skip
42264231

42274232
# build easyconfig
4228-
errormsg = '(no error)'
4233+
error_msg = '(no error)'
42294234
# timing info
42304235
start_time = time.time()
42314236
try:
@@ -4263,9 +4268,7 @@ def build_and_install_one(ecdict, init_env):
42634268
adjust_permissions(app.installdir, stat.S_IWUSR, add=False, recursive=True)
42644269

42654270
except EasyBuildError as err:
4266-
first_n = 300
4267-
errormsg = "build failed (first %d chars): %s" % (first_n, err.msg[:first_n])
4268-
_log.warning(errormsg)
4271+
error_msg = err.msg
42694272
result = False
42704273

42714274
ended = 'ended'
@@ -4387,11 +4390,7 @@ def ensure_writable_log_dir(log_dir):
43874390
# build failed
43884391
success = False
43894392
summary = 'FAILED'
4390-
4391-
build_dir = ''
4392-
if app.builddir:
4393-
build_dir = " (build directory: %s)" % (app.builddir)
4394-
succ = "unsuccessfully%s: %s" % (build_dir, errormsg)
4393+
succ = "unsuccessfully: " + error_msg
43954394

43964395
# cleanup logs
43974396
app.close_log()
@@ -4424,7 +4423,7 @@ def ensure_writable_log_dir(log_dir):
44244423

44254424
del app
44264425

4427-
return (success, application_log, errormsg)
4426+
return (success, application_log, error_msg)
44284427

44294428

44304429
def copy_easyblocks_for_reprod(easyblock_instances, reprod_dir):

0 commit comments

Comments
 (0)