mkorpela/RoboMachine

Order of rules matter

Closed this issue · 5 comments

I was under the impression that the order of the rules didn't matter. Apparently not. At least if the rules somewhat intersect.

Try swapping the two constraints below and watch how the generated file contains one more/less test.

*** Machine ***
${NAME}    any of    Adam    Peter
${LAST_NAME}    any of    Smith    Brown    Johnson

${LAST_NAME} == Smith  ==>  ${NAME} == Adam
${NAME} == Peter  ==>  ${LAST_NAME} == Brown

Data driven
    Test Driver

*** Keywords ***
Test Driver
    Log To Console    \n${NAME} ${LAST_NAME}

It turns out that only the first rule is used(!). @mkorpela: Can you confirm this? Just to eliminate my system from the equation (having different environment etc.).

After running the code with some debug printouts from pyparsing, it seems that the parser picks up everything as it should, and converts the text into a proper list of *Rule objects. But for some reason, the only rule that "sticks" (gets into the RoboMachine constructor) is the first rule.

Since I couldn't figure out how to properly fix this, I added a workaround: iterate over all matches and build the rules list from objects that are *Rule instances.

I'll send a pull request soon.

Thanks!

@mkorpela: Can you confirm that this issue is real?

See #16. That pull also includes some other stuff. Let me know if you want it split.

#16 was merged, so this can be closed (although the fix is a bit of a hack). Thanks!