This is very close to what I'm thinking of, but I was also thinking you could add the if ( !-t STDIN ) { ... } test in the read_stdin sub. That way for most tests there's no different code paths taken based on the external environment of the tests.
So, the consumer would do if ( my $content = read_stdin() ) { ... } and wouldn't have to check all the right things for STDIN (which, if I recall correctly, is both !-t and -z)
Coverage increased (+0.01%) to 91.873% when pulling b80cc8c4544e76e3c5d8f46172ed34654e5229f9 on mohawk2:test-stdin into 305b6f694f1ece6aa5d9a991eface2b54fbb3215 on preaction:master.
This is very close to what I'm thinking of, but I was also thinking you could add the
if ( !-t STDIN ) { ... }
test in theread_stdin
sub. That way for most tests there's no different code paths taken based on the external environment of the tests.So, the consumer would do
if ( my $content = read_stdin() ) { ... }
and wouldn't have to check all the right things for STDIN (which, if I recall correctly, is both!-t
and-z
)