SofaDefrost / sofa

SOFA, open source framework for multi-physics simulation.
https://www.sofa-framework.org
13 stars 6 forks source link

Test of expected failures in file opening triggering error messages #15

Closed flargilliere closed 7 years ago

flargilliere commented 7 years ago

Several tests of opening absent or corrupted files trigger RED messages of error.

This is desired for the normal usage.

However, I think that, as these failures are expected in a proper functioning of the tests, we should disable these messages to keep a not-red report when everything work as expected.

I was thinking about something like redirecting the stream cerr (and friends) temporarly but let's discuss this matter to find the best/fastest solution.

damienmarchal commented 7 years ago

Hi Fred,

Thank Fred, this is a point that on which I hesitated a lot and you are right that the red color in the successful reports are confusing.

But no we shouldn't disable the messages when we are in tests. Messages are part of the expected behavior of the component and some tests are event testing that the message are correctly emitted with the ExpectMessage and MessageAsTestFailure.

Instead we should disable their printing in red (or their printing at all but I personally find very useful to have the message printed when the test fail because this help in locating the problem).

The best is probably to change the code in the DefaultStyleMessageFormatter to add a boolean to control the printing into a non colorized version of the messages. If you do so...please do a PR to Sofa ;)

And stop using (cerr) the msg_* API is your friend: https://www.sofa-framework.org/community/doc/programming-with-sofa/logger/

DM

flargilliere commented 7 years ago

Well, the cerr were there without my intervention so I'm totally ok for switching to something else/smarter. I was not thinking about disabling them but rather redirecting cerr to a not-printed-as-error stream before the call to function expected to print an error then rerouting cerr to its default behavior.

But all in all, the "modify internally the message logger color" seems legit to me. Will have a look at that (and maybe will have some cerr to msg_ frenzy) when possible.