ros2cli icon indicating copy to clipboard operation
ros2cli copied to clipboard

ros2cli tests don't verify output stream

Open rotu opened this issue 5 years ago • 4 comments

ros2cli tests don't verify which stream output comes out on (stdout vs stderr).

These tests should confirm that the expected output does indeed come out via the expected stream, instead of munging together stdout and stderr.

See related #482, which may be wholly or partially attributed to this issue.

rotu avatar Apr 13 '20 18:04 rotu

I would think it is very unlikely that the combined output is actually equal to the expected output but it was printed via the "wrong" stream. At least I have never seen a false positive like this.

Do you have any specific use case where this is actually problematic?

Assuming there is none I will mark this as an enhancement for the backlog. Please consider to contribute a pull request for this.

dirk-thomas avatar Apr 13 '20 23:04 dirk-thomas

There is a great example here https://github.com/ros2/ros2cli/blob/bf4941afd06064d20914c19687a8ca98186687e6/ros2lifecycle/ros2lifecycle/verb/set.py#L86-L89

This utility logs a successful transition to stdout but an unsuccessful one to stderr. So if you're piping the output of the utility, you'll likely get an incomplete view of what's happening, and you may get log messages confusingly out of order.

rotu avatar Apr 13 '20 23:04 rotu

I would suggest to contribute a pull request to update that specific test then.

dirk-thomas avatar Apr 14 '20 00:04 dirk-thomas

And the tests as well to verify tool sanity! I'm sure there are other examples as well across this repo, and it would be a great use case for TDD.

That said, my bosses have requested I go on fewer development tangents, so I'm not likely to write the PR myself.

rotu avatar Apr 14 '20 01:04 rotu