@@ -258,6 +258,8 @@ def __init__(self, ec):
258258 if group_name is not None :
259259 self .group = use_group (group_name )
260260
261+ self .ignore_test_failure = build_option ('ignore_test_failure' )
262+
261263 # generate build/install directories
262264 self .gen_builddir ()
263265 self .gen_installdir ()
@@ -1814,6 +1816,18 @@ def remove_module_file(self):
18141816 self .log .info ("Removing existing module file %s" , self .mod_filepath )
18151817 remove_file (self .mod_filepath )
18161818
1819+ def report_test_failure (self , msg_or_error ):
1820+ """
1821+ Report a failing test either via an exception or warning depending on ignore-test-failure
1822+
1823+ :param msg_or_error: failure description (string value or an EasyBuildError instance)
1824+ """
1825+ if self .ignore_test_failure :
1826+ print_warning ("Test failure ignored: " + str (msg_or_error ), log = self .log )
1827+ else :
1828+ exception = msg_or_error if isinstance (msg_or_error , EasyBuildError ) else EasyBuildError (msg_or_error )
1829+ raise exception
1830+
18171831 #
18181832 # STEP FUNCTIONS
18191833 #
@@ -2229,6 +2243,13 @@ def test_step(self):
22292243
22302244 return out
22312245
2246+ def _test_step (self ):
2247+ """Run the test_step and handles failures"""
2248+ try :
2249+ self .test_step ()
2250+ except EasyBuildError as err :
2251+ self .report_test_failure (err )
2252+
22322253 def stage_install_step (self ):
22332254 """
22342255 Install in a stage directory before actual installation.
@@ -3367,10 +3388,12 @@ def run_step(self, step, step_methods):
33673388 run_hook (step , self .hooks , pre_step_hook = True , args = [self ])
33683389
33693390 for step_method in step_methods :
3370- self .log .info ("Running method %s part of step %s" % (extract_method_name (step_method ), step ))
3391+ # Remove leading underscore from e.g. "_test_step"
3392+ method_name = extract_method_name (step_method ).lstrip ('_' )
3393+ self .log .info ("Running method %s part of step %s" , method_name , step )
33713394
33723395 if self .dry_run :
3373- self .dry_run_msg ("[%s method]" , step_method ( self ). __name__ )
3396+ self .dry_run_msg ("[%s method]" , method_name )
33743397
33753398 # if an known possible error occurs, just report it and continue
33763399 try :
@@ -3443,7 +3466,7 @@ def install_step_spec(initial):
34433466 prepare_step_spec = (PREPARE_STEP , 'preparing' , [lambda x : x .prepare_step ], False )
34443467 configure_step_spec = (CONFIGURE_STEP , 'configuring' , [lambda x : x .configure_step ], True )
34453468 build_step_spec = (BUILD_STEP , 'building' , [lambda x : x .build_step ], True )
3446- test_step_spec = (TEST_STEP , 'testing' , [lambda x : x .test_step ], True )
3469+ test_step_spec = (TEST_STEP , 'testing' , [lambda x : x ._test_step ], True )
34473470 extensions_step_spec = (EXTENSIONS_STEP , 'taking care of extensions' , [lambda x : x .extensions_step ], False )
34483471
34493472 # part 1: pre-iteration + first iteration
0 commit comments