Browse files

Use PerlIO's support for in-memory files via a scalar ref instead of …

…piping from echo

echo is less portable than in-memory files.  On Solaris, for example,
/bin/echo does not support the -n flag and instead faithfully prints
every single argument.

I'm not sure the -n flag is actually needed — why suppress the trailing
newline? — but using an in-memory file should be more reliable than
spawning a child process and reading from a shared pipe.

Of note: ok() is not actually available within this package, so I simply
switched to die() instead of importing Test::More and futzing with
  • Loading branch information...
1 parent faddf9b commit f418bfaa4a64e3e7000d33a7720b9e9eea534865 @tsibley tsibley committed Feb 14, 2014
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/App/RecordStream/Test/
5 lib/App/RecordStream/Test/
@@ -52,8 +52,9 @@ sub test_stdin {
my $input = shift;
my $output = shift;
- # Re open stdin to the given input
- open(STDIN, "-|", "echo", "-n", $input) || ok(0, "Cannot open echo?!");
+ # Re-open stdin to the given input
+ close(STDIN) or die "Cannot close STDIN: $!";
+ open(STDIN, "<", \$input) or die "Cannot re-open STDIN to string ref: $!";
return App::RecordStream::Test::OperationHelper->do_match(

0 comments on commit f418bfa

Please sign in to comment.