1 # Copyright © 2015 Guillem Jover <guillem@debian.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
21 our $VERSION = '0.00';
29 test_needs_srcdir_switch
30 test_neutralize_checksums
37 test_needs_srcdir_switch
46 use Exporter qw(import);
48 use IPC::Cmd qw(can_run);
51 sub test_get_data_path
55 my $srcdir = $ENV{srcdir} || '.';
56 return "$srcdir/$path";
59 sub test_get_perl_dirs
61 return qw(t src/t lib utils/t scripts dselect);
67 my $scan_perl_files = sub {
68 push @files, $File::Find::name if m/\.(pl|pm|t)$/;
71 find($scan_perl_files, test_get_perl_dirs());
78 if (not $ENV{DPKG_DEVEL_MODE} and not $ENV{AUTHOR_TESTING}) {
79 plan skip_all => 'developer test';
85 my ($module, @imports) = @_;
86 my ($package) = caller;
90 if (@imports >= 1 and version::is_lax($imports[0])) {
91 $version = shift @imports;
96 use $module $version \@imports;
99 plan skip_all => "requires module $module $version";
103 sub test_needs_command
107 if (not can_run($command)) {
108 plan skip_all => "requires command $command";
112 sub test_needs_srcdir_switch
114 if (defined $ENV{srcdir}) {
115 chdir $ENV{srcdir} or BAIL_OUT("cannot chdir to source directory: $!");
119 sub test_neutralize_checksums
121 my $filename = shift;
122 my $filenamenew = "$filename.new";
124 open my $fhnew, '>', $filenamenew or die;
125 open my $fh, '<', $filename or die;
127 s/^ ([0-9a-f]{32,}) [1-9][0-9]* /q{ } . $1 =~ tr{0-9a-f}{0}r . q{ 0 }/e;
133 rename $filenamenew, $filename or die;