[t][TT #1122] Convert t/op/numbert.t to PIR, mgrimes++
[parrot.git] / t / tools / ops2pm / 07-no_ops_skip.t
blob046a5d3f64f4ca14749821fbdf13ff13f022a1bd
1 #! perl
2 # Copyright (C) 2007-2008, Parrot Foundation.
3 # $Id$
4 # 07-no_ops_skip.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 => 14;
23 use Cwd;
24 use File::Copy;
25 use File::Temp (qw| tempdir |);
27 use_ok('Parrot::Ops2pm');
29 use constant NUM_FILE  => "src/ops/ops.num";
30 use constant SKIP_FILE => "src/ops/ops.skip";
32 ok( chdir $main::topdir, "Positioned at top-level Parrot directory" );
34 # fail to provide ops.skip file
36     local @ARGV = qw(
37         src/ops/core.ops
38         src/ops/bit.ops
39     );
40     my $cwd = cwd();
41     {
42         my $tdir = tempdir( CLEANUP => 1 );
43         ok( chdir $tdir, 'changed to temp directory for testing' );
44         ok( ( mkdir qq{$tdir/src} ),     "able to make tempdir/src" );
45         ok( ( mkdir qq{$tdir/src/ops} ), "able to make tempdir/src" );
46         foreach my $f (@ARGV) {
47             ok( copy( qq{$cwd/$f}, qq{$tdir/$f} ), "copied .ops file" );
48         }
49         my $num  = NUM_FILE;
50         my $skip = SKIP_FILE;
51         ok( copy( qq{$cwd/$num}, qq{$tdir/$num} ), "copied ops.num file" );
53         #        ok(copy(qq{$cwd/$skip}, qq{$tdir/$skip}), "copied ops.skip file");
54         my @opsfiles = glob("./src/ops/*.ops");
56         my $self = Parrot::Ops2pm->new(
57             {
58                 argv    => [@opsfiles],
59                 script  => "tools/build/ops2pm.pl",
60                 nolines => undef,
61                 renum   => undef,
62             }
63         );
64         isa_ok( $self, q{Parrot::Ops2pm} );
66         ok( $self->prepare_ops, "prepare_ops() returned successfully" );
67         ok( defined( $self->{ops} ), "'ops' key has been defined" );
69         eval { $self->load_op_map_files(); };
70         like(
71             $@, qr|^Can't open.*src/ops/ops\.skip|,    #'
72             "Failure to prove ops.skip correctly detected"
73         );
75         ok( chdir $cwd, 'changed back to starting directory after testing' );
76     }
79 pass("Completed all tests in $0");
81 ################### DOCUMENTATION ###################
83 =head1 NAME
85 07-no_ops_skip.t - test C<Parrot::Ops2pm::no_ops_skip()>
87 =head1 SYNOPSIS
89     % prove t/tools/ops2pm/07-no_ops_skip.t
91 =head1 DESCRIPTION
93 The files in this directory test the publicly callable subroutines of
94 F<lib/Parrot/Ops2pm.pm> and F<lib/Parrot/Ops2pm/Auxiliary.pm>.
95 By doing so, they test the functionality of the F<ops2pm.pl> utility.
96 That functionality has largely been extracted
97 into the methods of F<Utils.pm>.
99 F<07-no_ops_skip.t> tests what happens when there is no F<src/ops/ops.skip>
100 available for C<load_op_map_files()> to evaluate.
102 =head1 AUTHOR
104 James E Keenan
106 =head1 SEE ALSO
108 Parrot::Ops2pm, F<ops2pm.pl>.
110 =cut
112 # Local Variables:
113 #   mode: cperl
114 #   cperl-indent-level: 4
115 #   fill-column: 100
116 # End:
117 # vim: expandtab shiftwidth=4: