Esempio n. 1
0
def sanity_function(func):
    warn.user_deprecation_warning(
        'using the @sn.sanity_function decorator from the sn module is '
        'deprecated; please use the built-in decorator @deferrable instead.',
        from_version='3.8.0'
    )
    return deferrable(func)
Esempio n. 2
0
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 ReframeSyntaxError(
            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)
Esempio n. 3
0
def parse(version_str):
    '''Compatibility function to normalize version strings from prior
    ReFrame versions

    :returns: a :class:`semver.VersionInfo` object.
    '''

    compat = False
    old_style_stable = re.search(r'^(\d+)\.(\d+)$', version_str)
    old_style_dev = re.search(r'(\d+)\.(\d+)((\d+))?-dev(\d+)$', version_str)
    if old_style_stable:
        compat = True
        major = old_style_stable.group(1)
        minor = old_style_stable.group(2)
        ret = semver.VersionInfo(major, minor, 0)
    elif old_style_dev:
        compat = True
        major = old_style_dev.group(1)
        minor = old_style_dev.group(2)
        patchlevel = old_style_dev.group(4) or 0
        prerelease = old_style_dev.group(5)
        ret = semver.VersionInfo(major, minor, patchlevel, f'dev.{prerelease}')
    else:
        ret = semver.VersionInfo.parse(version_str)

    if compat:
        user_deprecation_warning(
            f"the version string {version_str!r} is deprecated; "
            f"please use the conformant '{ret}'",
            from_version='3.5.0')

    return ret
Esempio n. 4
0
    def launcher(self):
        '''See :attr:`launcher_type`.

        .. deprecated:: 3.2
           Please use :attr:`launcher_type` instead.
        '''

        from reframe.core.warnings import user_deprecation_warning

        user_deprecation_warning("the 'launcher' attribute is deprecated; "
                                 "please use 'launcher_type' instead")
        return self.launcher_type
Esempio n. 5
0
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)
Esempio n. 6
0
def parameterized_test(*inst):
    '''Class decorator for registering multiple instantiations of a test class.

   The decorated class must derive from
   :class:`reframe.core.pipeline.RegressionTest`. This decorator is also
   available directly under the :mod:`reframe` module.

   :arg inst: The different instantiations of the test. Each instantiation
        argument may be either a sequence or a mapping.

   .. versionadded:: 2.13

   .. note::
      This decorator does not instantiate any test.  It only registers them.
      The actual instantiation happens during the loading phase of the test.

   .. deprecated:: 3.6.0

      Please use the :func:`~reframe.core.pipeline.RegressionTest.parameter`
      built-in instead.

    '''

    warn.user_deprecation_warning(
        'the @parameterized_test decorator is deprecated; '
        'please use the parameter() built-in instead',
        from_version='3.6.0'
    )

    def _do_register(cls):
        if _validate_test(cls):
            if not cls.param_space.is_empty():
                raise ReframeSyntaxError(
                    f'{cls.__qualname__!r} is already a parameterized test'
                )

            for args in inst:
                _register_parameterized_test(cls, args)

        return cls

    return _do_register
Esempio n. 7
0
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 ReframeSyntaxError(
            f'invalid pipeline stage specified: {stage!r}')

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

    return hooks.attach_to('pre_' + stage)
Esempio n. 8
0
def test_suppress_deprecations():
    with warn.suppress_deprecations():
        warn.user_deprecation_warning('warning 1')

    with pytest.warns(warn.ReframeDeprecationWarning):
        warn.user_deprecation_warning('warning 2')
Esempio n. 9
0
def test_deprecation_warning_from_version():
    next_version = semver.VersionInfo.parse(reframe.VERSION).bump_minor()
    warn.user_deprecation_warning('deprecated', str(next_version))
Esempio n. 10
0
def test_deprecation_warning():
    with pytest.warns(warn.ReframeDeprecationWarning):
        warn.user_deprecation_warning('deprecated')
Esempio n. 11
0
    def __get__(self, obj, objtype):
        if self._op & DeprecatedField.OP_GET:
            user_deprecation_warning(self._message, self._from_version)

        return self._target_field.__get__(obj, objtype)
Esempio n. 12
0
    def __set__(self, obj, value):
        if self._op & DeprecatedField.OP_SET:
            user_deprecation_warning(self._message, self._from_version)

        self._target_field.__set__(obj, value)
Esempio n. 13
0
def test_deprecation_warning_from_version():
    version = semver.VersionInfo.parse(reframe.VERSION).bump_minor()
    with warnings.catch_warnings(record=True) as w:
        warn.user_deprecation_warning('deprecated', str(version))
        assert len(w) == 0
Esempio n. 14
0
def test_deprecation_warning_from_prerelease_version(monkeypatch):
    monkeypatch.setattr(reframe, 'VERSION', '1.0.0-dev.0')
    with pytest.warns(warn.ReframeDeprecationWarning):
        warn.user_deprecation_warning('deprecated', '1.0.0')
Esempio n. 15
0
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``.

    .. deprecated:: 3.5.0
       Please set the ``require_version`` parameter in the class definition
       instead.

    '''
    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 ReframeSyntaxError('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 hasattr(mod, '_rfm_test_registry'):
            mod._rfm_test_registry = TestRegistry()

        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]}"
            )
            if cls in mod._rfm_test_registry:
                mod._rfm_test_registry.skip(cls)
            else:
                mod.__rfm_skip_tests.add(cls)

        return cls

    return _skip_tests
Esempio n. 16
0
 def _check_deprecation(self, kind):
     if isinstance(self.field, fields.DeprecatedField):
         if self.field.op & kind:
             user_deprecation_warning(self.field.message)
Esempio n. 17
0
 def deprecation_warning(self):
     user_deprecation_warning('feature foo is deprecated')