LOGONLY mark 195c30 and b3fe9f as NODOC since they're tiny tweaks
[p5sagit/p5-mst-13.2.git] / ext / Devel-DProf / dprof / V.pm
CommitLineData
583a019e 1package V;
2
3use Getopt::Std 'getopts';
95667ae4 4getopts('vp:d:');
583a019e 5
6require Exporter;
7@ISA = 'Exporter';
8
9@EXPORT = qw( dprofpp $opt_v $results $expected report @results );
10@EXPORT_OK = qw( notok ok $num );
11
583a019e 12$num = 0;
13$results = $expected = '';
14$perl = $opt_p || $^X;
2adbc9b6 15$dpp = $opt_d || '../../utils/dprofpp';
ef060a86 16$dpp .= '.com' if $^O eq 'VMS';
583a019e 17
18print "\nperl: $perl\n" if $opt_v;
19if( ! -f $perl ){ die "Where's Perl?" }
2eb25c99 20if( ! -f $dpp ) {
21 ($dpp = $^X) =~ s@(^.*)[/|\\].*@$1/dprofpp@;
22 die "Where's dprofpp?" if( ! -f $dpp );
23}
583a019e 24
25sub dprofpp {
26 my $switches = shift;
27
ef060a86 28 open( D, "$perl \"-I../lib\" $dpp \"$switches\" 2> err |" ) || warn "$0: Can't run. $!\n";
583a019e 29 @results = <D>;
30 close D;
31
32 open( D, "<err" ) || warn "$0: Can't open: $!\n";
33 @err = <D>;
34 close D;
35 push( @results, @err ) if @err;
36
37 $results = qq{@results};
38 # ignore Loader (Dyna/Auto etc), leave newline
39 $results =~ s/^\w+Loader::import//;
40 $results =~ s/\n /\n/gm;
41 $results;
42}
43
44sub report {
45 $num = shift;
46 my $sub = shift;
47 my $x;
48
49 $x = &$sub;
50 $x ? &ok : &notok;
51}
52
53sub ok {
95667ae4 54 print "ok $num\n";
583a019e 55}
56
57sub notok {
95667ae4 58 print "not ok $num\n";
59 print "\nResult\n{$results}\n";
60 print "Expected\n{$expected}\n";
583a019e 61}
62
583a019e 631;