@@ -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
0 commit comments