Skip to content

Commit

Permalink
Update tests and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasjacobsen committed Dec 12, 2024
1 parent 16ddfbf commit 7a31d6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ramble/docs/workspace_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,14 @@ Supported functions are:
* ``randint`` (from `random.randint`)
* ``re_search(regex, str)`` (determine if ``str`` contains pattern ``regex``, based on ``re.search``)

Additionally, string slicing is supported:
String slicing is supported:

* ``str[start:end:step]`` (string slicing)

Dictionary references are supported:

* ``dict_name["key"]`` (dictionary subscript)

.. _ramble-escaped-variables:

~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 4 additions & 0 deletions lib/ramble/ramble/test/expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def exp_dict():
"size": '"0000.96"', # Escaped as a string
"test_mask": '"0x0"',
"max_len": 9,
"test_dict": {"test_key1": "test_val1", "test_key2": "test_val2"},
}


Expand Down Expand Up @@ -85,6 +86,9 @@ def exp_dict():
('"{env_name}"[:{max_len}:1]', "spack_foo", set(), 1),
("not_a_slice[0]", "not_a_slice[0]", set(), 1),
("not_a_valid_slice[0:a]", "not_a_valid_slice[0:a]", set(), 1),
("{test_dict}", "{'test_key1': 'test_val1', 'test_key2': 'test_val2'}", set(), 1),
("{test_dict['test_key1']}", "test_val1", set(), 1),
("{test_dict['test_key2']}", "test_val2", set(), 1),
],
)
def test_expansions(input, output, no_expand_vars, passes):
Expand Down

0 comments on commit 7a31d6f

Please sign in to comment.