dos-djgpp updates (from Laszlo Molnar <laszlo.molnar@eth.ericsson.se>)
[p5sagit/p5-mst-13.2.git] / t / lib / 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;
95667ae4 15$dpp = $opt_d || '../utils/dprofpp';
583a019e 16
17print "\nperl: $perl\n" if $opt_v;
18if( ! -f $perl ){ die "Where's Perl?" }
95667ae4 19if( ! -f $dpp ){ die "Where's dprofpp?" }
583a019e 20
21sub dprofpp {
22 my $switches = shift;
23
95667ae4 24 open( D, "$perl -I../lib $dpp $switches 2> err |" ) || warn "$0: Can't run. $!\n";
583a019e 25 @results = <D>;
26 close D;
27
28 open( D, "<err" ) || warn "$0: Can't open: $!\n";
29 @err = <D>;
30 close D;
31 push( @results, @err ) if @err;
32
33 $results = qq{@results};
34 # ignore Loader (Dyna/Auto etc), leave newline
35 $results =~ s/^\w+Loader::import//;
36 $results =~ s/\n /\n/gm;
37 $results;
38}
39
40sub report {
41 $num = shift;
42 my $sub = shift;
43 my $x;
44
45 $x = &$sub;
46 $x ? &ok : &notok;
47}
48
49sub ok {
95667ae4 50 print "ok $num\n";
583a019e 51}
52
53sub notok {
95667ae4 54 print "not ok $num\n";
55 print "\nResult\n{$results}\n";
56 print "Expected\n{$expected}\n";
583a019e 57}
58
583a019e 591;