@@ -43,6 +43,7 @@ package TestLib;
43
43
use strict;
44
44
use warnings;
45
45
46
+ use Carp;
46
47
use Config;
47
48
use Cwd;
48
49
use Exporter ' import' ;
@@ -421,7 +422,7 @@ sub slurp_dir
421
422
{
422
423
my ($dir ) = @_ ;
423
424
opendir (my $dh , $dir )
424
- or die " could not opendir \" $dir \" : $! " ;
425
+ or croak " could not opendir \" $dir \" : $! " ;
425
426
my @direntries = readdir $dh ;
426
427
closedir $dh ;
427
428
return @direntries ;
@@ -443,19 +444,19 @@ sub slurp_file
443
444
if ($Config {osname } ne ' MSWin32' )
444
445
{
445
446
open (my $in , ' <' , $filename )
446
- or die " could not read \" $filename \" : $! " ;
447
+ or croak " could not read \" $filename \" : $! " ;
447
448
$contents = <$in >;
448
449
close $in ;
449
450
}
450
451
else
451
452
{
452
453
my $fHandle = createFile($filename , " r" , " rwd" )
453
- or die " could not open \" $filename \" : $^E" ;
454
+ or croak " could not open \" $filename \" : $^E" ;
454
455
OsFHandleOpen(my $fh = IO::Handle-> new(), $fHandle , ' r' )
455
- or die " could not read \" $filename \" : $^E\n " ;
456
+ or croak " could not read \" $filename \" : $^E\n " ;
456
457
$contents = <$fh >;
457
458
CloseHandle($fHandle )
458
- or die " could not close \" $filename \" : $^E\n " ;
459
+ or croak " could not close \" $filename \" : $^E\n " ;
459
460
}
460
461
$contents =~ s /\r\n / \n / g if $Config {osname } eq ' msys' ;
461
462
return $contents ;
@@ -474,7 +475,7 @@ sub append_to_file
474
475
{
475
476
my ($filename , $str ) = @_ ;
476
477
open my $fh , " >>" , $filename
477
- or die " could not write \" $filename \" : $! " ;
478
+ or croak " could not write \" $filename \" : $! " ;
478
479
print $fh $str ;
479
480
close $fh ;
480
481
return ;
0 commit comments