From bcacb2778cb5621b2a32206651ed48a5a1fa7c2c Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Thu, 11 Sep 2014 10:37:16 -0700 Subject: [PATCH] add test to assure RPM VERSION is up-to-date (#80) --- t/packaging.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 t/packaging.t diff --git a/t/packaging.t b/t/packaging.t new file mode 100644 index 0000000..e0df631 --- /dev/null +++ b/t/packaging.t @@ -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; +};