1515import functools
1616import inspect
1717import itertools
18+ import numbers
1819import os
1920import shutil
2021
3738from reframe .core .schedulers import Job
3839from reframe .core .schedulers .registry import getscheduler
3940from reframe .core .systems import SystemPartition
40- from reframe .utility .sanity import assert_reference
4141
4242
4343# Dependency kinds
@@ -202,7 +202,8 @@ class RegressionTest(metaclass=RegressionTestMeta):
202202 #: taken.
203203 #:
204204 #: :type: :class:`str` or :class:`None`
205- #: :default: ``'src'``
205+ #: :default: ``'src'`` if such a directory exists at the test level,
206+ #: otherwise ``None``
206207 #:
207208 #: .. note::
208209 #: .. versionchanged:: 2.9
@@ -211,6 +212,10 @@ class RegressionTest(metaclass=RegressionTestMeta):
211212 #:
212213 #: .. versionchanged:: 2.10
213214 #: Support for Git repositories was added.
215+ #:
216+ #: .. versionchanged:: 3.0
217+ #: Default value is now conditionally set to either ``'src'`` or
218+ #: :class:`None`.
214219 sourcesdir = fields .TypedField ('sourcesdir' , str , type (None ))
215220
216221 #: The build system to be used for this test.
@@ -661,8 +666,13 @@ def __new__(cls, *args, **kwargs):
661666 itertools .chain (args , kwargs .values ()))
662667 name += '_' + '_' .join (arg_names )
663668
664- obj ._rfm_init (name ,
665- os .path .abspath (os .path .dirname (inspect .getfile (cls ))))
669+ # Determine the prefix
670+ try :
671+ prefix = cls ._rfm_custom_prefix
672+ except AttributeError :
673+ prefix = os .path .abspath (os .path .dirname (inspect .getfile (cls )))
674+
675+ obj ._rfm_init (name , prefix )
666676 return obj
667677
668678 def __init__ (self ):
@@ -706,10 +716,11 @@ def _rfm_init(self, name=None, prefix=None):
706716 self .local = False
707717
708718 # Static directories of the regression check
709- if prefix is not None :
710- self ._prefix = os .path .abspath (prefix )
711-
712- self .sourcesdir = 'src'
719+ self ._prefix = os .path .abspath (prefix )
720+ if os .path .isdir (os .path .join (self ._prefix , 'src' )):
721+ self .sourcesdir = 'src'
722+ else :
723+ self .sourcesdir = None
713724
714725 # Output patterns
715726 self .sanity_patterns = None
@@ -1321,10 +1332,18 @@ def check_performance(self):
13211332
13221333 for key , values in self ._perfvalues .items ():
13231334 val , ref , low_thres , high_thres , * _ = values
1335+
1336+ # Verify that val is a number
1337+ if not isinstance (val , numbers .Number ):
1338+ raise SanityError (
1339+ "the value extracted for performance variable '%s' "
1340+ "is not a number: %s" % (key , val )
1341+ )
1342+
13241343 tag = key .split (':' )[- 1 ]
13251344 try :
13261345 sn .evaluate (
1327- assert_reference (
1346+ sn . assert_reference (
13281347 val , ref , low_thres , high_thres ,
13291348 msg = ('failed to meet reference: %s={0}, '
13301349 'expected {1} (l={2}, u={3})' % tag ))
0 commit comments