From 74cc6038b2dab6e0cad9f2108fb662811c51af0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= <fmang@mg0.fr>
Date: Sat, 10 Nov 2018 10:24:14 -0500
Subject: [PATCH] t: pass opus data in stdin/stdout

---
 t/cli.t | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/t/cli.t b/t/cli.t
index f284ec9..94ec862 100644
--- a/t/cli.t
+++ b/t/cli.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use utf8;
 
-use Test::More tests => 24;
+use Test::More tests => 25;
 
 use Digest::MD5;
 use File::Basename;
@@ -175,4 +175,33 @@ warning: skipping malformed tag
 warning: skipping malformed tag
 END_ERR
 
+sub slurp {
+	my ($filename) = @_;
+	local $/;
+	open(my $fh, '<', $filename);
+	binmode($fh);
+	my $data = <$fh>;
+	$data
+}
+
+sub opustags_binary {
+	my $in = pop @_;
+	my ($pid, $pin, $pout, $perr);
+	local $/;
+	$perr = gensym;
+	$pid = open3($pin, $pout, $perr, $opustags, @_);
+	binmode($pin);
+	binmode($pout);
+	binmode($perr, ':utf8');
+	print $pin $in if defined $in;
+	close $pin;
+	my $out = <$pout>;
+	my $err = <$perr>;
+	waitpid($pid, 0);
+	[$out, $err, $?]
+}
+
+my $data = slurp "$t/out.opus";
+is_deeply(opustags_binary('-', '-o', '-', $data), [$data, '', 0], 'read opus from stdin and write to stdout');
+
 unlink("$t/out.opus");