Load tag-reading modules on demand
[app-musicexpo.git] / t / App-MusicExpo.t
index 09b2bde29c9ba1261943134b34d30f8ffd9c4f3d..ea1c49653d7c29f9edeb0cea2cdefe1abf3b6f0b 100644 (file)
@@ -2,7 +2,7 @@
 use v5.14;
 use warnings;
 
-use Test::More tests => 37;
+use Test::More tests => 46;
 
 use Scalar::Util qw/looks_like_number/;
 use Storable qw/thaw/;
@@ -19,18 +19,27 @@ my %data = (
        genre       => 'Electro'
 );
 
+my %handled = map { $_ => 1 } App::MusicExpo::extensions_handled;
+
 sub test {
        my ($format, $sub, $file) = @_;
-       my $info = thaw $sub->($file);
-       is $info->{format}, $format, "$format format";
-       for (sort keys %data) {
-               my $op = looks_like_number $data{$_} ? '==' : 'eq';
-               cmp_ok $info->{$_}, $op, $data{$_}, "$format $_"
+       my ($ext) = $file =~ /(\..+)$/;
+
+  SKIP:
+       {
+               skip "Cannot handle $ext files (tag-reading module missing)", 9 unless $handled{$ext};
+                 my $info = thaw $sub->($file);
+               is $info->{format}, $format, "$format format";
+               for (sort keys %data) {
+                       my $op = looks_like_number $data{$_} ? '==' : 'eq';
+                       cmp_ok $info->{$_}, $op, $data{$_}, "$format $_"
+               }
+               is $info->{file}, $file, "$format file";
        }
-       is $info->{file}, $file, "$format file";
 }
 
 test FLAC   => \&App::MusicExpo::flacinfo,   'empty.flac';
 test MP3    => \&App::MusicExpo::mp3info,    'empty3.mp3';
 test Vorbis => \&App::MusicExpo::vorbisinfo, 'empty.ogg';
 test AAC    => \&App::MusicExpo::mp4info,    'empty4.aac';
+test Opus   => \&App::MusicExpo::opusinfo,   'empty2.opus';
This page took 0.009903 seconds and 4 git commands to generate.