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
Rebot does not preserve order of keywords and messages in output.xml #1867
I would expect the two log files flat-from-orig.html and flat-from-rebot.html be the same. Instead, the order of log messages in flat-from-rebot.html is incorrect.
flat-from-orig.html (as expected):
18:41:36.899 INFO Running Keyword 1
18:41:36.899 INFO Running Keyword 2
18:41:36.900 INFO Running BuiltIn.No Operation
flat-from-rebot.html (unexpected order)
18:41:36.900 INFO Running BuiltIn.No Operation
18:41:36.899 INFO Running Keyword 2
18:41:36.899 INFO Running Keyword 1
I can reproduce the problem. It caused a limitation in Robot's internal result model that also causes other issues. For example, if you look at logs from your execution, inside Keyword 1 you first see Keyword 2 and only then message Running Keyword 1. The message was logged before running Keyword 2 so it should be first.
The limitation in the model is that keywords and messages a keyword has are stored separately. Keywords and messages themselves have an order, but the relative order between keywords and messages is not stored. When keywords and messages are written to a log or to a Rebot generated output.xml, keywords are always written first and messages second. In your case this means that output-orig.xml and output-rebot.xml have messages/keywords in different order.
The main reason that keyword/message order is not stored is that most of the time keywords only contain either keywords or messages and thus such order doesn't matter. Additionally, you typically can understand the log file anyway also in those somewhat rare cases where keywords have both messages and keywords. For example, you didn't complain that the order in log is wrong in both cases. Using --FlattenKeywords removes the keyword structure and thus the problem gets much worse.
This is definitely an issue I'd like to see fixed. The problem I'm not sure what would be the best approach to fix it, and knowing the code I know it's not going to be easy. We also need to be extra careful with performance when modifying code related to XML parsing and log creation.
I prototyped this and keeping the keyword/message order turned out to be doable. I added new children attribute to keywords that returns a list containing keywords and messages in order they have been defined. It was also easy to change Rebot to write output.xml so that it uses this new children attribute. My current prototype code basically fixes the original reported problem. It needs a little clean-up and more tests, but I don't see why I couldn't get it into 2.8.7.
Fixing message/keyword order in logs is a separate task. I briefly looked at it, and it seems to require changes both to log files own Javascript code to Python code that generates the Javascript model used by logs. I'll take a second look at it later, but it will be a topic of a separate issue anyway.
changed the title [-]Rebot changes listener log message order[/-][+]Rebot does not preserve order of keywords and messages in output.xml[/+]on Dec 10, 2014
I see, so the flattening strips the structure first and then writes the log output, that is why the order remains right from the original xml. It is true that the order in the logs is keywords first, then output but in non-flattened log it is not that confusing, not even close. Maybe you could even say it looks intentional. But now that you mentioned it, it is true that it would be nicer to preserve the right order in the non-flattened log as well, but I agree that is a separate issue.
Nice to hear that you were able to find a reasonable resolution for rebot maintaining the order, thanks!
Activity
pekkaklarck commentedon Dec 10, 2014
I can reproduce the problem. It caused a limitation in Robot's internal result model that also causes other issues. For example, if you look at logs from your execution, inside
Keyword 1you first seeKeyword 2and only then messageRunning Keyword 1. The message was logged before runningKeyword 2so it should be first.The limitation in the model is that keywords and messages a keyword has are stored separately. Keywords and messages themselves have an order, but the relative order between keywords and messages is not stored. When keywords and messages are written to a log or to a Rebot generated output.xml, keywords are always written first and messages second. In your case this means that
output-orig.xmlandoutput-rebot.xmlhave messages/keywords in different order.The main reason that keyword/message order is not stored is that most of the time keywords only contain either keywords or messages and thus such order doesn't matter. Additionally, you typically can understand the log file anyway also in those somewhat rare cases where keywords have both messages and keywords. For example, you didn't complain that the order in log is wrong in both cases. Using
--FlattenKeywordsremoves the keyword structure and thus the problem gets much worse.This is definitely an issue I'd like to see fixed. The problem I'm not sure what would be the best approach to fix it, and knowing the code I know it's not going to be easy. We also need to be extra careful with performance when modifying code related to XML parsing and log creation.
pekkaklarck commentedon Dec 10, 2014
I prototyped this and keeping the keyword/message order turned out to be doable. I added new
childrenattribute to keywords that returns a list containing keywords and messages in order they have been defined. It was also easy to change Rebot to write output.xml so that it uses this newchildrenattribute. My current prototype code basically fixes the original reported problem. It needs a little clean-up and more tests, but I don't see why I couldn't get it into 2.8.7.Fixing message/keyword order in logs is a separate task. I briefly looked at it, and it seems to require changes both to log files own Javascript code to Python code that generates the Javascript model used by logs. I'll take a second look at it later, but it will be a topic of a separate issue anyway.
[-]Rebot changes listener log message order[/-][+]Rebot does not preserve order of keywords and messages in output.xml[/+]terokinnunen commentedon Dec 10, 2014
I see, so the flattening strips the structure first and then writes the log output, that is why the order remains right from the original xml. It is true that the order in the logs is keywords first, then output but in non-flattened log it is not that confusing, not even close. Maybe you could even say it looks intentional. But now that you mentioned it, it is true that it would be nicer to preserve the right order in the non-flattened log as well, but I agree that is a separate issue.
Nice to hear that you were able to find a reasonable resolution for rebot maintaining the order, thanks!