You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set variable ``VAR`` in all tests or optionally only in test ``TEST`` to ``VAL``.
392
+
393
+
Multiple variables can be set at the same time by passing this option multiple times.
394
+
This option *cannot* change arbitrary test attributes, but only test variables declared with the :attr:`~reframe.core.pipeline.RegressionMixin.variable` built-in.
395
+
If an attempt is made to change an inexistent variable or a test parameter, a warning will be issued.
396
+
397
+
ReFrame will try to convert ``VAL`` to the type of the variable.
398
+
If it does not succeed, a warning will be issued and the variable will not be set.
399
+
``VAL`` can take the special value ``@none`` to denote that the variable must be set to :obj:`None`.
400
+
401
+
Sequence and mapping types can also be set from the command line by using the following syntax:
402
+
403
+
- Sequence types: ``-S seqvar=1,2,3,4``
404
+
- Mapping types: ``-S mapvar=a:1,b:2,c:3``
405
+
406
+
Conversions to arbitrary objects are also supported.
407
+
See :class:`~reframe.utility.typecheck.ConvertibleType` for more details.
408
+
409
+
410
+
The optional ``TEST.`` prefix refers to the test class name, *not* the test name.
411
+
412
+
Variable assignments passed from the command line happen *before* the test is instantiated and is the exact equivalent of assigning a new value to the variable *at the end* of the test class body.
413
+
This has a number of implications that users of this feature should be aware of:
414
+
415
+
- In the following test, :attr:`num_tasks` will have always the value ``1`` regardless of any command-line assignment of the variable :attr:`foo`:
416
+
417
+
.. code-block:: python
418
+
419
+
@rfm.simple_test
420
+
classmy_test(rfm.RegressionTest):
421
+
foo = variable(int, value=1)
422
+
num_tasks = foo
423
+
424
+
- If the variable is set in any pipeline hook, the command line assignment will have an effect until the variable assignment in the pipeline hook is reached.
425
+
The variable will be then overwritten.
426
+
- The `test filtering <#test-filtering>`__ happens *after* a test is instantiated, so the only way to scope a variable assignment is to prefix it with the test class name.
427
+
However, this has some positive side effects:
428
+
429
+
- Passing ``-S valid_systems='*'`` and ``-S valid_prog_environs='*'`` is the equivalent of passing the :option:`--skip-system-check` and :option:`--skip-prgenv-check` options.
430
+
- Users could alter the behavior of tests based on tag values that they pass from the command line, by changing the behavior of a test in a post-init hook based on the value of the :attr:`~reframe.core.pipeline.RegressionTest.tags` attribute.
431
+
- Users could force a test with required variables to run if they set these variables from the command line.
432
+
For example, the following test could only be run if invoked with ``-S num_tasks=<NUM>``:
0 commit comments