Skip to content

Generalized variable substitution for LoopExecutor#145

Merged
whotwagner merged 3 commits intoait-testbed:developmentfrom
annaerdi:development
Feb 7, 2025
Merged

Generalized variable substitution for LoopExecutor#145
whotwagner merged 3 commits intoait-testbed:developmentfrom
annaerdi:development

Conversation

@annaerdi
Copy link
Contributor

Previously, the LoopExecutor only substituted variables in the cmd field. This was insufficient for commands with additional attributes, which may also contain placeholders.

This PR enhances the LoopExecutor to support generalized variable substitution for all string attributes in commands.

Units tests were written with the help of the sleep command to make sure it works with its seconds field. It was also successfully tested with the incoming browser executor. To manually test it with the sleep command, here is an example playbook:

vars:
  LISTA:
    - 1
    - 2
    - 3
    - 4
    - 5

commands:
  - type: loop
    cmd: "range(0,5)"
    commands:
      - type: sleep
        seconds: $LOOP_INDEX
  - type: loop
    cmd: "items(LISTA)"
    commands:
      - type: sleep
        seconds: $LOOP_ITEM

Co-authored-by: Thorina Boenke <68156005+thorinaboenke@users.noreply.github.com>
@thorinaboenke thorinaboenke self-requested a review February 7, 2025 09:55
@whotwagner whotwagner merged commit f56aab8 into ait-testbed:development Feb 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants