2 # Copyright (C) 2007, The Perl Foundation.
11 use Cwd qw(cwd realpath);
12 realpath($Bin) =~ m{^(.*\/parrot)\/[^/]*\/[^/]*\/[^/]*$};
14 if ( defined $topdir ) {
15 print "\nOK: Parrot top directory located\n";
18 $topdir = realpath($Bin) . "/../../..";
20 unshift @INC, qq{$topdir/lib};
22 use Test::More tests => 38;
26 use File::Temp (qw| tempdir |);
27 use_ok('Parrot::Ops2pm::Utils');
28 use lib ("$main::topdir/t/tools/ops2cutils/testlib");
35 my @dynopsfiles = qw( src/dynoplibs/dan.ops src/dynoplibs/myops.ops );
37 ok( chdir $main::topdir, "Positioned at top-level Parrot directory" );
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" );
48 require Parrot::Ops2c::Utils;
50 foreach my $f (@dynopsfiles) {
51 copy( qq{$cwd/$f}, qq{$tdir/$f} );
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;
72 my $self = Parrot::Ops2c::Utils->new(
74 argv => $local_argv_ref,
75 flag => { dynamic => 1, nolines => 1 },
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);
88 ok( -s $$self{source}, "file was written" );
92 ################### DOCUMENTATION ###################
96 09-dynamic_nolines.t - test C<--nolines> option to F<tools/build/ops2c.pl>.
100 % prove t/tools/ops2cutils/09-dynamic_nolines.t
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
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>.
126 Parrot::Ops2c::Auxiliary, F<ops2c.pl>.
132 # cperl-indent-level: 4
135 # vim: expandtab shiftwidth=4: