Skip to content


Tests fail when redirected to a file #6

bkabrda opened this Issue · 5 comments

2 participants


I just found out, that when you redirect the test output to a file, the 3 table tests fail, because you don't do the formatting. For example:

#display_table([{:a => 1}, {:a => 2}]) - returns " +---+\n | \e[1ma\e[0m |\n +---+\n | 1 |\n +---+\n | 2 |\n +---+\n"
expected => " +---+\n | \e[1ma\e[0m |\n +---+\n | 1 |\n +---+\n | 2 |\n +---+\n"
returned => " +---+\n | a |\n +---+\n | 1 |\n +---+\n | 2 |\n +---+\n"

I believe that this is not an issue with formatador itself, but with the tests. I think they should react to the situation when redirected to a file.

Bohuslav Kabrda.


I don't think I entirely follow. What command are you running and/or what code are you changing to redirect to a file? I can see the problem in the difference between results, but I want to make sure I am duplicating it correctly before working to fix it. Thanks!


I'm running something like shindo > a.txt, so the whole tests output goes into a file.


Ok, I see now. Just wanted to make sure I was on the same page. I believe the issue you are running into is because before outputting stuff it checks to see if stdout is tty. When outputting to a file like this, I presume that it would not be, so it will strip formatting first. The tests expect to be run against tty so they can check the formatting. Is there a particular use case that requires outputting to a file?


Indeed, I am packaging formatador for Fedora and we need to build in Koji, where all output is redirected to a file, so the tests fail and the whole build fails. So it would be fine if the tests could react to this situation.

@geemus geemus added a commit that closed this issue
@geemus cleanup test output formatting
also allows tests to pass with non-tty STDOUT
closes #6
@geemus geemus closed this in a874311

Thank you, works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.