[cage] Fix pgegrep, which was merely an innocent bystander in the Great Namespace...
[parrot.git] / t / configure / 017-revision_from_cache.t
blob058bd40fcf633e9f4a5e317704189d9542aec189
1 #! perl
2 # Copyright (C) 2007, Parrot Foundation.
3 # $Id$
4 # 017-revision_from_cache.t
6 use strict;
7 use warnings;
9 use Test::More;
10 plan( skip_all =>
11     "\nRelevant only when working in checkout from repository and during configuration" )
12     unless (-e 'DEVELOPING' and ! -e 'Makefile');
13 plan( tests =>  7 );
14 use Carp;
15 use Cwd;
16 use File::Copy;
17 use File::Path ();
18 use File::Temp qw| tempdir |;
19 use lib qw( lib );
21 my $cwd = cwd();
23     my $rev = 16000;
24     my ($cache, $libdir) = setup_cache($rev, $cwd);
25     require Parrot::Revision;
26     no warnings 'once';
27     is($Parrot::Revision::current, $rev,
28         "Got expected revision number from cache");
29     use warnings;
30     unlink qq{$libdir/Parrot/Revision.pm}
31         or croak "Unable to delete file after testing";
32     ok( chdir $cwd, "Able to change back to starting directory");
35 pass("Completed all tests in $0");
37 ##### SUBROUTINES #####
39 sub setup_cache {
40     my ($rev, $cwd) = @_;
41     my $tdir = tempdir( CLEANUP => 1 );
42     ok( chdir $tdir, "Changed to temporary directory for testing" );
43     my $libdir = qq{$tdir/lib};
44     ok( (File::Path::mkpath( [ $libdir ], 0, 0777 )), "Able to make libdir");
45     local @INC;
46     unshift @INC, $libdir;
47     ok( (File::Path::mkpath( [ qq{$libdir/Parrot} ], 0, 0777 )), "Able to make Parrot dir");
48     ok( (copy qq{$cwd/lib/Parrot/Revision.pm},
49             qq{$libdir/Parrot}), "Able to copy Parrot::Revision");
50     my $cache = q{.parrot_current_rev};
51     open my $FH, ">", $cache
52         or croak "Unable to open $cache for writing";
53     print $FH qq{$rev\n};
54     close $FH or croak "Unable to close $cache after writing";
55     return ($cache, $libdir);
58 ################### DOCUMENTATION ###################
60 =head1 NAME
62 017-revision_from_cache.t - test Parrot::Revision
64 =head1 SYNOPSIS
66     % prove t/configure/017-revision_from_cache.t
68 =head1 DESCRIPTION
70 The files in this directory test functionality used by F<Configure.pl>.
72 The tests in this file test Parrot::Revision (F<lib/Parrot/Revision.pm>).
74 =head1 AUTHOR
76 James E Keenan
78 =head1 SEE ALSO
80 Parrot::Configure, F<Configure.pl>.
82 =cut
84 # Local Variables:
85 #   mode: cperl
86 #   cperl-indent-level: 4
87 #   fill-column: 100
88 # End:
89 # vim: expandtab shiftwidth=4: