Skip to content

set_var_default() still sets the variable even if it's set just before it #3049

@vkarak

Description

@vkarak

The following test reproduces it:

import reframe as rfm
import reframe.utility.sanity as sn


@rfm.simple_test
class buggy_test(rfm.RunOnlyRegressionTest):
    valid_prog_environs = ['*']
    valid_systems = ['*']
    executable = 'echo'
    x = variable(str)

    @sanity_function
    def validate(self):
        return sn.assert_found(r'value', self.stdout)

    @run_before('run')
    def set_arg(self):
        self.x = 'value'
        self.set_var_default('x', 'default')
        self.executable_opts = [self.x]

The problem comes from here:

https://github.com/reframe-hpc/reframe/blob/develop/reframe/core/pipeline.py#L1372

This check only checks if the variable was defined with a default value and does not cover the case when it was assigned a value after the test's instantiation. The check should be instead hasattr(self, var_name).

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions