[icinga-checkins] icinga.org: icinga-core/test/core: Replace Perl6:: Slurp with our own slurp implementation

git at icinga.org git at icinga.org
Tue Apr 3 09:16:14 CEST 2012


Module: icinga-core
Branch: test/core
Commit: 593b622b69d84fd7f45141afe744c7058d98ff86
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=593b622b69d84fd7f45141afe744c7058d98ff86

Author: Alexander Wirt <formorer at debian.org>
Date:   Mon Feb 27 19:34:50 2012 +0100

Replace Perl6::Slurp with our own slurp implementation

---

 t/900-configparsing.t |    9 ++++-----
 t/Icinga/Test.pm      |   12 +++++++++++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/t/900-configparsing.t b/t/900-configparsing.t
index 2756e30..1b5466a 100644
--- a/t/900-configparsing.t
+++ b/t/900-configparsing.t
@@ -1,13 +1,12 @@
 #!/usr/bin/perl
-# 
+#
 # Taking a known icinga configuration directory, will check that the objects.cache is as expected
 
 use warnings;
 use strict;
 use Test::Most;
 use FindBin qw($Bin);
-use Icinga::Test qw ( run_cmd );
-use Perl6::Slurp;
+use Icinga::Test qw ( run_cmd slurp_file );
 
 chdir $Bin or die "Cannot chdir";
 
@@ -35,8 +34,8 @@ if ($? == 0) {
 
 system("grep -v 'Created:' $precache > '$precache.generated'");
 
-my $generated = slurp("$precache.generated");
-my $expected = slurp("$precache.expected");
+my $generated = slurp_file("$precache.generated");
+my $expected = slurp_file("$precache.expected");
 eq_or_diff($generated, $expected,'Icinga precached objects file matches expected');
 
 #cleanup
diff --git a/t/Icinga/Test.pm b/t/Icinga/Test.pm
index e1d7470..75204bb 100644
--- a/t/Icinga/Test.pm
+++ b/t/Icinga/Test.pm
@@ -4,9 +4,10 @@ package Icinga::Test;
 
 use strict;
 use warnings;
+use Carp;
 
 use Exporter 'import';
-our @EXPORT_OK = qw( run_cgi get_body run_cmd );
+our @EXPORT_OK = qw( run_cgi get_body run_cmd slurp_file );
 
 use IPC::Run3 qw( run3 );
 
@@ -56,4 +57,13 @@ sub get_body ($) {
     return $body;
 }
 
+sub slurp_file ($) {
+    my $filename = shift;
+    carp "Filename $filename not found" unless -f $filename;
+    open (my $fh, '<', $filename) 
+        or carp "Could not open $filename for reading: $!";
+    my $content = do { local $/; <$fh> };
+    close($fh);
+    return $content;
+}
 1;





More information about the icinga-checkins mailing list