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

rosunit should allow simultaneous XML output and text output #110

Closed
v-lopez opened this issue Mar 15, 2016 · 10 comments
Closed

rosunit should allow simultaneous XML output and text output #110

v-lopez opened this issue Mar 15, 2016 · 10 comments

Comments

@v-lopez
Copy link

v-lopez commented Mar 15, 2016

Right now we are executing unit tests using make test in our buildfarm.

Fixing an unexpected failure or a crash on a unit test in the buildfarm is an almost impossible task since we have no logs and the XML output only reports a crash and zero useful logs.

Example of XML output on the case of a crash:

test [serial_driver_test] did not generate test results
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/runner.py", line 164, in fn
self.assert_(os.path.isfile(test_file), "test [%s] did not generate test results"%test_name)
File "/usr/lib/python2.7/unittest/case.py", line 424, in assertTrue
raise self.failureException(msg)

It would be very helpful to have alll std output as part of the XML report, if it cannot be made visible in the terminal running the tests.

@dirk-thomas
Copy link
Member

Please consider to contribute a pull request implementing this feature.

@dirk-thomas dirk-thomas added this to the untargeted milestone Jun 27, 2016
@talhaHavadar
Copy link

is there any development going on about this issue?

@v-lopez
Copy link
Author

v-lopez commented Nov 28, 2017

Not yet from our side.

We haven't discarded doing it, but it's not on our sights yet.

@talhaHavadar
Copy link

Then I can start implementation of it if it is ok for you

@v-lopez
Copy link
Author

v-lopez commented Nov 29, 2017

Sure, if you want a tester just let me know.

@talhaHavadar
Copy link

I changed the super class of _XMLTestResult from 'unittest.TestResult' to 'unittest.TextTestResult'. And also updated the functions like 'startTest', 'stopTest', 'addError' etc. With this change we can write the output to the stdout while creating the xml. I need to do some spot checks to be sure it is working correctly then I will open a PR for this changes.

@v-lopez
Copy link
Author

v-lopez commented Feb 28, 2018

I've been looking further into this issue. I've created this repo with examples of different ways of running tests:
https://github.com/pal-robotics/ros_testing_experiments

With the kinetic-devel branch, I'm not seeing a uniform behaviour with regards to the handling of the log output of the tests:

I am testing four cases, the bold text is the name I'll use:
cpp_test: C++ gtest
cpp_rostest: C++ gtest executed within rostest
py_test: Python test
py_rostest: Python test executed within rostest

Running the tests with make run_tests I have the following behaviour:

test stdout stderr log info log warn log error
cpp_test terminal terminal terminal terminal terminal
py_test - terminal - - -
cpp_rostest ~/.ros/log terminal ~/.ros/log ~/.ros/log terminal
py_rostest rosunit xml rosunit xml rosunit xml rosunit xml rosunit xml
cpp_rostest --text terminal terminal terminal terminal terminal
py_rostest --text terminal terminal terminal terminal terminal

The - indicates that the logs could not be found.

With @talhaHavadar changes I see the same behaviour, but the generated XML are invalid (that was the cause of the test failure in #163).

@dirk-thomas Do you know if this is the actual behaviour or am I doing something wrong?
What would be the desired behaviour, and if I fixed it would it make it to kinetic?

From my understanding, at least cpp_rostest and py_rostest should have the same behaviour, and log onto the rosunit (or maybe rostest?) xml file. Regardless of what was requested in this issue.

And cpp_test and py_test should log everything to the terminal.

Finally, what was requested from this issue, it would be that cpp_rostest and py_rostest also logged to the terminal while still creating an xml with the result for parsers such as jenkins.

@v-lopez
Copy link
Author

v-lopez commented Feb 28, 2018

With some modifications I have the following behavior, on bold the behaviours that have changed.

The changes:
https://github.com/ros/ros_comm/compare/kinetic-devel...pal-robotics-forks:rostest-screen-output?expand=1
https://github.com/ros/ros/compare/kinetic-devel...pal-robotics:tee-test-output?expand=1

test stdout stderr log info log warn log error
cpp_test terminal terminal terminal terminal terminal
py_test terminal1 terminal1 terminal1 terminal1 terminal1
cpp_rostest terminal terminal terminal terminal terminal
py_rostest terminal1 & rosunit xml terminal1 & rosunit xml terminal1 & rosunit xml terminal1 & rosunit xml terminal1 & rosunit xml
cpp_rostest --text terminal terminal terminal terminal terminal
py_rostest --text terminal terminal terminal terminal terminal

1 The logs have no color, probably related to the py logging macros, haven't looked into it.

While keeping test result output to XML for jenkins.
These changes would satisfy what was requested in this issue.

I see three drawbacks to these fixes:

1. cpp rostests no longer write to log file
I would say that the previous behaviour was not consistent, and difficult to use reliably since a rostest could be writing to 3 different places.

2. Logs colors are missing for python tests
Probably this can be fixed if there's an interest into these changes.

3. Tests are now more verbose
It's true

@progtologist
Copy link

Are you planning of making a PR with those changes?

@dirk-thomas
Copy link
Member

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants