Codebase list id3 / 3a4e802
Use Audio::Scan instead of MP3::Info in the tests. Peter Pentchev 2 years ago
4 changed file(s) with 102 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
44 Build-Depends:
55 debhelper-compat (= 13),
66 dh-sequence-single-binary,
7 libaudio-scan-perl <!nocheck>,
78 libjs-scriptaculous <!nocheck>,
8 libmp3-info-perl <!nocheck>,
99 libpath-tiny-perl <!nocheck>,
1010 libtest-command-perl <!nocheck>,
1111 perl <!nocheck>,
00 test-genre.patch
1 test-audio-scan.patch
0 Description: Use Audio::Scan instead of MP3::Info.
1 Forwarded: yes
2 Author: Peter Pentchev <roam@ringlet.net>
3 Last-Updated: 2021-12-31
4
5 --- a/t/02-mp3-info.t
6 +++ b/t/02-mp3-info.t
7 @@ -19,7 +19,7 @@
8 use Test::More;
9
10 my $have_mp3_info = 1;
11 -eval "use MP3::Info;";
12 +eval "use Audio::Scan;";
13 if ($@) {
14 $have_mp3_info = 0;
15 }
16 @@ -36,6 +36,15 @@
17 )
18 $}x;
19
20 +my %XLAT = (
21 + COMM => 'Comment',
22 + TALB => 'Album',
23 + TCON => 'Genre',
24 + TDRC => 'Year',
25 + TIT2 => 'Title',
26 + TPE1 => 'Artist',
27 +);
28 +
29 sub extract_file_tag_stripped($)
30 {
31 my ($lines) = @_;
32 @@ -77,7 +86,7 @@
33 BAIL_OUT "Not an executable file: $PROG" unless -f $PROG && -x $PROG;
34
35 SKIP: {
36 - skip 'no MP3::Info module', 2 unless $have_mp3_info;
37 + skip 'no Audio::Scan module', 2 unless $have_mp3_info;
38
39 my $orig = path($ENV{TEST_ID3_MEOW} //
40 '/usr/share/doc/libvideo-info-perl/examples/meow.mp3.gz');
41 @@ -98,11 +107,11 @@
42 }
43 BAIL_OUT "Could not create $fdata" unless $fdata->is_file;
44
45 - my $exp = MP3::Info->new("$fdata");
46 - is $exp->FILE, "$fdata", "MP3::Info parsed $fdata";
47 + my $exp = Audio::Scan->scan_tags("$fdata");
48 + ok exists $exp->{tags}, "Audio::Scan parsed $fdata";
49
50 subtest 'List (RFC-822) the tag' => sub {
51 - plan tests => 5;
52 + plan tests => 6;
53
54 my $cmd = [$PROG, '-l', '-R', '--', $fdata];
55 my $tcmd = Test::Command->new(cmd => $cmd);
56 @@ -113,21 +122,32 @@
57
58 my $tag = extract_file_tag_stripped \@lines;
59 ok scalar keys %{$tag} >= 5, '-l -R output at least five tags';
60 + if (exists $tag->{Genre}) {
61 + my $value = (split / [(]/, $tag->{Genre})[0];
62 + $value = '' if $value eq 'Unknown';
63 + $tag->{Genre} = $value;
64 + }
65
66 subtest 'compare the keys' => sub {
67 - plan tests => scalar keys %{$tag};
68 + plan tests => scalar keys %{$exp->{tags}};
69
70 - for my $key (sort keys %{$tag}) {
71 - my $value = $tag->{$key};
72 - my $upper = uc $key;
73 - if ($key eq 'Filename') {
74 - $upper = 'FILE';
75 - } elsif ($key eq 'Genre') {
76 - $value = (split / [(]/, $value)[0];
77 - $value = '' if $value eq 'Unknown';
78 + for my $key (sort keys %{$exp->{tags}}) {
79 + my $expected = $exp->{tags}->{$key};
80 + if ($key eq 'COMM') {
81 + # Let's hope this works...
82 + $expected = $expected->[$#{$expected}];
83 + }
84 + my $xlat = $XLAT{$key};
85 + if (!defined $xlat) {
86 + die "Unhandled '$key': '$expected'";
87 }
88 - is $value, $exp->{$upper}, "compare $key";
89 + is $tag->{$xlat}, $expected, "compare $key ($xlat)";
90 + delete $tag->{$xlat};
91 }
92 };
93 + my $leftover = join ' ',
94 + grep $_ ne 'Filename' && $tag->{$_} ne '',
95 + keys %{$tag};
96 + is $leftover, '', 'only empty keys left in the id3 output';
97 };
98 }
00 Test-Command: env TEST_ID3=/usr/bin/id3 TEST_ID3_MEOW=/usr/share/doc/libjs-scriptaculous/test/functional/sword.mp3.gz prove t
11 Depends:
22 @,
3 libaudio-scan-perl,
34 libjs-scriptaculous,
4 libmp3-info-perl,
55 libtest-command-perl,
66 libpath-tiny-perl,
77 perl,