Skip to content

Commit a55e84d

Browse files
author
Vasileios Karakasis
committed
Allow variables to be set on fixtures from the command line
1 parent 6e4a0e2 commit a55e84d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

reframe/core/meta.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,17 @@ def setvar(cls, name, value):
535535
536536
'''
537537

538+
if '.' in name:
539+
# `name` refers to a fixture variable
540+
fixtname, varname = name.split('.', maxsplit=1)
541+
try:
542+
fixt_space = super().__getattribute__('_rfm_fixture_space')
543+
except AttributeError:
544+
'''Catch early access attempt to the variable space.'''
545+
546+
if fixtname in fixt_space:
547+
return fixt_space[fixtname].cls.setvar(varname, value)
548+
538549
try:
539550
var_space = super().__getattribute__('_rfm_var_space')
540551
if name in var_space:

reframe/core/variables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def __getattr__(self, name):
281281
def _check_is_defined(self):
282282
if not self.is_defined():
283283
raise ReframeSyntaxError(
284-
f'variable {self._name} is not assigned a value'
284+
f'variable {self._name!r} is not assigned a value'
285285
)
286286

287287
def __repr__(self):

unittests/test_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ def test_external_vars(run_reframe):
845845
'-S', 'foolist=3,4',
846846
'-S', 'bar=@none']
847847
)
848+
assert 'PASSED' in stdout
849+
assert 'Ran 6/6 test case(s)' in stdout
848850
assert 'Traceback' not in stdout
849-
assert 'Ran 2/2 test case(s)' in stdout
850851
assert 'Traceback' not in stderr
851852
assert returncode == 0
852853

0 commit comments

Comments
 (0)