File: 10-check_perldiag.t

package info (click to toggle)
libparse-errorstring-perl-perl 0.27-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 220 kB
  • sloc: perl: 2,059; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 678 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 4;

use File::Temp qw(tempdir);
use File::Spec ();

my $dir = tempdir( CLEANUP => 1 );

#diag $dir;

my $out = "$dir/out";
my $err = "$dir/err";
my $cmd = "$^X -wc " . File::Spec->catfile( 'bin', 'check_perldiag' ) . "> $out 2> $err";

#diag $cmd;
system $cmd;

ok( -e $out, 'out file exists' );
is( -s $out, 0, 'out file is empty' );
ok( -e $err, 'err file exists' );

my $err_data = slurp($err);
like( $err_data, qr{^bin[/\\]+check_perldiag syntax OK$}, 'syntax ok' );

sub slurp {
	my $file = shift;
	if ( open my $fh, '<', $file ) {
		local $/ = undef;
		return <$fh>;
	} else {
		warn $!;
		return;
	}
}