77
88import collections
99import inspect
10+ import sys
11+ import traceback
1012
1113import reframe
12- from reframe .core .exceptions import ReframeSyntaxError
14+ from reframe .core .exceptions import ReframeSyntaxError , user_frame
1315from reframe .core .logging import getlogger
1416from reframe .core .pipeline import RegressionTest
1517from reframe .utility .versioning import Version , VersionValidator
1618
1719
1820def _register_test (cls , args = None ):
19- def _instantiate ():
21+ def _instantiate (cls , args ):
22+ if isinstance (args , collections .Sequence ):
23+ return cls (* args )
24+ elif isinstance (args , collections .Mapping ):
25+ return cls (** args )
26+ elif args is None :
27+ return cls ()
28+
29+ def _instantiate_all ():
2030 ret = []
2131 for cls , args in mod .__rfm_test_registry :
2232 try :
@@ -26,18 +36,21 @@ def _instantiate():
2636 except AttributeError :
2737 mod .__rfm_skip_tests = set ()
2838
29- if isinstance (args , collections .Sequence ):
30- ret .append (cls (* args ))
31- elif isinstance (args , collections .Mapping ):
32- ret .append (cls (** args ))
33- elif args is None :
34- ret .append (cls ())
39+ try :
40+ ret .append (_instantiate (cls , args ))
41+ except Exception as e :
42+ frame = user_frame (sys .exc_info ()[2 ])
43+ msg = "skipping test due to errors: %s: " % cls .__name__
44+ msg += "use `-v' for more information\n "
45+ msg += " FILE: %s:%s" % (frame .filename , frame .lineno )
46+ getlogger ().warning (msg )
47+ getlogger ().verbose (traceback .format_exc ())
3548
3649 return ret
3750
3851 mod = inspect .getmodule (cls )
3952 if not hasattr (mod , '_rfm_gettests' ):
40- mod ._rfm_gettests = _instantiate
53+ mod ._rfm_gettests = _instantiate_all
4154
4255 try :
4356 mod .__rfm_test_registry .append ((cls , args ))
0 commit comments