modules: no --delim option if separator is colon character (#39010)
Update Tcl modulefile template to simplify generated `append-path`, `prepend-path` and `remove-path` commands and improve their readability. If path element delimiter is colon character, do not set the `--delim` option as it is the default delimiter value.
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							f57c2501a3
						
					
				
				
					commit
					751b64cbcd
				
			@@ -133,9 +133,9 @@ def test_prepend_path_separator(self, modulefile_content, module_configuration):
 | 
				
			|||||||
        module_configuration("module_path_separator")
 | 
					        module_configuration("module_path_separator")
 | 
				
			||||||
        content = modulefile_content("module-path-separator")
 | 
					        content = modulefile_content("module-path-separator")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert len([x for x in content if "append-path --delim {:} COLON {foo}" in x]) == 1
 | 
					        assert len([x for x in content if "append-path COLON {foo}" in x]) == 1
 | 
				
			||||||
        assert len([x for x in content if "prepend-path --delim {:} COLON {foo}" in x]) == 1
 | 
					        assert len([x for x in content if "prepend-path COLON {foo}" in x]) == 1
 | 
				
			||||||
        assert len([x for x in content if "remove-path --delim {:} COLON {foo}" in x]) == 1
 | 
					        assert len([x for x in content if "remove-path COLON {foo}" in x]) == 1
 | 
				
			||||||
        assert len([x for x in content if "append-path --delim {;} SEMICOLON {bar}" in x]) == 1
 | 
					        assert len([x for x in content if "append-path --delim {;} SEMICOLON {bar}" in x]) == 1
 | 
				
			||||||
        assert len([x for x in content if "prepend-path --delim {;} SEMICOLON {bar}" in x]) == 1
 | 
					        assert len([x for x in content if "prepend-path --delim {;} SEMICOLON {bar}" in x]) == 1
 | 
				
			||||||
        assert len([x for x in content if "remove-path --delim {;} SEMICOLON {bar}" in x]) == 1
 | 
					        assert len([x for x in content if "remove-path --delim {;} SEMICOLON {bar}" in x]) == 1
 | 
				
			||||||
@@ -150,37 +150,23 @@ def test_manpath_setup(self, modulefile_content, module_configuration):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # no manpath set by module
 | 
					        # no manpath set by module
 | 
				
			||||||
        content = modulefile_content("mpileaks")
 | 
					        content = modulefile_content("mpileaks")
 | 
				
			||||||
        assert len([x for x in content if "append-path --delim {:} MANPATH {}" in x]) == 0
 | 
					        assert len([x for x in content if "append-path MANPATH {}" in x]) == 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # manpath set by module with prepend-path
 | 
					        # manpath set by module with prepend-path
 | 
				
			||||||
        content = modulefile_content("module-manpath-prepend")
 | 
					        content = modulefile_content("module-manpath-prepend")
 | 
				
			||||||
        assert (
 | 
					        assert len([x for x in content if "prepend-path MANPATH {/path/to/man}" in x]) == 1
 | 
				
			||||||
            len([x for x in content if "prepend-path --delim {:} MANPATH {/path/to/man}" in x])
 | 
					        assert len([x for x in content if "prepend-path MANPATH {/path/to/share/man}" in x]) == 1
 | 
				
			||||||
            == 1
 | 
					        assert len([x for x in content if "append-path MANPATH {}" in x]) == 1
 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
        assert (
 | 
					 | 
				
			||||||
            len(
 | 
					 | 
				
			||||||
                [
 | 
					 | 
				
			||||||
                    x
 | 
					 | 
				
			||||||
                    for x in content
 | 
					 | 
				
			||||||
                    if "prepend-path --delim {:} MANPATH {/path/to/share/man}" in x
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            )
 | 
					 | 
				
			||||||
            == 1
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
        assert len([x for x in content if "append-path --delim {:} MANPATH {}" in x]) == 1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # manpath set by module with append-path
 | 
					        # manpath set by module with append-path
 | 
				
			||||||
        content = modulefile_content("module-manpath-append")
 | 
					        content = modulefile_content("module-manpath-append")
 | 
				
			||||||
        assert (
 | 
					        assert len([x for x in content if "append-path MANPATH {/path/to/man}" in x]) == 1
 | 
				
			||||||
            len([x for x in content if "append-path --delim {:} MANPATH {/path/to/man}" in x]) == 1
 | 
					        assert len([x for x in content if "append-path MANPATH {}" in x]) == 1
 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
        assert len([x for x in content if "append-path --delim {:} MANPATH {}" in x]) == 1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # manpath set by module with setenv
 | 
					        # manpath set by module with setenv
 | 
				
			||||||
        content = modulefile_content("module-manpath-setenv")
 | 
					        content = modulefile_content("module-manpath-setenv")
 | 
				
			||||||
        assert len([x for x in content if "setenv MANPATH {/path/to/man}" in x]) == 1
 | 
					        assert len([x for x in content if "setenv MANPATH {/path/to/man}" in x]) == 1
 | 
				
			||||||
        assert len([x for x in content if "append-path --delim {:} MANPATH {}" in x]) == 0
 | 
					        assert len([x for x in content if "append-path MANPATH {}" in x]) == 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @pytest.mark.regression("29578")
 | 
					    @pytest.mark.regression("29578")
 | 
				
			||||||
    def test_setenv_raw_value(self, modulefile_content, module_configuration):
 | 
					    def test_setenv_raw_value(self, modulefile_content, module_configuration):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,11 +54,23 @@ conflict {{ name }}
 | 
				
			|||||||
{% block environment %}
 | 
					{% block environment %}
 | 
				
			||||||
{% for command_name, cmd in environment_modifications %}
 | 
					{% for command_name, cmd in environment_modifications %}
 | 
				
			||||||
{% if command_name == 'PrependPath' %}
 | 
					{% if command_name == 'PrependPath' %}
 | 
				
			||||||
 | 
					{% if cmd.separator == ':' %}
 | 
				
			||||||
 | 
					prepend-path {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
 | 
					{% else %}
 | 
				
			||||||
prepend-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
					prepend-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
{% elif command_name in ('AppendPath', 'AppendFlagsEnv') %}
 | 
					{% elif command_name in ('AppendPath', 'AppendFlagsEnv') %}
 | 
				
			||||||
 | 
					{% if cmd.separator == ':' %}
 | 
				
			||||||
 | 
					append-path {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
 | 
					{% else %}
 | 
				
			||||||
append-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
					append-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
{% elif command_name in ('RemovePath', 'RemoveFlagsEnv') %}
 | 
					{% elif command_name in ('RemovePath', 'RemoveFlagsEnv') %}
 | 
				
			||||||
 | 
					{% if cmd.separator == ':' %}
 | 
				
			||||||
 | 
					remove-path {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
 | 
					{% else %}
 | 
				
			||||||
remove-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
					remove-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
{% elif command_name == 'SetEnv' %}
 | 
					{% elif command_name == 'SetEnv' %}
 | 
				
			||||||
setenv {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
					setenv {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
 | 
				
			||||||
{% elif command_name == 'UnsetEnv' %}
 | 
					{% elif command_name == 'UnsetEnv' %}
 | 
				
			||||||
@@ -68,7 +80,7 @@ unsetenv {{ cmd.name }}
 | 
				
			|||||||
{% endfor %}
 | 
					{% endfor %}
 | 
				
			||||||
{# Make sure system man pages are enabled by appending trailing delimiter to MANPATH #}
 | 
					{# Make sure system man pages are enabled by appending trailing delimiter to MANPATH #}
 | 
				
			||||||
{% if has_manpath_modifications %}
 | 
					{% if has_manpath_modifications %}
 | 
				
			||||||
append-path --delim {{ '{' }}:{{ '}' }} MANPATH {{ '{' }}{{ '}' }}
 | 
					append-path MANPATH {{ '{' }}{{ '}' }}
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user