Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions docs/deferrable_functions_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,5 @@ The page ":doc:`deferrables`" explains in detail how deferrable functions work a
do_sth()


.. py:decorator:: reframe.utility.sanity.sanity_function(func)

Please use the :func:`reframe.core.pipeline.RegressionMixin.deferrable` decorator when possible. Alternatively, please use the :func:`reframe.utility.sanity.deferrable` decorator instead.

.. warning:: Not to be mistaken with :func:`~reframe.core.pipeline.RegressionMixin.sanity_function` built-in.
.. deprecated:: 3.8.0


.. automodule:: reframe.utility.sanity
:members:
53 changes: 4 additions & 49 deletions docs/regression_test_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Test Base Classes
Test Decorators
---------------

.. autodecorator:: reframe.core.decorators.parameterized_test(*inst)

.. autodecorator:: reframe.core.decorators.required_version(*versions)

.. autodecorator:: reframe.core.decorators.simple_test


Expand Down Expand Up @@ -221,6 +217,8 @@ The framework will then continue with other activities and it will execute the p
.. versionchanged:: 3.7.0
Declaring pipeline hooks using the same name functions from the :py:mod:`reframe` or :py:mod:`reframe.core.decorators` modules is now deprecated.
You should use the built-in functions described in this section instead.
.. versionchanged:: 4.0.0
Pipeline hooks can only be defined through the built-in functions described in this section.

.. py:decorator:: RegressionMixin.run_before(stage)

Expand Down Expand Up @@ -315,8 +313,8 @@ Built-in functions
.. versionchanged:: 3.7.0
Using this function from the :py:mod:`reframe` or :py:mod:`reframe.core.decorators` modules is now deprecated.
You should use the built-in function described here.


.. versionchanged:: 4.0.0
This function can only be used as a built-in.



Expand Down Expand Up @@ -442,49 +440,6 @@ The :py:mod:`reframe` module offers direct access to the basic test classes, con

See :class:`reframe.core.pipeline.RunOnlyRegressionTest`.

.. py:attribute:: reframe.DEPEND_BY_ENV

See :attr:`reframe.core.pipeline.DEPEND_BY_ENV`.


.. py:attribute:: reframe.DEPEND_EXACT

See :attr:`reframe.core.pipeline.DEPEND_EXACT`.


.. py:attribute:: reframe.DEPEND_FULLY

See :attr:`reframe.core.pipeline.DEPEND_FULLY`.


.. py:decorator:: reframe.parameterized_test

See :func:`@reframe.core.decorators.parameterized_test <reframe.core.decorators.parameterized_test>`.


.. py:decorator:: reframe.require_deps

.. deprecated:: 3.7.0
Please use the :func:`~reframe.core.pipeline.RegressionMixin.require_deps` built-in function


.. py:decorator:: reframe.required_version

See :func:`@reframe.core.decorators.required_version <reframe.core.decorators.required_version>`.


.. py:decorator:: reframe.run_after

.. deprecated:: 3.7.0
Please use the :func:`~reframe.core.pipeline.RegressionMixin.run_after` built-in function


.. py:decorator:: reframe.run_before

.. deprecated:: 3.7.0
Please use the :func:`~reframe.core.pipeline.RegressionMixin.run_before` built-in function


.. py:decorator:: reframe.simple_test

See :func:`@reframe.core.decorators.simple_test <reframe.core.decorators.simple_test>`.
Expand Down
144 changes: 1 addition & 143 deletions reframe/core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
# Decorators used for the definition of tests
#

__all__ = [
'simple_test', 'required_version',
'require_deps', 'run_before', 'run_after'
]
__all__ = ['simple_test']


import collections
Expand All @@ -19,8 +16,6 @@
import traceback

import reframe.utility.osext as osext
import reframe.core.warnings as warn
import reframe.core.hooks as hooks
from reframe.core.exceptions import (ReframeSyntaxError,
SkipTestError,
user_frame)
Expand Down Expand Up @@ -117,140 +112,3 @@ def simple_test(cls):
_register_test(cls)

return cls


