add test to assure RPM VERSION is up-to-date (#80)

This commit is contained in:
Matt Simerson 2014-09-11 10:37:16 -07:00
parent 8f8463e91e
commit bcacb2778c

36
t/packaging.t Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
ok(my $qp_version = get_qp_version(), 'get_qp_version');
ok(my $rpm_version = get_rpm_version(), "get_rpm_version");
cmp_ok($rpm_version, 'eq', $qp_version, "RPM version is up-to-date");
done_testing();
sub get_qp_version {
my $rvfile = get_file_contents('lib/Qpsmtpd.pm')
or return;
my ($ver_line) = grep { $_ =~ /^our \$VERSION/ } @$rvfile;
my ($ver) = $ver_line =~ /"([0-9\.]+)"/;
return $ver;
};
sub get_rpm_version {
my $rvfile = get_file_contents('packaging/rpm/VERSION')
or return;
chomp @$rvfile;
return $rvfile->[0];
}
sub get_file_contents {
my $file = shift;
open my $fh, '<', $file or do {
warn "failed to open $file";
return;
};
my @r = <$fh>;
return \@r;
};