diff --git a/docs/config_reference.rst b/docs/config_reference.rst index f4d88c039..184906da9 100644 --- a/docs/config_reference.rst +++ b/docs/config_reference.rst @@ -201,6 +201,7 @@ System Configuration A list of environment variables to be set always when running on this system. These variables modify the ReFrame environment. Each environment variable is specified as a two-element list containing the variable name and its value. + The variable name must be a valid POSIX shell name: it may contain only alphanumeric characters and underscores (``_``) and must not start with a digit. You may reference other environment variables when defining an environment variable here. ReFrame will expand its value. Variables are set after the environment modules are loaded. @@ -699,6 +700,7 @@ System Partition Configuration A list of environment variables to be set before running a regression test on this partition. Each environment variable is specified as a two-element list containing the variable name and its value. + The variable name must be a valid POSIX shell name: it may contain only alphanumeric characters and underscores (``_``) and must not start with a digit. You may reference other environment variables when defining an environment variable here. ReFrame will expand its value. Variables are set after the environment modules are loaded. @@ -875,6 +877,7 @@ ReFrame can launch containerized applications, but you need to configure properl List of environment variables to be set when running containerized tests using this container platform. Each environment variable is specified as a two-element list containing the variable name and its value. + The variable name must be a valid POSIX shell name: it may contain only alphanumeric characters and underscores (``_``) and must not start with a digit. You may reference other environment variables when defining an environment variable here. ReFrame will expand its value. Variables are set after the environment modules are loaded. @@ -1004,6 +1007,7 @@ They are associated with `system partitions <#system-partition-configuration>`__ A list of environment variables to be set when loading this environment. Each environment variable is specified as a two-element list containing the variable name and its value. + The variable name must be a valid POSIX shell name: it may contain only alphanumeric characters and underscores (``_``) and must not start with a digit. You may reference other environment variables when defining an environment variable here. ReFrame will expand its value. Variables are set after the environment modules are loaded. diff --git a/reframe/schemas/config.json b/reframe/schemas/config.json index e6d9e16e1..66ee7b0a4 100644 --- a/reframe/schemas/config.json +++ b/reframe/schemas/config.json @@ -19,8 +19,8 @@ "type": "array", "items": { "type": "array", - "items": [{"$ref": "#/defs/alphanum_ext_string"}], - "additionalProperties": false + "items": [{"$ref": "#/defs/alphanum_string"}, {}], + "additionalItems": false } }, "modules_list": { diff --git a/unittests/test_config.py b/unittests/test_config.py index 35f8744e5..5e4186453 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -150,6 +150,19 @@ def test_validate_config_invalid_syntax(): site_config.validate() +def test_validate_config_env_vars_name(): + # Environment variable names must be POSIX shell names; a name containing + # a `-` must be rejected (see GH #). + site_config = config.load_config('reframe/core/settings.py') + site_config['systems'][0]['env_vars'] = [['FOO_BAR', 1]] + site_config.validate() + + site_config['systems'][0]['env_vars'] = [['FOO-BAR', 1]] + with pytest.raises(ConfigError, + match=r'could not validate configuration file'): + site_config.validate() + + def test_select_subconfig_autodetect(): site_config = config.load_config('reframe/core/settings.py') site_config.select_subconfig()