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 => 7;
26 use File::Temp (qw| tempdir |);
27 use_ok('Parrot::Ops2pm::Utils');
28 use lib ( "$main::topdir/t/tools/ops2cutils/testlib", "./lib" );
36 ok( chdir $main::topdir, "Positioned at top-level Parrot directory" );
40 my $tdir = tempdir( CLEANUP => 1 );
41 ok( chdir $tdir, 'changed to temp directory for testing' );
44 mkdir qq{$tdir/src/ops};
45 mkdir qq{$tdir/src/dynoplibs};
47 foreach my $f (@srcopsfiles) {
48 copy( qq{$cwd/$f}, qq{$tdir/$f} );
50 copy( qq{$cwd/$num}, qq{$tdir/$num} );
51 copy( qq{$cwd/$skip}, qq{$tdir/$skip} );
52 my @opsfiles = glob("./src/ops/*.ops");
55 mkdir qq{$tdir/lib/Parrot};
56 mkdir qq{$tdir/lib/Parrot/Ops2c};
57 mkdir qq{$tdir/include};
58 mkdir qq{$tdir/include/parrot};
60 my $o2p = Parrot::Ops2pm::Utils->new(
63 script => "tools/build/ops2pm.pl",
64 moddir => "lib/Parrot/OpLib",
70 $o2p->load_op_map_files();
72 $o2p->prepare_real_ops();
75 croak "Temporary core.pm file not written"
76 unless ( -f qq|$tdir/$o2p->{moddir}/$o2p->{module}| );
78 my $tlib = qq{$tdir/lib};
79 ok( -d $tlib, "lib directory created under tempdir" );
81 require Parrot::Ops2c::Utils;
84 local @ARGV = qw( C CGoto CGP CSwitch CPrederef );
85 my $self = Parrot::Ops2c::Utils->new(
88 flag => { core => 1 },
92 "Constructor correctly returned even though include/parrot/oplib had to be created" );
94 ok( chdir($cwd), "returned to starting directory" );
97 pass("Completed all tests in $0");
99 sub test_single_trans {
101 my %available = map { $_, 1 } qw( C CGoto CGP CSwitch CPrederef );
102 croak "Bad argument $trans to test_single_trans()"
103 unless $available{$trans};
105 my $self = Parrot::Ops2c::Utils->new(
108 flag => { core => 1 },
111 ok( defined $self, "Constructor correct when provided with single argument $trans" );
114 ################### DOCUMENTATION ###################
118 07-make_incdir.t - test C<Parrot::Ops2c::Utils::new()>
122 % prove t/tools/ops2cutils/07-make_incdir.t
126 The files in this directory test the publicly callable subroutines of
127 F<lib/Parrot/Ops2c/Utils.pm> and F<lib/Parrot/Ops2c/Auxiliary.pm>.
128 By doing so, they test the functionality of the F<ops2c.pl> utility.
129 That functionality has largely been extracted
130 into the methods of F<Utils.pm>.
132 All the files in this directory are intended to be run B<after>
133 F<Configure.pl> has been run but before F<make> has been called. Hence, they
134 are B<not> part of the test suite run by F<make test>. Once you have run
135 F<Configure.pl>, however, you may run these tests as part of F<make
138 F<07-make_incdir.t> tests whether C<Parrot::Ops2c::Utils::new()>
139 works properly when F<include/parrot/oplib> was not previously created..
147 Parrot::Ops2c::Auxiliary, F<ops2c.pl>.
153 # cperl-indent-level: 4
156 # vim: expandtab shiftwidth=4: