From 62ea90e5d5a6338cdc674e5ff3ec9687cff9407b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sun, 4 Nov 2018 13:15:27 -0500 Subject: [PATCH] t: merge tags.t and meta.t in cli.t --- t/{tags.t => cli.t} | 56 ++++++++++++++++++++++++++++++++++++++++++--- t/meta.t | 52 ----------------------------------------- 2 files changed, 53 insertions(+), 55 deletions(-) rename t/{tags.t => cli.t} (65%) delete mode 100644 t/meta.t diff --git a/t/tags.t b/t/cli.t similarity index 65% rename from t/tags.t rename to t/cli.t index 1830d97..ec505df 100644 --- a/t/tags.t +++ b/t/cli.t @@ -1,19 +1,69 @@ -# Test the main features of opustags on an Ogg Opus sample file. - use strict; use warnings; use utf8; -use Test::More tests => 27; +use Test::More tests => 35; use Digest::MD5; use File::Basename; use IPC::Open3; use Symbol 'gensym'; +my $opustags = './opustags'; +BAIL_OUT("$opustags does not exist or is not executable") if (! -x $opustags); + my $t = dirname(__FILE__); BAIL_OUT("'$t' contains unsupported characters") if $t !~ m|^[\w/]*$|; +#################################################################################################### +# Tests related to the overall opustags executable, like the help message. +# No Opus file is manipulated here. + +chomp(my $version = `$opustags --help | head -n 1`); +like($version, qr/^opustags version \d+\.\d+\.\d+$/, 'get the version string'); + +is(`$opustags`, <<"EOF", 'no options show the usage'); +$version +Usage: opustags --help + opustags [OPTIONS] FILE + opustags OPTIONS FILE -o FILE +EOF +is($?, 0, 'no option is not an error'); # should it be? + +my $help = <<"EOF"; +$version + +Usage: opustags --help + opustags [OPTIONS] FILE + opustags OPTIONS FILE -o FILE + +Options: + -h, --help print this help + -o, --output write the modified tags to a file + -i, --in-place [SUFFIX] use a temporary file then replace the original file + -y, --overwrite overwrite the output file if it already exists + -d, --delete FIELD delete all the fields of a specified type + -a, --add FIELD=VALUE add a field + -s, --set FIELD=VALUE delete then add a field + -D, --delete-all delete all the fields! + -S, --set-all read the fields from stdin + +See the man page for extensive documentation. +EOF + +is(`$opustags --help`, $help, '--help displays the help message'); +is($?, 0, '--help returns 0'); + +is(`$opustags --h`, $help, '-h displays the help message too'); + +is(`$opustags --derp 2>&1`, <<'EOF', 'unrecognized option shows an error'); +./opustags: unrecognized option '--derp' +EOF +is($?, 256, 'unrecognized option causes return code 256'); + +#################################################################################################### +# Test the main features of opustags on an Ogg Opus sample file. + sub md5 { my ($file) = @_; open(my $fh, '<', $file) or return; diff --git a/t/meta.t b/t/meta.t deleted file mode 100644 index 0ba9803..0000000 --- a/t/meta.t +++ /dev/null @@ -1,52 +0,0 @@ -# Tests related to the overall opustags executable, like the help message. -# No Opus file is manipulated here. - -use strict; -use warnings; - -use Test::More tests => 8; - -my $opustags = './opustags'; -BAIL_OUT("$opustags does not exist or is not executable") if (! -x $opustags); - -chomp(my $version = `$opustags --help | head -n 1`); -like($version, qr/^opustags version \d+\.\d+\.\d+$/, 'get the version string'); - -is(`$opustags`, <<"EOF", 'no options show the usage'); -$version -Usage: opustags --help - opustags [OPTIONS] FILE - opustags OPTIONS FILE -o FILE -EOF -is($?, 0, 'no option is not an error'); # should it be? - -my $help = <<"EOF"; -$version - -Usage: opustags --help - opustags [OPTIONS] FILE - opustags OPTIONS FILE -o FILE - -Options: - -h, --help print this help - -o, --output write the modified tags to a file - -i, --in-place [SUFFIX] use a temporary file then replace the original file - -y, --overwrite overwrite the output file if it already exists - -d, --delete FIELD delete all the fields of a specified type - -a, --add FIELD=VALUE add a field - -s, --set FIELD=VALUE delete then add a field - -D, --delete-all delete all the fields! - -S, --set-all read the fields from stdin - -See the man page for extensive documentation. -EOF - -is(`$opustags --help`, $help, '--help displays the help message'); -is($?, 0, '--help returns 0'); - -is(`$opustags --h`, $help, '-h displays the help message too'); - -is(`$opustags --derp 2>&1`, <<'EOF', 'unrecognized option shows an error'); -./opustags: unrecognized option '--derp' -EOF -is($?, 256, 'unrecognized option causes return code 256');