def required_version(*versions):
'''Class decorator for specifying the required ReFrame versions for the
following test.

If the test is not compatible with the current ReFrame version it will be
skipped.

:arg versions: A list of ReFrame version specifications that this test is
allowed to run. A version specification string can have one of the
following formats:

1. ``VERSION``: Specifies a single version.
2. ``{OP}VERSION``, where ``{OP}`` can be any of ``>``, ``>=``, ``<``,
``<=``, ``==`` and ``!=``. For example, the version specification
string ``'>=3.5.0'`` will allow the following test to be loaded only
by ReFrame 3.5.0 and higher. The ``==VERSION`` specification is the
equivalent of ``VERSION``.
3. ``V1..V2``: Specifies a range of versions.

You can specify multiple versions with this decorator, such as
``@required_version('3.5.1', '>=3.5.6')``, in which case the test will be
selected if *any* of the versions is satisfied, even if the versions
specifications are conflicting.

.. versionadded:: 2.13

.. versionchanged:: 3.5.0

Passing ReFrame version numbers that do not comply with the `semantic
versioning <https://semver.org/>`__ specification is deprecated.
Examples of non-compliant version numbers are ``3.5`` and ``3.5-dev0``.
These should be written as ``3.5.0`` and ``3.5.0-dev.0``.

'''
warn.user_deprecation_warning(
"the '@required_version' decorator is deprecated; please set "
"the 'require_version' parameter in the class definition instead",
from_version='3.7.0'
)

if not versions:
raise ValueError('no versions specified')

conditions = [VersionValidator(v) for v in versions]

def _skip_tests(cls):
mod = inspect.getmodule(cls)
if not hasattr(mod, '__rfm_skip_tests'):
mod.__rfm_skip_tests = set()

if not any(c.validate(osext.reframe_version()) for c in conditions):
getlogger().warning(
f"skipping incompatible test '{cls.__qualname__}': not valid "
f"for ReFrame version {osext.reframe_version().split('-')[0]}"
)
mod.__rfm_skip_tests.add(cls)

return cls

return _skip_tests


# Valid pipeline stages that users can specify in the `run_before()` and
# `run_after()` decorators
_USER_PIPELINE_STAGES = (
'init', 'setup', 'compile', 'run', 'sanity', 'performance', 'cleanup'
)


def run_before(stage):
'''Decorator for attaching a test method to a pipeline stage.

.. deprecated:: 3.7.0
Please use the :func:`~reframe.core.pipeline.RegressionMixin.run_before`
built-in function.

'''
warn.user_deprecation_warning(
'using the @rfm.run_before decorator from the rfm module is '
'deprecated; please use the built-in decorator @run_before instead.',
from_version='3.7.0'
)
if stage not in _USER_PIPELINE_STAGES:
raise ValueError(f'invalid pipeline stage specified: {stage!r}')

if stage == 'init':
raise ValueError('pre-init hooks are not allowed')

return hooks.attach_to('pre_' + stage)


def run_after(stage):
'''Decorator for attaching a test method to a pipeline stage.

.. deprecated:: 3.7.0
Please use the :func:`~reframe.core.pipeline.RegressionMixin.run_after`
built-in function.

'''
warn.user_deprecation_warning(
'using the @rfm.run_after decorator from the rfm module is '
'deprecated; please use the built-in decorator @run_after instead.',
from_version='3.7.0'
)
if stage not in _USER_PIPELINE_STAGES:
raise ValueError(f'invalid pipeline stage specified: {stage!r}')

# Map user stage names to the actual pipeline functions if needed
if stage == 'init':
stage = '__init__'
elif stage == 'compile':
stage = 'compile_wait'
elif stage == 'run':
stage = 'run_wait'

return hooks.attach_to('post_' + stage)


def require_deps(fn):
'''Decorator to denote that a function will use the test dependencies.

.. versionadded:: 2.21

.. deprecated:: 3.7.0
Please use the
:func:`~reframe.core.pipeline.RegressionTest.require_deps` built-in
function.

'''
warn.user_deprecation_warning(
'using the @rfm.require_deps decorator from the rfm module is '
'deprecated; please use the built-in decorator @require_deps instead.',
from_version='3.7.0'
)
return hooks.require_deps(fn)
2 changes: 1 addition & 1 deletion reframe/core/launchers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LauncherWrapper(JobLauncher):

.. code:: python

@rfm.run_after('setup')
@run_after('setup')
def set_launcher(self):
self.job.launcher = LauncherWrapper(self.job.launcher, 'ddt',
['--offline'])
Expand Down
Loading