2 # Copyright (C) 2007-2010, Parrot Foundation.
9 use Test::More tests => 10;
13 use File::Temp qw( tempdir );
19 q{Relevant only when working in checkout from repository},
21 unless (-e 'DEVELOPING');
23 use_ok('Parrot::Manifest');
26 my $mani = Parrot::Manifest->new( { script => $script, } );
27 isa_ok( $mani, 'Parrot::Manifest' );
30 my $sk = q{MANIFEST.SKIP};
31 my $print_str = $mani->prepare_manifest_skip();
32 ok( $print_str, "prepare_manifest_skip() returned" );
34 # 1: Copy the real MANIFEST.SKIP unaltered to the tempdir.
35 # Assuming the real MANIFEST.SKIP was correct going in to this test, the
36 # absence of any change in it will mean that there will be no need to
39 my $tdir = tempdir( CLEANUP => 1 );
41 or croak "Unable to change to temporary directory for testing";
42 copy( qq{$cwd/$sk}, qq{$tdir/$sk} )
43 or croak "Unable to copy $sk to tempdir";
44 ok( -f $sk, "$sk found in tempdir" );
45 my $need_for_skip = $mani->determine_need_for_manifest_skip($print_str);
46 ok( !$need_for_skip, "No need to regenerate $sk" );
47 unlink qq{$tdir/$sk} or croak "Unable to delete file from tempdir";
49 or croak "Unable to change back from temporary directory after testing";
52 # 2: Copy the real MANIFEST.SKIP to the tempdir but mangle it there.
53 # The alteration in the copied MANIFEST.SKIP will be sufficient to require
54 # regeneration of MANIFEST.SKIP.
56 my $tdir = tempdir( CLEANUP => 1 );
58 or croak "Unable to change to temporary directory for testing";
59 copy( qq{$cwd/$sk}, qq{$tdir/$sk} )
60 or croak "Unable to copy $sk to tempdir";
61 ok( -f $sk, "$sk found in tempdir" );
63 tie @lines, 'Tie::File', qq{$tdir/$sk}
64 or croak "Unable to tie to $sk in tempdir";
67 if ( defined( $lines[-1] ) ) {
71 untie @lines or croak "Unable to untie from $sk";
72 my $need_for_skip = $mani->determine_need_for_manifest_skip($print_str);
73 ok( $need_for_skip, "Need to regenerate $sk" );
74 ok( $mani->print_manifest_skip($print_str), "print_manifest_skip() returned true" );
75 ok( -f $sk, "$sk has been created in tempdir" );
76 unlink qq{$tdir/$sk} or croak "Unable to delete file from tempdir";
78 or croak "Unable to change back from temporary directory after testing";
82 pass("Completed all tests in $0");
84 ################### DOCUMENTATION ###################
88 03-regenerate_skip.t - test C<Parrot::Manifest> MANIFEST.SKIP-related methods
92 % prove t/manifest/03-regenerate_skip.t
96 The files in this directory test the publicly callable methods of
97 F<lib/Parrot/Manifest.pm> and packages which inherit from that package.
99 F<03-regenerate_skip.t> tests whether Parrot::Manifest correctly determines
100 whether MANIFEST.SKIP needs to be regenerated or not.
104 James E Keenan (jkeenan@cpan.org)
108 Parrot::Manifest, Parrot::Manifest::Files, Parrot::Manifest::Skip,
109 F<tools/dev/mk_manifest_and_skip.pl>.
115 # cperl-indent-level: 4
118 # vim: expandtab shiftwidth=4: