This happens because ack only checks whether STDIN is a tty.
The intent of the check is to see if data should be filtered from STDIN,
which is assumed to be the case if STDIN is not a tty. However, I
believe that if STDIN is not a tty and there's no data available on it
(because it's closed or it's null/EOF), ack should proceed as normal.
The test failures can be reproduced with:
perl -e 'close(STDIN); print system("make","test")'
I have attached a patch that checks for EOF on STDIN, which also allows
this to succeed:
cat /dev/null | make test
In doing that, ack will now not treat null or closed STDIN as if it's
running from a terminal, and yet "echo foo | ack foo" still works. The
catch is that the following now fails to do the right thing:
/bin/true | ack foo
where /bin/true is any command that doesn't have output. A warning to
STDERR may be appropriate in that case, along the lines of:
ack: STDIN is not a terminal and has no data, ignoring