Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should not do mutating variable resolution #2

Closed
DirkRichter opened this issue Jul 8, 2021 · 8 comments
Closed

Should not do mutating variable resolution #2

DirkRichter opened this issue Jul 8, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@DirkRichter
Copy link

Using parameter --listener RobotStackTracer in regular robot run results in different test result (pass vs fail):

running robot Test.robot
grafik

running robot --listener RobotStackTracer Test.robot
grafik

This --listener RobotStackTracer is now used in latest pabot version and i wonder, why my tests fail with pabot but pass in robot.

Versions:
Windows 10
python 3.9.6
robotframework-pabot 2.0.0
robotframework 4.0.3

@mkorpela
Copy link
Member

mkorpela commented Jul 8, 2021

Thanks @DirkRichter !

@mkorpela mkorpela added the bug Something isn't working label Jul 8, 2021
@mkorpela mkorpela changed the title RobotStackTracer results in different robot test result Should not do mutating variable resolution Jul 8, 2021
@pekkaklarck
Copy link

Is variable resolution needed in general? I'm afraid detecting does resolving a variable do something that shouldn't be done is pretty much impossible. For example, ${var.attr} can call a property that does something that should only be done once.

@mkorpela
Copy link
Member

mkorpela commented Jul 8, 2021

I think there is value in it, but resolving that allows code execution should not happen or happen only after a failure.

@DirkRichter
Copy link
Author

Thx. Now i understand, why ${d.pop('x')} results in KeyError. When key 'x' is removed from ${d} inside RobotStackTracer, then real robot can not find key 'x'.

Thus in general a robot listener should always be side-effect-free (https://dev.to/dev0928/what-is-a-side-effect-of-a-function-in-python-36ei).
Pure functional listeners could ensure this e.g. via https://pypi.org/project/effect/. Unfortunately writing such listeners would become much more complex.

@pekkaklarck
Copy link

Yeah, the problem is that ${d.pop('x')} modifies d and that affects execution later. I agree listeners shouldn't have side-effects and in general thus shouldn't resolve variables. I would also say that variable usages shouldn't have side-effects so ${d.pop('x')} is questionable. Using a keyword to pop the value would be better.

@mkorpela
Copy link
Member

@Snooz82 I put a PR for this. #3

Seems that your the only one with PyPI deployment keys, so can not deploy.

@mkorpela
Copy link
Member

It might be good also to remove variable resolution from higher calls in the stack.
Original solution took the value at the time of start_kw (this is good) but has side-effects that can impact the execution.
Proposed change in PR works only in end_kw in case of a failure, but this might have values that are not anymore correct for higher calls in the stack.

@mkorpela
Copy link
Member

Fixed in next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants