[t][TT #1122] Convert t/op/numbert.t to PIR, mgrimes++
[parrot.git] / t / tools / pmc2cutils / 00-qualify.t
blob975cd20ab66a9154eaa400bde1a7431e7eb8f6dd
1 #! perl
2 # Copyright (C) 2006-2007, Parrot Foundation.
3 # $Id$
4 # 00-qualify.t
6 use strict;
7 use warnings;
8 use Test::More tests => 10;
9 use FindBin;
10 use lib ( "$FindBin::Bin/../..", "$FindBin::Bin/../../lib", "$FindBin::Bin/../../../lib", );
11 use_ok('Parrot::Pmc2c::Pmc2cMain');
13 ok( -f "$FindBin::Bin/../../../Makefile",          "Makefile located" );
14 ok( -f "$FindBin::Bin/../../../myconfig",          "myconfig located" );
15 ok( -f "$FindBin::Bin/../../../lib/Parrot/PMC.pm", "lib/Parrot/PMC.pm located" );
17 my ( @files, %sfx );
18 @files = glob("$FindBin::Bin/../../../src/pmc/*");
19 for my $f (@files) {
20     if ( $f =~ m/.*\.(.*)$/ ) {
21         my $s = $1;
22         $sfx{$s}++;
23     }
26 # In src/pmc, we should have only .pmc files (81+ of them), 1 .num file,
27 # and >= .h files none of whose names may begin 'pmc_' (lest they be left over
28 # from a previous build).
29 my $suffixqty = scalar( keys %sfx );
30 ok( ( ( 2 <= $suffixqty ) and ( $suffixqty <= 3 ) ), "only 2 or 3 file suffixes in src/pmc" );
32 ok( $sfx{'num'}, ".num suffix correctly located" );
33 ok( $sfx{'pmc'}, ".pmc suffix correctly located" );
34 if ( $sfx{'h'} ) {
35     my $pmc_leftovers = 0;
36     foreach my $f (@files) {
37         $pmc_leftovers++ if $f =~ m/^pmc_.*\.h$/;
38     }
39     is( $pmc_leftovers, 0, "No left-over 'pmc_*.h' files in src/pmc/" );
41 else {
42     pass("No .h files in src/pmc/");
45 my $message = <<END_OF_MESSAGE;
48 The files in this directory test the publicly callable methods of
49 Parrot::Pmc2c::Pmc2cMain.  By doing so, they test the functionality
50 of the pmc2c.pl utility.
52 Since pmc2c.pl is invoked many times during 'make', tests of its
53 functionality can give meaningful results only if you run them
54 when your file system under the top-level Parrot directory is in
55 a 'pre-make' state, i.e., you have run 'perl Configure.pl' but
56 have *not* yet run 'make'.  These tests should pass if run at
57 that point in the build process, but some will necessarily fail
58 if 'make' has already been executed.  Hence, they should not be
59 included in the set of tests run by 'make test'.
61 In short, these are tests of Parrot::Pmc2c::Pmc2cMain but are *not*
62 tests of Parrot itself.
64 END_OF_MESSAGE
65 pass($message);
66 pass("Completed all tests in $0");
68 ################### DOCUMENTATION ###################
70 =head1 NAME
72 00-qualify.t - Is this the right point to test Parrot build tools?
74 =head1 SYNOPSIS
76     % prove t/tools/pmc2cutils/00-qualify.t
78 =head1 DESCRIPTION
80 The files in this directory test the publicly callable methods of
81 F<lib/Parrot/Pmc2c/Pmc2cMain.pm>.  By doing so, they test the functionality
82 of the F<pmc2c.pl> utility.  That functionality has largely been extracted
83 into the methods of F<Pmc2cMain.pm>.
85 Since F<pmc2c.pl> is invoked during C<make>, tests of its functionality can
86 give meaningful results only if they take into consideration the status of the
87 file structure at particular points in the build process:
89 =over 4
91 =item *
93 after F<Configure.pl> has run but before F<make> has run;
95 =item *
97 at various points while F<make> is running; or
99 =item *
101 once F<make> has completed.
103 =back
105 The tests in F<00-qualify.t> attempt to confirm that you are at the first of
106 these three stages.  It tests for the presence or absence of certain files to
107 form a judgment as to whether F<Configure.pl> has been run (it should have
108 been) and whether F<make> has been run (it should I<not> have been).  The
109 tests make certain assumptions about what files should be present or not --
110 assumptions which may be invalid if the Parrot build process changes in the
111 future.
113 =head1 AUTHOR
115 James E Keenan
117 =head1 SEE ALSO
119 Parrot::Pmc2c, F<pmc2c.pl>.
121 =cut
123 # Local Variables:
124 #   mode: cperl
125 #   cperl-indent-level: 4
126 #   fill-column: 100
127 # End:
128 # vim: expandtab shiftwidth=4: