summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Devel/DProf/V.pm
blob: e613f6f4410abb005b637cf9d8298f1bf48dee5e (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package V;

use Getopt::Std 'getopts';
getopts('vp:d:');

require Exporter;
@ISA = 'Exporter';

@EXPORT = qw( dprofpp $opt_v $results $expected report @results );
@EXPORT_OK = qw( notok ok $num );

$num = 0;
$results = $expected = '';
$perl = $opt_p || $^X;
$dpp = $opt_d || '../../utils/dprofpp';
$dpp .= '.com' if $^O eq 'VMS';

print "\nperl: $perl\n" if $opt_v;
if( ! -f $perl ){ die "Where's Perl?" }
if( ! -f $dpp ) { 
    ($dpp = $^X) =~ s@(^.*)[/|\\].*@$1/dprofpp@;
    die "Where's dprofpp?" if( ! -f $dpp );
}

sub dprofpp {
	my $switches = shift;

        open( D, "$perl \"-I../lib\" $dpp \"$switches\" 2> err |" ) || warn "$0: Can't run. $!\n";
	@results = <D>;
	close D;

	open( D, "<err" ) || warn "$0: Can't open: $!\n";
	@err = <D>;
	close D;
	push( @results, @err ) if @err;

	$results = qq{@results};
	# ignore Loader (Dyna/Auto etc), leave newline
	$results =~ s/^\w+Loader::import//;
	$results =~ s/\n /\n/gm;
	$results;
}

sub report {
	$num = shift;
	my $sub = shift;
	my $x;

	$x = &$sub;
	$x ? &ok : &notok;
}

sub ok {
	print "ok $num\n";
}

sub notok {
	print "not ok $num\n";
	print "\nResult\n{$results}\n";
	print "Expected\n{$expected}\n";
}

1;