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

Add option to filter output #3

Open
biffen opened this issue Jan 8, 2017 · 6 comments
Open

Add option to filter output #3

biffen opened this issue Jan 8, 2017 · 6 comments
Milestone

Comments

@biffen
Copy link
Member

biffen commented Jan 8, 2017

I.e. --quiet/-q to reduce the output to just the ‘bad’ stuff (failed tests and their details).

This would produce invalid TAP, but it would mainly be meant for human consumption.

@biffen biffen added this to the v3.1.0 milestone Jan 8, 2017
@ghost
Copy link

ghost commented Mar 17, 2017

Filtering out printfs from the code itself would be great, also. Great library by the way, thanks for making it.

@biffen
Copy link
Member Author

biffen commented Mar 25, 2017

@bright-star Thanks for the kind words.

I'm afraid, however, I don't quite understand your request. Could you clarify what you mean?

@ghost
Copy link

ghost commented Mar 26, 2017

If some portion of the code under test prints to the std streams, the test output will mix those in with the TAP results. I don't use any TAP readers, but the visual noise can be significant. I'm not sure if this is possible with C++ or not, but suppressing output from anything that isn't BugEye's entry point itself would solve this.

For an example, here is the repo I was trying BugEye out with. If you run make check you can see warning messages from the library in the test output.

@biffen
Copy link
Member Author

biffen commented Mar 27, 2017

I don't know of a good way of doing that. The only thing I can think of would use preprocessor hackery, and I definitely don't want to do that in a library.

There are two other ways:

  1. You could wrap your printing in #ifndef TEST#endif.

  2. You could stop printing directly to STDOUT in your code: Use some form of logging instead, and turn it off when testing.

Frankly I find the latter to be the better option, as I as a user of your library wouldn't want it to uncontrollably print things. It's not a very Nice Thing™ to do.

@ghost
Copy link

ghost commented Mar 27, 2017

That's true.

@biffen
Copy link
Member Author

biffen commented Apr 18, 2017

For clarification, both to @bright-star and to anyone coming across this conversation:

I realise my previous comment may be perceived as a ‘my code is perfect, it's you who should change’ type comment. That is most certainly not the intention.

The idea of disabling printing to STDOUT (and STDERR) by any code other that of BugEye itself is an interesting one. I would like to be able to implement it, but it would have to be a good implementation; one that doesn't interfere and preferably doesn't use any preprocessor hackery.

That being said, I do (personally) think that code that should be unit tested shouldn't ordinarily print anything, or at least be easily configurable not to. This is especially true for library code: I as a library user would expect to be in charge of what gets printed, and I'd be surprised if a call to a library function had such side effects.

This doesn't, however, invalidate the feature request. It may be implemented in the future (although not under this particular issue).

In summary

  • The feature request is of interest,
  • but not part of this issue.
  • There's a well-defined (and documented) workaround, albeit a somewhat intrusive one.
  • It is not for BugEye or myself to say how the tested code ‘should’ behave,
  • but in this case I believe a ‘fix’ would also improve the overall quality of the code in question.

The general attitude of BugEye is one of accommodation and adaptation. If it doesn't work well with a particular piece of code let us know and we shall try to solve it.

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

1 participant