[svn:parrot] r49802 - in branches/tt532_headerizer_refactor: . t/tools/dev/headerizer

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Mon Nov 8 02:41:51 UTC 2010


Author: jkeenan
Date: Mon Nov  8 02:41:51 2010
New Revision: 49802
URL: https://trac.parrot.org/parrot/changeset/49802

Log:
Create a file to hold tests of Parrot::Headerizer::Functions.

Added:
   branches/tt532_headerizer_refactor/t/tools/dev/headerizer/
   branches/tt532_headerizer_refactor/t/tools/dev/headerizer/01_functions.t
      - copied, changed from r49797, branches/tt532_headerizer_refactor/t/tools/dev/pmctree.t
Modified:
   branches/tt532_headerizer_refactor/MANIFEST

Modified: branches/tt532_headerizer_refactor/MANIFEST
==============================================================================
--- branches/tt532_headerizer_refactor/MANIFEST	Mon Nov  8 02:19:54 2010	(r49801)
+++ branches/tt532_headerizer_refactor/MANIFEST	Mon Nov  8 02:41:51 2010	(r49802)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Mon Nov  8 01:50:18 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Nov  8 02:41:45 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -2052,6 +2052,7 @@
 t/steps/inter/yacc-02.t                                     [test]
 t/stress/gc.t                                               [test]
 t/tools/create_language.t                                   [test]
+t/tools/dev/headerizer/01_functions.t                       [test]
 t/tools/dev/pmctree.t                                       [test]
 t/tools/dev/searchops.t                                     [test]
 t/tools/dev/searchops/samples.pm                            [test]

Copied and modified: branches/tt532_headerizer_refactor/t/tools/dev/headerizer/01_functions.t (from r49797, branches/tt532_headerizer_refactor/t/tools/dev/pmctree.t)
==============================================================================
--- branches/tt532_headerizer_refactor/t/tools/dev/pmctree.t	Mon Nov  8 01:46:54 2010	(r49797, copy source)
+++ branches/tt532_headerizer_refactor/t/tools/dev/headerizer/01_functions.t	Mon Nov  8 02:41:51 2010	(r49802)
@@ -1,333 +1,23 @@
 #! perl
-# Copyright (C) 2007-2010, Parrot Foundation.
+# Copyright (C) 2010, Parrot Foundation.
 # $Id$
-# pmctree.t
+# 01_functions.t
 
 use strict;
 use warnings;
-use Test::More tests => 60;
+use Test::More qw(no_plan); # tests => 60;
 use Cwd;
 use File::Basename;
 use File::Copy;
 use File::Temp qw( tempdir );
 use lib qw( lib );
-use Parrot::Pmc2c::PMC::PrintTree;
+use Parrot::Headerizer::Functions qw(
+    print_headerizer_warnings
+    read_file
+    write_file
+);
 use IO::CaptureOutput qw| capture |;
 
-my ( %opt, @include, @args );
-my $dump_file;
-my $self;
-my $rv;
-my $cwd = cwd();
-
-my @include_orig = qw( src/pmc src/dynpmc );
-
-# @args holds default.pmc; print_tree has no args, defaulting to 0 for depth
-# and contents of @args for files to be printed
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    ok( chdir $tdir, 'changed to temp directory for testing' );
-    touch_parrot();
-    my $pmcdir = q{src/pmc};
-    ok( ( mkdir qq{$tdir/src} ), "created src/ under tempdir" );
-    my $temppmcdir = qq{$tdir/src/pmc};
-    ok( ( mkdir $temppmcdir ), "created src/pmc/ under tempdir" );
-
-    my @pmcfiles     = glob("$cwd/src/pmc/*.pmc");
-    my $pmcfilecount = scalar(@pmcfiles);
-    my $copycount;
-    foreach my $pmcfile (@pmcfiles) {
-        my $basename = basename($pmcfile);
-        my $rv = copy( $pmcfile, qq{$temppmcdir/$basename} );
-        $copycount++ if $rv;
-    }
-    is( $copycount, $pmcfilecount, "all src/pmc/*.pmc files copied to tempdir" );
-    my @include = ( $tdir, $temppmcdir, @include_orig );
-
-    @args = ( qq{$temppmcdir/default.pmc}, );
-    $self = Parrot::Pmc2c::PMC::PrintTree->new(
-        {
-            include => \@include,
-            opt     => {},
-            args    => [@args],
-            bin     => q{},
-        }
-    );
-    isa_ok( $self, q{Parrot::Pmc2c::PMC::PrintTree} );
-    $dump_file = $self->dump_vtable("$cwd/src/vtable.tbl");
-    ok( -e $dump_file, "dump_vtable created vtable.dump" );
-
-    ok( $self->dump_pmc(), "dump_pmc succeeded" );
-    ok( -f qq{$temppmcdir/default.dump}, "default.dump created as expected" );
-
-    my ( $fh, $currfh, $msg );
-    {
-        $currfh = select($fh);
-        open( $fh, '>', \$msg ) or die "Unable to open handle: $!";
-        $rv = $self->print_tree();
-        close $fh or die "Unable to close handle: $!";
-        select($currfh);
-    }
-    ok( $rv, "tree printed for default.dump" );
-    like( $msg, qr/^default$/, "print_tree() correctly reported which .dump was printed" );
-
-    ok( chdir $cwd, "changed back to original directory" );
-}
-
-# @args hold default.pmc and one other .pmc
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    ok( chdir $tdir, 'changed to temp directory for testing' );
-    touch_parrot();
-    my $pmcdir = q{src/pmc};
-    ok( ( mkdir qq{$tdir/src} ), "created src/ under tempdir" );
-    my $temppmcdir = qq{$tdir/src/pmc};
-    ok( ( mkdir $temppmcdir ), "created src/pmc/ under tempdir" );
-
-    my @pmcfiles = ( "$cwd/src/pmc/default.pmc", "$cwd/src/pmc/array.pmc", );
-    my $pmcfilecount = scalar(@pmcfiles);
-    my $copycount;
-    foreach my $pmcfile (@pmcfiles) {
-        my $basename = basename($pmcfile);
-        my $rv = copy( $pmcfile, qq{$temppmcdir/$basename} );
-        $copycount++ if $rv;
-    }
-    is( $copycount, $pmcfilecount, "all src/pmc/*.pmc files copied to tempdir" );
-    my @include = ( $tdir, $temppmcdir, @include_orig );
-
-    @args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
-    $self = Parrot::Pmc2c::PMC::PrintTree->new(
-        {
-            include => \@include,
-            opt     => {},
-            args    => [@args],
-            bin     => q{},
-        }
-    );
-    isa_ok( $self, q{Parrot::Pmc2c::PMC::PrintTree} );
-    $dump_file = $self->dump_vtable("$cwd/src/vtable.tbl");
-    ok( -e $dump_file, "dump_vtable created vtable.dump" );
-
-    ok( $self->dump_pmc(),               "dump_pmc succeeded" );
-    ok( -f qq{$temppmcdir/default.dump}, "default.dump created as expected" );
-    ok( -f qq{$temppmcdir/array.dump},   "array.dump created as expected" );
-
-    my ( $fh, $currfh, $msg );
-    {
-        $currfh = select($fh);
-        open( $fh, '>', \$msg ) or die "Unable to open handle: $!";
-        $rv = $self->print_tree();
-        close $fh or die "Unable to close handle: $!";
-        select($currfh);
-    }
-    ok( $rv, "tree printed for default.dump and array.dump" );
-    like(
-        $msg,
-        qr/^default\nArray\n\s{4}default$/s,
-        "print_tree() correctly reported which .dumps were printed"
-    );
-    ok( chdir $cwd, "changed back to original directory" );
-}
-
-# failure cases:  wrong argument to 'files' key
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    ok( chdir $tdir, 'changed to temp directory for testing' );
-    touch_parrot();
-    my $pmcdir = q{src/pmc};
-    ok( ( mkdir qq{$tdir/src} ), "created src/ under tempdir" );
-    my $temppmcdir = qq{$tdir/src/pmc};
-    ok( ( mkdir $temppmcdir ), "created src/pmc/ under tempdir" );
-
-    my @pmcfiles = ( "$cwd/src/pmc/default.pmc", "$cwd/src/pmc/array.pmc", );
-    my $pmcfilecount = scalar(@pmcfiles);
-    my $copycount;
-    foreach my $pmcfile (@pmcfiles) {
-        my $basename = basename($pmcfile);
-        my $rv = copy( $pmcfile, qq{$temppmcdir/$basename} );
-        $copycount++ if $rv;
-    }
-    is( $copycount, $pmcfilecount, "all src/pmc/*.pmc files copied to tempdir" );
-    my @include = ( $tdir, $temppmcdir, @include_orig );
-
-    @args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
-    $self = Parrot::Pmc2c::PMC::PrintTree->new(
-        {
-            include => \@include,
-            opt     => {},
-            args    => [@args],
-            bin     => q{},
-        }
-    );
-    isa_ok( $self, q{Parrot::Pmc2c::PMC::PrintTree} );
-    $dump_file = $self->dump_vtable("$cwd/src/vtable.tbl");
-    ok( -e $dump_file, "dump_vtable created vtable.dump" );
-
-    ok( $self->dump_pmc(),               "dump_pmc succeeded" );
-    ok( -f qq{$temppmcdir/default.dump}, "default.dump created as expected" );
-    ok( -f qq{$temppmcdir/array.dump},   "array.dump created as expected" );
-
-    eval { $rv = $self->print_tree( { files => {}, } ); };
-    like(
-        $@,
-        qr/Value of 'files' key in call to print_tree\(\) must be array ref/,
-        "Argument to 'files' key must be array ref"
-    );
-
-    eval { $rv = $self->print_tree( { files => [], } ); };
-    like(
-        $@,
-        qr/^Array ref which is value of 'files' key/,
-        "Argument to 'files' key must be array ref with nonzero elements"
-    );
-
-    ok( chdir $cwd, "changed back to original directory" );
-}
-
-# failure case:  no call to dump_pmc before calling print_tree
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    ok( chdir $tdir, 'changed to temp directory for testing' );
-    touch_parrot();
-    my $pmcdir = q{src/pmc};
-    ok( ( mkdir qq{$tdir/src} ), "created src/ under tempdir" );
-    my $temppmcdir = qq{$tdir/src/pmc};
-    ok( ( mkdir $temppmcdir ), "created src/pmc/ under tempdir" );
-
-    my @pmcfiles = ( "$cwd/src/pmc/default.pmc", "$cwd/src/pmc/array.pmc", );
-    my $pmcfilecount = scalar(@pmcfiles);
-    my $copycount;
-    foreach my $pmcfile (@pmcfiles) {
-        my $basename = basename($pmcfile);
-        my $rv = copy( $pmcfile, qq{$temppmcdir/$basename} );
-        $copycount++ if $rv;
-    }
-    is( $copycount, $pmcfilecount, "all src/pmc/*.pmc files copied to tempdir" );
-    my @include = ( $tdir, $temppmcdir, @include_orig );
-
-    @args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
-    $self = Parrot::Pmc2c::PMC::PrintTree->new(
-        {
-            include => \@include,
-            opt     => {},
-            args    => [@args],
-            bin     => q{},
-        }
-    );
-    isa_ok( $self, q{Parrot::Pmc2c::PMC::PrintTree} );
-    $dump_file = $self->dump_vtable("$cwd/src/vtable.tbl");
-    ok( -e $dump_file, "dump_vtable created vtable.dump" );
-
-    ### $self->dump_pmc();
-    {
-        my $stdout;
-        capture(
-            sub { eval { $self->print_tree(); } },
-            \$stdout
-        );
-        like(
-            $@,
-            qr<cannot find file '.*/src/pmc/default.dump'>,
-            "print_tree() predictably failed because dump_pmc() had not been called"
-        );
-    }
-
-    ok( chdir $cwd, "changed back to original directory" );
-}
-
-# failure case:  nothing in @args; no call to dump_pmc before calling print_tree
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    ok( chdir $tdir, 'changed to temp directory for testing' );
-    touch_parrot();
-    my $pmcdir = q{src/pmc};
-    ok( ( mkdir qq{$tdir/src} ), "created src/ under tempdir" );
-    my $temppmcdir = qq{$tdir/src/pmc};
-    ok( ( mkdir $temppmcdir ), "created src/pmc/ under tempdir" );
-
-    my @pmcfiles = ( "$cwd/src/pmc/default.pmc", "$cwd/src/pmc/array.pmc", );
-    my $pmcfilecount = scalar(@pmcfiles);
-    my $copycount;
-    foreach my $pmcfile (@pmcfiles) {
-        my $basename = basename($pmcfile);
-        my $rv = copy( $pmcfile, qq{$temppmcdir/$basename} );
-        $copycount++ if $rv;
-    }
-    is( $copycount, $pmcfilecount, "all src/pmc/*.pmc files copied to tempdir" );
-    my @include = ( $tdir, $temppmcdir, @include_orig );
-
-    @args = ();
-    $self = Parrot::Pmc2c::PMC::PrintTree->new(
-        {
-            include => \@include,
-            opt     => {},
-            args    => [@args],
-            bin     => q{},
-        }
-    );
-    isa_ok( $self, q{Parrot::Pmc2c::PMC::PrintTree} );
-    $dump_file = $self->dump_vtable("$cwd/src/vtable.tbl");
-    ok( -e $dump_file, "dump_vtable created vtable.dump" );
-
-    ### $self->dump_pmc();
-    {
-        my $stdout;
-        capture(
-            sub { eval { $self->print_tree(); } },
-            \$stdout
-        );
-        like(
-            $@,
-            qr<^print_tree\(\) lacked files>,
-            "print_tree() predictably failed because nothing in \@args and dump_pmc() not called"
-        );
-    }
-
-    ok( chdir $cwd, "changed back to original directory" );
-}
-
-# failure case:  called before 'make' has run
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    ok( chdir $tdir, 'changed to temp directory for testing' );
-#    touch_parrot();
-    my $pmcdir = q{src/pmc};
-    ok( ( mkdir qq{$tdir/src} ), "created src/ under tempdir" );
-    my $temppmcdir = qq{$tdir/src/pmc};
-    ok( ( mkdir $temppmcdir ), "created src/pmc/ under tempdir" );
-
-    my @pmcfiles = ( "$cwd/src/pmc/default.pmc", "$cwd/src/pmc/array.pmc", );
-    my $pmcfilecount = scalar(@pmcfiles);
-    my $copycount;
-    foreach my $pmcfile (@pmcfiles) {
-        my $basename = basename($pmcfile);
-        my $rv = copy( $pmcfile, qq{$temppmcdir/$basename} );
-        $copycount++ if $rv;
-    }
-    is( $copycount, $pmcfilecount, "all src/pmc/*.pmc files copied to tempdir" );
-    my @include = ( $tdir, $temppmcdir, @include_orig );
-
-    @args = ();
-    $self = Parrot::Pmc2c::PMC::PrintTree->new(
-        {
-            include => \@include,
-            opt     => {},
-            args    => [@args],
-            bin     => q{},
-        }
-    );
-    isa_ok( $self, q{Parrot::Pmc2c::PMC::PrintTree} );
-    $dump_file = $self->dump_vtable("$cwd/src/vtable.tbl");
-    ok( -e $dump_file, "dump_vtable created vtable.dump" );
-
-    eval { $self->print_tree(); };
-    like($@,
-        qr/^This program may only be called after 'make' has run/,
-        "Got expected error message for running program at wrong time"
-    );
-
-    ok( chdir $cwd, "changed back to original directory" );
-}
 
 pass("Completed all tests in $0");
 
@@ -342,26 +32,18 @@
 
 =head1 NAME
 
-pmctree.t - test C<Parrot::Pmc2c::PMC::PrintTree::print_tree()>
+01_functions.t - Test functions in Parrot::Headerizer::Functions.
 
 =head1 SYNOPSIS
 
-    % prove t/tools/pmc2cutils/pmctree.t
+    % prove t/tools/dev/headerizer/01_functions.t
 
 =head1 DESCRIPTION
 
-The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/PMC::PrintTree.pm>.  By doing so, they test the functionality
-of the F<pmc2c.pl> utility.  That functionality has largely been extracted
-into the methods of F<PMC::PrintTree.pm>.
-
-F<pmctree.t> tests the C<Parrot::Pmc2c::PMC::PrintTree::print_tree()> method.
-This method is I<not> called F<make>. It appears to be intended as an aid in
-debugging once F<make> has run.
-
-So as not to pollute the Parrot build directories with files created
-during the testing process, all functions which create or modify
-files should be called within a temporary directory.
+The files in this directory test the publicly callable subroutines found in 
+F<lib/Parrot/Headerizer/Functions.pm>.  By doing so, they help test the functionality
+of the F<tools/dev/headerizer.pl> utility.
+
 
 =head1 AUTHOR
 
@@ -369,7 +51,7 @@
 
 =head1 SEE ALSO
 
-Parrot::Pmc2c, F<pmc2c.pl>.
+F<tools/dev/headerizer.pl>; F<lib/Parrot/Headerizer/Functions.pm>.
 
 =cut
 


More information about the parrot-commits mailing list