2 # Copyright (C) 2007, Parrot Foundation.
4 # 061-revision_from_cache.t
11 # "\nRelevant only when working in checkout from repository and during configuration" )
12 # unless (-e 'DEVELOPING' and ! -e 'Makefile');
14 if (-e 'DEVELOPING' and ! -e 'Makefile') {
19 q{Relevant only when working in checkout from repository and prior to configuration};
25 use File::Temp qw| tempdir |;
27 use Parrot::Revision ();
32 my ($cache, $libdir) = setup_cache($rev, $cwd);
36 my $ret = Parrot::Revision::_handle_update( {
38 revision => $revision,
42 is($ret, q{unknown}, "Got expected return value from _handle_update");
43 unlink qq{$libdir/Parrot/Revision.pm}
44 or croak "Unable to delete file after testing";
45 ok( chdir $cwd, "Able to change back to starting directory");
50 my ($cache, $libdir) = setup_cache($rev, $cwd);
53 my $ret = Parrot::Revision::_handle_update( {
55 revision => $revision,
59 is($ret, $current, "Got expected return value from _handle_update");
60 unlink qq{$libdir/Parrot/Revision.pm}
61 or croak "Unable to delete file after testing";
62 ok( chdir $cwd, "Able to change back to starting directory");
65 { # prev and revision both defined and identical
67 my ($cache, $libdir) = setup_cache($rev, $cwd);
71 my $ret = Parrot::Revision::_handle_update( {
73 revision => $revision,
77 is($ret, $current, "Got expected return value from _handle_update");
78 unlink qq{$libdir/Parrot/Revision.pm}
79 or croak "Unable to delete file after testing";
80 ok( chdir $cwd, "Able to change back to starting directory");
83 { # prev and revision both defined but not identical
85 my ($cache, $libdir) = setup_cache($rev, $cwd);
89 my $ret = Parrot::Revision::_handle_update( {
91 revision => $revision,
95 is($ret, $revision, "Got expected return value from _handle_update");
96 unlink qq{$libdir/Parrot/Revision.pm}
97 or croak "Unable to delete file after testing";
98 ok( chdir $cwd, "Able to change back to starting directory");
101 pass("Completed all tests in $0");
104 ##### SUBROUTINES #####
107 my ($rev, $cwd) = @_;
108 my $tdir = tempdir( CLEANUP => 1 );
109 ok( chdir $tdir, "Changed to temporary directory for testing" );
110 my $libdir = qq{$tdir/lib};
111 ok( (File::Path::mkpath( [ $libdir ], 0, 0777 )), "Able to make libdir");
113 unshift @INC, $libdir;
114 ok( (File::Path::mkpath( [ qq{$libdir/Parrot} ], 0, 0777 )), "Able to make Parrot dir");
115 ok( (copy qq{$cwd/lib/Parrot/Revision.pm},
116 qq{$libdir/Parrot}), "Able to copy Parrot::Revision");
117 my $cache = q{.parrot_current_rev};
118 open my $FH, ">", $cache
119 or croak "Unable to open $cache for writing";
120 print $FH qq{$rev\n};
121 close $FH or croak "Unable to close $cache after writing";
122 return ($cache, $libdir);
125 ################### DOCUMENTATION ###################
129 061-revision_from_cache.t - test Parrot::Revision
133 % prove t/configure/061-revision_from_cache.t
137 The files in this directory test functionality used by F<Configure.pl>.
139 The tests in this file test Parrot::Revision (F<lib/Parrot/Revision.pm>).
147 Parrot::Configure, F<Configure.pl>.
153 # cperl-indent-level: 4
156 # vim: expandtab shiftwidth=4: