mirror of
https://github.com/webmin/webmin.git
synced 2026-08-23 15:30:28 +01:00
29 lines
547 B
Perl
29 lines
547 B
Perl
# Common helpers for Webmin tests.
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
# write_text(file, contents)
|
|
# Writes a text fixture and fails the test immediately on an I/O error
|
|
sub write_text
|
|
{
|
|
my ($file, $text) = @_;
|
|
open(my $fh, ">", $file) or die "open $file: $!";
|
|
print $fh $text;
|
|
close($fh) or die "close $file: $!";
|
|
}
|
|
|
|
# read_text(file)
|
|
# Returns the complete contents of a text fixture
|
|
sub read_text
|
|
{
|
|
my ($file) = @_;
|
|
open(my $fh, "<", $file) or die "open $file: $!";
|
|
local $/;
|
|
my $text = <$fh>;
|
|
close($fh) or die "close $file: $!";
|
|
return $text;
|
|
}
|
|
|
|
1;
|