JuliaAttic / FactCheck.jl

Midje-like testing for Julia
Other
81 stars 36 forks source link

swallowing stdout #21

Open ssfrr opened 10 years ago

ssfrr commented 10 years ago

When testing code that prints to stdout, the output gets interleaved with the test status output.

In at least one of the python test runners the runner swallows stdout and only displays it on a test failure. If the tests are passing you can assume the user doesn't really care what got printed.

Not sure how exactly to implement this, but I wanted to feel out whether it would be considered a desired feature.

zachallaun commented 10 years ago

I'm not a fan of this as a default (I believe it leads to confusing behavior if you're not expecting it), but I'd welcome it as some kind of configuration option. If you want to take a crack at it and #19, feel free to include the changes together.

IainNZ commented 9 years ago

This could possibly be an option, but I need to think about it. Certainly wouldn't be default option. When a failure occurs, does it print all STDOUT from the context, or just the statement?

ssfrr commented 9 years ago

The way it works in some other test frameworks I've used (I think nose.py does this) is that for each test case any generated STDOUT is suppressed, but if a given test fails than all the STDOUT from that test is printed, so you have more context. It makes test results a lot more concise, especially for passing tests where you generally don't care to see extra prints.

IainNZ commented 9 years ago

This is my next todo, and will involve redirect_stdout()

IainNZ commented 9 years ago

e.g.

oldstdout = STDOUT
rd, wr = redirect_stdout()
println("you won't see me")
readavailable(rd)
redirect_stdout(oldstdout)
println("you will see me")
oxinabox commented 8 years ago

Any update on this?

IainNZ commented 8 years ago

I'm not working on this (or this package), in favor of Base.Test (and its packaged version BaseTestNext)

oxinabox commented 8 years ago

fair enough, thanks. on that basis I will move all future tests I write over to Base.Test/BaseTestNext.