aboutsummaryrefslogtreecommitdiffstats
path: root/t/Utils.pm
diff options
context:
space:
mode:
authorGuillaume Rousse <guillomovitch@mandriva.org>2010-01-01 23:12:39 +0000
committerGuillaume Rousse <guillomovitch@mandriva.org>2010-01-01 23:12:39 +0000
commit52639f09bcc16bc4e50ad411ddef52da97533c81 (patch)
tree545eed899cc4d2dddd11a0277a8ef259197f19ac /t/Utils.pm
parent13710e05cbe37fb5048cdc76520818252f411447 (diff)
downloadspec-helper-52639f09bcc16bc4e50ad411ddef52da97533c81.tar
spec-helper-52639f09bcc16bc4e50ad411ddef52da97533c81.tar.gz
spec-helper-52639f09bcc16bc4e50ad411ddef52da97533c81.tar.bz2
spec-helper-52639f09bcc16bc4e50ad411ddef52da97533c81.tar.xz
spec-helper-52639f09bcc16bc4e50ad411ddef52da97533c81.zip
code factorisation
Diffstat (limited to 't/Utils.pm')
-rw-r--r--t/Utils.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/Utils.pm b/t/Utils.pm
new file mode 100644
index 0000000..eef8187
--- /dev/null
+++ b/t/Utils.pm
@@ -0,0 +1,30 @@
+package Utils;
+
+use strict;
+use warnings;
+use base qw(Exporter);
+use FindBin qw/$Bin/;
+use Digest::MD5;
+
+our @EXPORT_OK = qw(run get_md5);
+
+
+sub run {
+ my ($buildroot, $program) = @_;
+
+ $ENV{RPM_BUILD_ROOT} = $buildroot;
+ system("$Bin/../$program");
+}
+
+
+sub get_md5 {
+ my ($file) = @_;
+ open(my $in, '<', $file) or die "can't read $file: $!";
+ binmode($in);
+ my $md5 = Digest::MD5->new();
+ $md5->addfile($in);
+ close($in);
+ return $md5->hexdigest();
+}
+
+1;