1 # Copyright (C) 2007, The Perl Foundation.
6 our ( @ISA, @EXPORT_OK );
9 our @srcopsfiles = qw( src/ops/core.ops src/ops/bit.ops src/ops/cmp.ops
10 src/ops/debug.ops src/ops/experimental.ops src/ops/io.ops src/ops/math.ops
11 src/ops/object.ops src/ops/pic.ops src/ops/pmc.ops src/ops/set.ops
12 src/ops/stack.ops src/ops/stm.ops src/ops/string.ops src/ops/sys.ops
14 our $num = "src/ops/ops.num";
15 our $skip = "src/ops/ops.skip";
26 use Parrot
::Ops2pm
::Utils
;
30 my ( $cwd, $tdir, $srcopsref, $num_file, $skip_file ) = @_;
31 my @srcopsfiles = @
$srcopsref;
33 mkdir qq{$tdir/src/ops};
34 mkdir qq{$tdir/src/dynoplibs
};
36 foreach my $f (@srcopsfiles) {
37 copy
( qq{$cwd/$f}, qq{$tdir/$f} );
39 copy
( qq{$cwd/$num}, qq{$tdir/$num} );
40 copy
( qq{$cwd/$skip}, qq{$tdir/$skip} );
41 my @opsfiles = glob("./src/ops/*.ops");
44 mkdir qq{$tdir/lib/Parrot
};
45 mkdir qq{$tdir/lib/Parrot
/Ops2c
};
46 mkdir qq{$tdir/include
};
47 mkdir qq{$tdir/include/parrot
};
48 mkdir qq{$tdir/include/parrot
/oplib
};
50 my $o2p = Parrot
::Ops2pm
::Utils
->new(
53 script
=> "tools/build/ops2pm.pl",
54 moddir
=> "lib/Parrot/OpLib",
60 $o2p->load_op_map_files();
62 $o2p->prepare_real_ops();
65 croak
"Temporary core.pm file not written"
66 unless ( -f
qq|$tdir/$o2p->{moddir}/$o2p->{module
}| );
72 ################### DOCUMENTATION ###################
76 GenerateCore - functionality used in testing Parrot::Ops2c::Utils
80 use lib ("t/tools/ops2cutils/testlib");
81 use GenerateCore qw| generate_core |;
84 src/ops/core.ops src/ops/bit.ops src/ops/cmp.ops
85 src/ops/debug.ops src/ops/experimental.ops src/ops/io.ops
86 src/ops/math.ops src/ops/object.ops src/ops/pic.ops
87 src/ops/pmc.ops src/ops/set.ops src/ops/stack.ops
88 src/ops/stm.ops src/ops/string.ops src/ops/sys.ops
92 $num = "src/ops/ops.num";
93 $skip = "src/ops/ops.skip";
96 $tdir = tempdir( CLEANUP => 1 );
98 $tlib = generate_core(
99 $cwd, $tdir, \@srcopsfiles, $num, $skip);
105 The test suite found in F<t/tools/ops2cutils/> tests the methods of
106 Parrot::Ops2c::Utils. Those methods are invoked by Parrot build tool
107 F<tools/build/ops2c.pl>, which in turn is invoked several times by F<make>.
108 Parrot::Ops2c::Utils has as a prerequisite Parrot::OpLib::core. But
109 Parrot::OpLib::core is not part of the Parrot distribution, nor does it exist
110 at the point F<make> is called. Rather, it is created
111 during the Parrot build process prior to the first call to F<ops2c.pl>.
113 To test Parrot::Ops2c::Utils therefore requires a module which does not exist
114 'pre-F<make>'. The tests in this suite, however, are designed to be run when
115 your filesystem is in a 'post-F<Configure.pl>, pre-F<make>' state. The
116 solution to this conundrum is to create a copy of Parrot::OpLib::core which
117 exists only for the duration of a single test file.
119 This package, GenerateCore, exports upon request a single subroutine,
120 C<generate_core>, which (a) creates subdirectories needed underneath a
121 temporary directory created solely for testing purposes; then
122 (b) creates a temporary copy of Parrot::OpLib::core such that
123 C<Parrot::Ops2c::Utils::new()> can successfully execute.
125 =head2 C<generate_core()>
129 =item * B<Purpose:> (See above.)
131 =item * B<Arguments:> Five scalar arguments, in this order:
133 cwd : String with full path of directory from which
134 tests are invoked (generally, the top-level
136 tdir : String holding full path of temporary
137 directory into which you have changed for
139 \@srcopsfiles : Reference to an array of F<.ops> files
140 (generally, the list of arguments to ops2c.pl
142 $num : Path to ops.num file.
143 $skip : Path to ops.skip file.
145 =item * B<Return Value:> String holding full path to a directory F<lib/>
146 found one level underneath the temporary directory denoted by F<tdir> above.
147 (This is the directory underneath which the temporary copy of
148 Parrot::OpLib::core is created.) The return value may be used in testing as a
149 marker for the creation of all the needed temporary subdirectories and the
150 temporary copy of Parrot::OpLib::core.
160 =item * Parrot::Ops2c::Utils
166 James E Keenan (jkeenan@cpan.org).
172 =item * Parrot::Ops2c::Utils
174 =item * F<tools/build/ops2c.pl>
182 # cperl-indent-level: 4
185 # vim: expandtab shiftwidth=4: