Skip to content

Document limitations with embedded arguments utilizing custom regexps with variables #5396

@pekkaklarck

Description

@pekkaklarck

Keywords with embedded arguments utilizing custom regexps can be used with variables, but only if the variable is used on its own. If there are multiple variables or a variable and some other content, usage fails. These examples demonstrate the issue:

*** Variables ***
${HI}       hi
${H}        h

*** Test Cases ***
Passes
    Robot says "hi"!
    Robot says "${HI}"!

Multiple variables fails
    Robot says "${HI}${EMPTY}"!

Variable with other content fails
    Robot says "${H}i"!

*** Keywords ***
Robot says "${greeting:hi}"!
    Should Be Equal    ${greeting}    hi

The reason for the failure is that the custom pattern hi doesn't match ${HI}${EMPTY} or ${H}i. It obviously doesn't match ${HI} either, but the custom regexp handling code automatically handles variables used on their own. That logic has a bug that it doesn't work with the inline evaluation syntax (#5394) and the root cause for that bug is the same that causes this issue.

The inline evaluation issue (#5394) can be fixed like this:

  • Replace variables in the calling keyword with a placeholder before matching the regexp.
  • Keep a mapping between placeholders and original variables.
  • Append the custom regexp with a pattern matching the placeholder.
  • Replace placeholders with original variables after the regexp match.

Unfortunately the above doesn't fix this issue, because the extra content in addition to the single variable means that pattern appended in the second last step doesn't match the whole value. Because I don't see any simple ways to fix this, and because nobody has reported this issue earlier, I believe it is enough to document this limitation. If it turns out to create concrete problems, we can return to this later.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions