Ticket #101: trac101-t-tools.patch

File trac101-t-tools.patch, 11.1 KB (added by rurban, 13 years ago)
  • MANIFEST

     
    37163716t/tools/ops2pm/samples/core_ops.orig                        [] 
    37173717t/tools/ops2pm/samples/ops_num.orig                         [] 
    37183718t/tools/ops2pm/samples/pic_ops.orig                         [] 
     3719t/tools/parrot_config.t                                     [] 
    37193720t/tools/parrot_debugger.t                                   [] 
     3721t/tools/pbc_disassemble.t                                   [] 
     3722t/tools/pbc_info.t                                          [] 
    37203723t/tools/pbc_merge.t                                         [] 
     3724t/tools/pdump.t                                             [] 
    37213725t/tools/pmc2c.t                                             [] 
    37223726t/tools/pmc2cutils/00-qualify.t                             [] 
    37233727t/tools/pmc2cutils/01-pmc2cutils.t                          [] 
  • t/tools/parrot_debugger.t

     
    2222=head1 REQUIREMENTS 
    2323 
    2424This test script requires you to build parrot_debugger, by typing 
    25 "make parrot_debugger" (using a suitable make tool for your platform). 
     25"make parrot_utils" (using a suitable make tool for your platform). 
    2626If this requirement has not been met, all tests will be skipped. 
    2727 
    2828=cut 
     
    3232use lib qw(lib); 
    3333 
    3434use Test::More; 
    35 use IO::File; 
     35use IO::File (); 
    3636use Parrot::Config; 
    3737use File::Spec; 
    3838 
     
    4242    $path_to_pdb = File::Spec->catfile( ".", "parrot_debugger" ); 
    4343    my $exefile = $path_to_pdb . $PConfig{exe}; 
    4444    unless ( -f $exefile ) { 
    45         plan skip_all => "parrot_debugger hasn't been built"; 
     45        plan skip_all => "parrot_debugger hasn't been built. Run make parrot_utils"; 
    4646        exit(0); 
    4747    } 
    4848} 
     
    101101    my $output = join( '', <$f> ); 
    102102 
    103103    local $Test::Builder::Level = $Test::Builder::Level + 1; 
     104    unlink ($codefn, $stdinfn, $stdoutfn); 
    104105    like( $output, $check, $diag ); 
    105106} 
    106107 
  • t/tools/pbc_disassemble.t

     
     1#! perl 
     2# Copyright (C) 2007-2008, The Perl Foundation. 
     3# $Id: pbc_disassemble.t 34223 2008-12-22 03:24:34Z petdance $ 
     4 
     5=head1 NAME 
     6 
     7t/tools/pbc_disassemble.t - test the Parrot Debugger 
     8 
     9=head1 SYNOPSIS 
     10 
     11    % prove t/tools/pbc_disassemble.t 
     12 
     13=head1 DESCRIPTION 
     14 
     15Tests the C<pbc_disassemble> tool by providing it with a number of source 
     16files, and running through it with various commands. 
     17 
     18We never actually check the I<full> output of pbc_disassemble.  We simply check 
     19several smaller components to avoid a test file that is far too unwieldy. 
     20 
     21 
     22=head1 REQUIREMENTS 
     23 
     24This test script requires you to build pbc_disassemble, by typing 
     25"make parrot_utils" (using a suitable make tool for your platform). 
     26If this requirement has not been met, all tests will be skipped. 
     27 
     28=cut 
     29 
     30use strict; 
     31use warnings; 
     32use lib qw(lib); 
     33 
     34use Test::More; 
     35use IO::File (); 
     36use Parrot::Config; 
     37use File::Spec; 
     38 
     39my $path; 
     40my $parrot = File::Spec->catfile( ".", $PConfig{test_prog} ); 
     41 
     42BEGIN { 
     43    $path = File::Spec->catfile( ".", "pbc_disassemble" ); 
     44    my $exefile = $path . $PConfig{exe}; 
     45    unless ( -f $exefile ) { 
     46        plan skip_all => "pbc_disassemble hasn't been built. Run make parrot_utils"; 
     47        exit(0); 
     48    } 
     49    plan tests => 2; 
     50} 
     51 
     52output_like( <<PIR, "pir", [ qr/set_n_nc/, qr/print_n/], 'pbc_disassemble'); 
     53.sub main :main 
     54    \$N3 = 3.14159 
     55    print \$N3 
     56    print "\\n" 
     57.end 
     58PIR 
     59 
     60=head1 HELPER SUBROUTINES 
     61 
     62=head2 output_like 
     63 
     64    output_like(<<PASM, "pasm", "some output", "running $file"); 
     65 
     66Takes 3-4 arguments: a file to run, 
     67the filename-extension of the file (probably "pir" or "pasm"), 
     68an arrayref or single regex string to match within pbc_disassemble's output, 
     69and the optional test diagnostic. 
     70 
     71=cut 
     72 
     73my $testno = 0; 
     74 
     75sub output_like { 
     76    my ( $file, $ext, $check, $diag ) = @_; 
     77    $testno++; 
     78    my $codefn   = "$0.$testno.$ext"; 
     79    my $pbcfn    = "$0.$testno.pbc"; 
     80    my $stdoutfn = "$0.$testno.stdout"; 
     81    my $f        = IO::File->new(">$codefn"); 
     82    $f->print($file); 
     83    $f->close(); 
     84    system("$parrot -o $pbcfn $codefn 2>&1"); 
     85    system("$path $pbcfn >$stdoutfn 2>&1"); 
     86    $f = IO::File->new($stdoutfn); 
     87 
     88    my $output = join( '', <$f> ); 
     89 
     90    local $Test::Builder::Level = $Test::Builder::Level + 1; 
     91    unlink ($codefn, $pbcfn, $stdoutfn); 
     92    if (ref $check eq 'ARRAY') { 
     93        for my $chk (@$check) { 
     94            like( $output, $chk, $diag ); 
     95            $testno++; 
     96        } 
     97    } else { 
     98        like( $output, $check, $diag ); 
     99    } 
     100} 
     101 
     102=head1 TODO 
     103 
     104=over 4 
     105 
     106=item 
     107 
     108Flesh it out.  This is a bare bones proof of concept. 
     109Add tests for all of the commands. 
     110 
     111=back 
     112 
     113=cut 
     114 
     115# Local Variables: 
     116#   mode: cperl 
     117#   cperl-indent-level: 4 
     118#   fill-column: 100 
     119# End: 
     120# vim: expandtab shiftwidth=4: 
  • t/tools/pbc_info.t

    Property changes on: t/tools/pbc_disassemble.t
    ___________________________________________________________________
    Added: svn:executable
       + *
    
     
     1#! perl 
     2# Copyright (C) 2007-2008, The Perl Foundation. 
     3# $Id: pbc_info.t 34223 2008-12-22 03:24:34Z petdance $ 
     4 
     5=head1 NAME 
     6 
     7t/tools/pbc_info.t - test the Parrot Dumper 
     8 
     9=head1 SYNOPSIS 
     10 
     11    % prove t/tools/pbc_info.t 
     12 
     13=head1 DESCRIPTION 
     14 
     15Tests the C<pbc_info> tool by providing it with a number of source 
     16files, and running through it with various commands. 
     17 
     18We never actually check the I<full> output of pbc_info.  We simply check 
     19several smaller components to avoid a test file that is far too unwieldy. 
     20 
     21 
     22=head1 REQUIREMENTS 
     23 
     24This test script requires you to build pbc_info, by typing 
     25"make parrot_utils" (using a suitable make tool for your platform). 
     26If this requirement has not been met, all tests will be skipped. 
     27 
     28=cut 
     29 
     30use strict; 
     31use warnings; 
     32use lib qw(lib); 
     33 
     34use Test::More; 
     35use IO::File (); 
     36use Parrot::Config; 
     37use File::Spec; 
     38 
     39my $path; 
     40my $parrot = File::Spec->catfile( ".", $PConfig{test_prog} ); 
     41 
     42BEGIN { 
     43    $path = File::Spec->catfile( ".", "pbc_info" ); 
     44    my $exefile = $path . $PConfig{exe}; 
     45    unless ( -f $exefile ) { 
     46        plan skip_all => "pbc_info hasn't been built. Run make parrot_utils"; 
     47        exit(0); 
     48    } 
     49    plan tests => 4; 
     50} 
     51 
     52output_like( <<PIR, "pir", [qr/FIXUP_t/, qr/PIC_idx/, qr/CONSTANT_t/, qr/BYTECODE_t/], 'pbc_info'); 
     53.sub main :main 
     54    \$N3 = 3.14159 
     55    print \$N3 
     56    print "\\n" 
     57.end 
     58PIR 
     59 
     60=head1 HELPER SUBROUTINES 
     61 
     62=head2 output_like 
     63 
     64    output_like(<<PASM, "pasm", "some output", "running $file"); 
     65 
     66Takes 3-4 arguments: a file to run, 
     67the filename-extension of the file (probably "pir" or "pasm"), 
     68an arrayref or single regex string to match within pbc_info's output, 
     69and the optional test diagnostic. 
     70 
     71=cut 
     72 
     73my $testno = 0; 
     74 
     75sub output_like { 
     76    my ( $file, $ext, $check, $diag ) = @_; 
     77    $testno++; 
     78    my $codefn   = "$0.$testno.$ext"; 
     79    my $pbcfn    = "$0.$testno.pbc"; 
     80    my $stdoutfn = "$0.$testno.stdout"; 
     81    my $f        = IO::File->new(">$codefn"); 
     82    $f->print($file); 
     83    $f->close(); 
     84    system("$parrot -o $pbcfn $codefn 2>&1"); 
     85    system("$path $pbcfn >$stdoutfn 2>&1"); 
     86    $f = IO::File->new($stdoutfn); 
     87 
     88    my $output = join( '', <$f> ); 
     89 
     90    local $Test::Builder::Level = $Test::Builder::Level + 1; 
     91    unlink ($codefn, $pbcfn, $stdoutfn); 
     92    if (ref $check eq 'ARRAY') { 
     93        for my $chk (@$check) { 
     94            like( $output, $chk, $diag ); 
     95            $testno++; 
     96        } 
     97    } else { 
     98        like( $output, $check, $diag ); 
     99    } 
     100} 
     101 
     102=head1 TODO 
     103 
     104=over 4 
     105 
     106=item 
     107 
     108Flesh it out.  This is a bare bones proof of concept. 
     109Add tests for all of the commands. 
     110 
     111=back 
     112 
     113=cut 
     114 
     115# Local Variables: 
     116#   mode: cperl 
     117#   cperl-indent-level: 4 
     118#   fill-column: 100 
     119# End: 
     120# vim: expandtab shiftwidth=4: 
  • t/tools/pdump.t

    Property changes on: t/tools/pbc_info.t
    ___________________________________________________________________
    Added: svn:executable
       + *
    
     
     1#! perl 
     2# Copyright (C) 2007-2008, The Perl Foundation. 
     3# $Id: pdump.t 34223 2008-12-22 03:24:34Z petdance $ 
     4 
     5=head1 NAME 
     6 
     7t/tools/pdump.t - test the Parrot Dumper 
     8 
     9=head1 SYNOPSIS 
     10 
     11    % prove t/tools/pdump.t 
     12 
     13=head1 DESCRIPTION 
     14 
     15Tests the C<pdump> tool by providing it with a number of source 
     16files, and running through it with various commands. 
     17 
     18We never actually check the I<full> output of pdump.  We simply check 
     19several smaller components to avoid a test file that is far too unwieldy. 
     20 
     21 
     22=head1 REQUIREMENTS 
     23 
     24This test script requires you to build pdump, by typing 
     25"make parrot_utils" (using a suitable make tool for your platform). 
     26If this requirement has not been met, all tests will be skipped. 
     27 
     28=cut 
     29 
     30use strict; 
     31use warnings; 
     32use lib qw(lib); 
     33 
     34use Test::More; 
     35use IO::File (); 
     36use Parrot::Config; 
     37use File::Spec; 
     38 
     39my $path; 
     40my $parrot = File::Spec->catfile( ".", $PConfig{test_prog} ); 
     41 
     42BEGIN { 
     43    $path = File::Spec->catfile( ".", "pdump" ); 
     44    my $exefile = $path . $PConfig{exe}; 
     45    unless ( -f $exefile ) { 
     46        plan skip_all => "pdump hasn't been built. Run make parrot_utils"; 
     47        exit(0); 
     48    } 
     49    plan tests => 2; 
     50} 
     51 
     52output_like( <<PIR, "pir", [qr/'PFC_STRING'/, qr/PFC_PMC/], ''); 
     53.sub main :main 
     54    \$N3 = 3.14159 
     55    print \$N3 
     56    print "\\n" 
     57.end 
     58PIR 
     59 
     60=head1 HELPER SUBROUTINES 
     61 
     62=head2 output_like 
     63 
     64    output_like(<<PASM, "pasm", "some output", "running $file"); 
     65 
     66Takes 3-4 arguments: a file to run, 
     67the filename-extension of the file (probably "pir" or "pasm"), 
     68an arrayref or single regex string to match within pdump's output, 
     69and the optional test diagnostic. 
     70 
     71=cut 
     72 
     73my $testno = 0; 
     74 
     75sub output_like { 
     76    my ( $file, $ext, $check, $diag ) = @_; 
     77    $testno++; 
     78    my $codefn   = "$0.$testno.$ext"; 
     79    my $pbcfn    = "$0.$testno.pbc"; 
     80    my $stdoutfn = "$0.$testno.stdout"; 
     81    my $f        = IO::File->new(">$codefn"); 
     82    $f->print($file); 
     83    $f->close(); 
     84    system("$parrot -o $pbcfn $codefn 2>&1"); 
     85    system("$path $pbcfn >$stdoutfn 2>&1"); 
     86    $f = IO::File->new($stdoutfn); 
     87 
     88    my $output = join( '', <$f> ); 
     89 
     90    local $Test::Builder::Level = $Test::Builder::Level + 1; 
     91    unlink ($codefn, $pbcfn, $stdoutfn); 
     92    if (ref $check eq 'ARRAY') { 
     93        for my $chk (@$check) { 
     94            like( $output, $chk, $diag ); 
     95            $testno++; 
     96        } 
     97    } else { 
     98        like( $output, $check, $diag ); 
     99    } 
     100} 
     101 
     102=head1 TODO 
     103 
     104=over 4 
     105 
     106=item 
     107 
     108Flesh it out.  This is a bare bones proof of concept. 
     109Add tests for all of the commands. 
     110 
     111=back 
     112 
     113=cut 
     114 
     115# Local Variables: 
     116#   mode: cperl 
     117#   cperl-indent-level: 4 
     118#   fill-column: 100 
     119# End: 
     120# vim: expandtab shiftwidth=4: