tagged release 0.6.4
[parrot.git] / t / tools / ops2cutils / 09-dynamic_nolines.t
blobfb8a83034a1a313f0fbd242ebd7c29ab8c270d98
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # 09-dynamic_nolines.t
6 use strict;
7 use warnings;
9 BEGIN {
10     use FindBin qw($Bin);
11     use Cwd qw(cwd realpath);
12     realpath($Bin) =~ m{^(.*\/parrot)\/[^/]*\/[^/]*\/[^/]*$};
13     our $topdir = $1;
14     if ( defined $topdir ) {
15         print "\nOK:  Parrot top directory located\n";
16     }
17     else {
18         $topdir = realpath($Bin) . "/../../..";
19     }
20     unshift @INC, qq{$topdir/lib};
22 use Test::More tests => 38;
23 use Carp;
24 use Cwd;
25 use File::Copy;
26 use File::Temp (qw| tempdir |);
27 use_ok('Parrot::Ops2pm::Utils');
28 use lib ("$main::topdir/t/tools/ops2cutils/testlib");
29 use GenerateCore qw|
30     generate_core
31     @srcopsfiles
32     $num
33     $skip
35 my @dynopsfiles = qw( src/dynoplibs/dan.ops src/dynoplibs/myops.ops );
37 ok( chdir $main::topdir, "Positioned at top-level Parrot directory" );
38 my $cwd = cwd();
41     my $tdir = tempdir( CLEANUP => 1 );
42     ok( chdir $tdir, 'changed to temp directory for testing' );
44     my $tlib = generate_core( $cwd, $tdir, \@srcopsfiles, $num, $skip );
46     ok( -d $tlib, "lib directory created under tempdir" );
47     unshift @INC, $tlib;
48     require Parrot::Ops2c::Utils;
50     foreach my $f (@dynopsfiles) {
51         copy( qq{$cwd/$f}, qq{$tdir/$f} );
52     }
53     chdir "src/dynoplibs" or croak "Unable to change to src/dynoplibs: $!";
55     test_dynops_nolines( [qw( CGoto    myops.ops )] );
56     test_dynops_nolines( [qw( CGP      myops.ops )] );
57     test_dynops_nolines( [qw( C        myops.ops )] );
58     test_dynops_nolines( [qw( CSwitch  myops.ops )] );
59     test_dynops_nolines( [qw( CGoto    dan.ops )] );
60     test_dynops_nolines( [qw( CGP      dan.ops )] );
61     test_dynops_nolines( [qw( C        dan.ops )] );
62     test_dynops_nolines( [qw( CSwitch  dan.ops )] );
64     ok( chdir($cwd), "returned to starting directory" );
67 pass("Completed all tests in $0");
69 sub test_dynops_nolines {
70     my $local_argv_ref = shift;
71     {
72         my $self = Parrot::Ops2c::Utils->new(
73             {
74                 argv => $local_argv_ref,
75                 flag => { dynamic => 1, nolines => 1 },
76             }
77         );
78         ok( defined $self, "Constructor correctly returned when provided >= 1 arguments" );
80         my $c_header_file = $self->print_c_header_file();
81         ok( -e $c_header_file, "$c_header_file created" );
82         ok( -s $c_header_file, "$c_header_file has non-zero size" );
84         my $source = IO::File->new('>' . $$self{source});
85         $self->print_c_source_top($source);
86         $self->print_c_source_bottom($source);
87         $source->close();
88         ok( -s $$self{source}, "file was written" );
89     }
92 ################### DOCUMENTATION ###################
94 =head1 NAME
96 09-dynamic_nolines.t - test C<--nolines> option to F<tools/build/ops2c.pl>.
98 =head1 SYNOPSIS
100     % prove t/tools/ops2cutils/09-dynamic_nolines.t
102 =head1 DESCRIPTION
104 The files in this directory test the publicly callable subroutines of
105 F<lib/Parrot/Ops2c/Utils.pm> and F<lib/Parrot/Ops2c/Auxiliary.pm>.
106 By doing so, they test the functionality of the F<ops2c.pl> utility.
107 That functionality has largely been extracted
108 into the methods of F<Utils.pm>.
110 All the files in this directory are intended to be run B<after>
111 F<Configure.pl> has been run but before F<make> has been called.  Hence, they
112 are B<not> part of the test suite run by F<make test>.   Once you have run
113 F<Configure.pl>, however, you may run these tests as part of F<make
114 buildtools_tests>.
116 F<09-dynamic_nolines.t> tests whether
117 C<Parrot::Ops2c::Utils::new()> work properly when the C<--nolines> and
118 C<--dynamic> options are passed to F<tools/build/ops2c.pl>.
120 =head1 AUTHOR
122 James E Keenan
124 =head1 SEE ALSO
126 Parrot::Ops2c::Auxiliary, F<ops2c.pl>.
128 =cut
130 # Local Variables:
131 #   mode: cperl
132 #   cperl-indent-level: 4
133 #   fill-column: 100
134 # End:
135 # vim: expandtab shiftwidth=4: