You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Programmatically re-running failed tests prevents subsequent Robot and Rebot usage in same process #2437
When we use RobotFramework.main to execute test suites, we get a output.xml result file, then we use RobotFramework.main and the output.xml to rerun the failed cases in the same process, we get the second result file, naming it output_rerun.xml. After that, we use rebot api to merge the output.xml and output_rerun.xml to one result file, naming output_all.xml. We find that output_all.xml just contains the execution result of the failed cases.
So we checked the source code of robotframework, and we found the error code in robot/conf/settings.py:83
We found that code will change the default value of the items of _BaseSettings._cli_opts.
The root cause of this issue is self['TestNames'] and _BaseSettings._cli_opts['TestNames'][1] reference the same list, when execute self['TestNames'] += self['ReRunFailed'], equal to change the value of _BaseSettings._cli_opts['TestNames'][1]
This looks nasty. I want to reproduce this myself before merging the PR. I'll make sure this is included in RF 3.0.1, but it may still take a little time before I have a possibility to concentrate on that release.
I too have had this problem when calling both robot.run and robot.rebot from the same Python program. The attached files demonstrate this problem. Python (version 2.7) script test2.py runs flip.robot which always passes the first test case run and fails the second. The outputs from the first run are out1.xml and log1.html. It then reruns the failed tests in out1.xml producing outputs out2.xml and log2.html. Finally it tries to merge out1.xml and out2.xml into log3.html. However log3.html only contains the result of the rerun tests not all of the tests.
The suggested fix for this bug in robot/conf/settings.py also solves my problem.
Looking at the added unit tests in PR #2438, I noticed there's a similar test added when a similar issue #881 was fixed five years ago. Strange that nobody had encountered this variation earlier.
UPDATE: This problem seems to only occur when using --rerunfailed option. It updates TestNames setting inplace while others seem to replace values altogether. This would explain why nobody has encountered this before at least before --rerunfailed existed. If this is the only option causing the issue, I'll update the title of this issue accordingly.
changed the title [-]Options' default value of RobotSettings and RebotSettings should not be changed when running[/-][+]Programmatically re-running failed tests prevents subsequent Robot and Rebot usage in same process[/+]on Sep 22, 2016
UPDATE: This problem seems to only occur when using --rerunfailed option. It updates TestNames setting inplace while others seem to replace values altogether. This would explain why nobody has encountered this before at least before --rerunfailed existed. If this is the only option causing the issue, I'll update the title of this issue accordingly.
@pekkaklarck Yes, you figure out the root cause. I think it's better to separate the instance's attributes and class's attributes, so I copy the value from class to instance as the PR did rather than just modify the code of updating TestNames
@krizex: I agree it's better to avoid all potential problems with mutable objects rather than just fixing the issue with --rerunfailed updating TestNames. I wanted anyway to change the issue title to match the actual problem.
@krizex: I agree it's better to avoid all potential problems with mutable objects rather than just fixing the issue with --rerunfailed updating TestNames. I wanted anyway to change the issue title to match the actual problem.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Activity
robotframework#2437 Options' default value of RobotSettings and Rebot…
pekkaklarck commentedon Aug 31, 2016
This looks nasty. I want to reproduce this myself before merging the PR. I'll make sure this is included in RF 3.0.1, but it may still take a little time before I have a possibility to concentrate on that release.
krizex commentedon Sep 1, 2016
I have added some UT in the PR, you can use it as a reference for your reproducing.
Direl commentedon Sep 20, 2016
I too have had this problem when calling both robot.run and robot.rebot from the same Python program. The attached files demonstrate this problem. Python (version 2.7) script test2.py runs flip.robot which always passes the first test case run and fails the second. The outputs from the first run are out1.xml and log1.html. It then reruns the failed tests in out1.xml producing outputs out2.xml and log2.html. Finally it tries to merge out1.xml and out2.xml into log3.html. However log3.html only contains the result of the rerun tests not all of the tests.
The suggested fix for this bug in robot/conf/settings.py also solves my problem.
Friday.zip
pekkaklarck commentedon Sep 20, 2016
Seems to be a more common problem. Updated priority accordingly.
pekkaklarck commentedon Sep 22, 2016
Looking at the added unit tests in PR #2438, I noticed there's a similar test added when a similar issue #881 was fixed five years ago. Strange that nobody had encountered this variation earlier.
UPDATE: This problem seems to only occur when using
--rerunfailedoption. It updatesTestNamessetting inplace while others seem to replace values altogether. This would explain why nobody has encountered this before at least before--rerunfailedexisted. If this is the only option causing the issue, I'll update the title of this issue accordingly.Small cleanup and added utest for handling settings between runs.
[-]Options' default value of RobotSettings and RebotSettings should not be changed when running[/-][+]Programmatically re-running failed tests prevents subsequent Robot and Rebot usage in same process[/+]pekkaklarck commentedon Sep 22, 2016
Thanks a lot for the bug report and PR @krizex! The PR was merged as 9f1490e and I did some enhancements to it in c45a051. This issue is done.
krizex commentedon Sep 23, 2016
@pekkaklarck Yes, you figure out the root cause. I think it's better to separate the instance's attributes and class's attributes, so I copy the value from class to instance as the PR did rather than just modify the code of updating
TestNamesThanks for your enhancements.
pekkaklarck commentedon Sep 23, 2016
@krizex: I agree it's better to avoid all potential problems with mutable objects rather than just fixing the issue with
--rerunfailedupdatingTestNames. I wanted anyway to change the issue title to match the actual problem.krizex commentedon Sep 23, 2016
I am agree with you, the title you changed is ok.