[Rt-commit] r8928 - rt/branches/3.7-EXPERIMENTAL/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Wed Sep 5 06:56:34 EDT 2007


Author: ruz
Date: Wed Sep  5 06:56:29 2007
New Revision: 8928

Modified:
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm

Log:
* add RT::Test->file_content

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm	Wed Sep  5 06:56:29 2007
@@ -389,6 +389,25 @@
     return ($status, $id);
 }
 
+sub file_content {
+    my $self = shift;
+    my $path = shift;
+    my %args = @_;
+
+    $path = File::Spec->catfile( @$path ) if ref $path;
+
+    diag "reading content of '$path'" if $ENV{'TEST_VERBOSE'};
+
+    open my $fh, "<:raw", $path
+        or die "couldn't open file '$path': $!";
+    my $content = do { local $/; <$fh> };
+    close $fh;
+
+    unlink $path if $args{'unlink'};
+
+    return $content;
+}
+
 sub import_gnupg_key {
     my $self = shift;
     my $key = shift;


More information about the Rt-commit mailing list