-
Notifications
You must be signed in to change notification settings - Fork 32
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
Removing the escape sequence from the console outputs! #141
base: main
Are you sure you want to change the base?
Conversation
Testcases fail as the output is having escape sequence in it which is not expected to be there. Removing this escape sequence fixes almost 2000+ testcases. Signed-off-by: Anushree Mathur <[email protected]>
efore applying the patch i tried to print the outputs in between and found out the escape sequence issue.Many testcases were getting failed, 1 of the example is as follows:
After applying the patch, testcases are getting passed:
Last element of the list gets used after removing the escape sequence. This is necessary to check for the the proper login.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Anushree-Mathur, this change makes sense to me as in get_last_non_empty_line
we do expect console output which might be corrupted by console codes. My only concern is whether we shouldn't strip the full output as the current version might result in ""
output (when last nonempty line contains only escape code, it'll be identified as non-empty and then stripped).
I think I need an extra pair of eyes on this as it might affect the behaviour @smitterl or @pevogam can you please take a look at this?
Hello @ldoktor, thanks alot for taking time and reviewing this commit! The much I have understood, IMO the output will surely be something with the escape sequence but if it is only containing escape sequence and stripping this comes as empty ouput, maybe that was expected? The output that is coming in the console and the way it is getting read, those are different! So it will take the output only until the last nonempty output that is correct according to the console but the escape code gets added in a way it gets read. Please correct me if i am wrong. Thanks in advance! |
I'm talking about situation like this |
Hi, I will be able to test and review this towards the end of the week, I hope this is ok and thanks for the contribution! |
Thanks @pevogam. Btw it'd be nice to include a selftest. One example I tried was to create a file:
And then run >>> import aexpect
>>> a=aexpect.ShellSession("bash -c 'cat /tmp/test; sleep 10'")
>>> a.read_up_to_prompt()
'foo\nbar\n[user@computer ~ ]$ \n\x1b[0;31m\x1b[0m\n'
>>> a.read_up_to_prompt()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/medic/Work/Projekty/avocado/aexpect/aexpect/client.py", line 1186, in read_up_to_prompt
return self.read_until_last_line_matches([self.prompt], timeout,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/medic/Work/Projekty/avocado/aexpect/aexpect/client.py", line 1002, in read_until_last_line_matches
return self.read_until_output_matches(patterns,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/medic/Work/Projekty/avocado/aexpect/aexpect/client.py", line 940, in read_until_output_matches
raise ExpectProcessTerminatedError(patterns, self.get_status(),
aexpect.exceptions.ExpectProcessTerminatedError: Process terminated while looking for pattern '[\\#\\$]\\s*$' (status: 0, output: '') Also while looking at this we might want to improve the |
Thank you so much @pevogam @ldoktor for your time! I am getting your point now @ldoktor, I am also looking into this, will get back to you on this by tomorrow. Thank you for the clarification. But still I have 1 doubt, in my case the output is getting stripped at first and then it is returning only the last element of the list after removing the escape sequence! For example: It is getting stripped as a list as Then the value that the code is returning is the last output without the escape sequence that is This function itself means that it is returning only the last element of the list. I apologize for multiple questions, but just reclarifying the things! Thanks in advance for your time! |
I'm not sure I follow, can you please elaborate a bit more? The function you're modifying is inside a filter function My proposal was about another potential situation, where the console spits additional content after the last line which would again contain only control characters (eg. |
Hi @ldoktor, now I totally got your point. Before I got confused that maybe my code is doing something wrong! I can edit the code in such a way that it checks whether a last output contains only escape characters or control characters and if it is empty then it will return as the output as |
Testcases fail as the output is having escape sequence in it which is not expected to be there.Removing this escape sequence fixes almost 2000+ testcases.
Signed-off-by: Anushree Mathur [email protected]