Skip to content

Commit 872e1e8

Browse files
author
Vasileios Karakasis
authored
Merge branch 'master' into feat/perf_configuration
2 parents d2dd7fb + 067a557 commit 872e1e8

File tree

4 files changed

+204
-128
lines changed

4 files changed

+204
-128
lines changed

reframe/core/pipeline.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import functools
1616
import inspect
1717
import itertools
18+
import numbers
1819
import os
1920
import shutil
2021

@@ -37,7 +38,6 @@
3738
from reframe.core.schedulers import Job
3839
from reframe.core.schedulers.registry import getscheduler
3940
from 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))

reframe/utility/sanity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
computing statistical information on series of data etc.
6464
6565
'''
66+
6667
import builtins
6768
import glob as pyglob
6869
import itertools
@@ -551,7 +552,7 @@ def calc_bound(thres):
551552
evaluate(assert_bounded(val, lower, upper))
552553
except SanityError:
553554
error_msg = msg or '{0} is beyond reference value {1} (l={2}, u={3})'
554-
raise SanityError(_format(error_msg, val, ref, lower, upper))
555+
raise SanityError(_format(error_msg, val, ref, lower, upper)) from None
555556
else:
556557
return True
557558

unittests/fixtures.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,16 @@ def partition_with_scheduler(name=None, skip_partitions=['kesch:pn']):
8686
def has_sane_modules_system():
8787
return not isinstance(rt.runtime().modules_system.backend,
8888
modules.NoModImpl)
89+
90+
91+
def custom_prefix(prefix):
92+
'''Assign a custom prefix to a test.
93+
94+
This is useful in unit tests when we want to create tests on-the-fly and
95+
associate them with existing resources.'''
96+
97+
def _set_prefix(cls):
98+
cls._rfm_custom_prefix = prefix
99+
return cls
100+
101+
return _set_prefix

0 commit comments

Comments
 (0)