This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix warning.
[perl5.git] / lib / ExtUtils / t / prereq_print.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't' if -d 't';
6         @INC = ('../lib', 'lib');
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12
13 use strict;
14 use Config;
15
16 use Test::More;
17
18 unless( eval { require Data::Dumper } ) {
19     plan skip_all => 'Data::Dumper not available';
20 }
21
22 plan tests => 11;
23
24
25 use MakeMaker::Test::Utils;
26 use MakeMaker::Test::Setup::BFD;
27
28 # 'make disttest' sets a bunch of environment variables which interfere
29 # with our testing.
30 delete @ENV{qw(PREFIX LIB MAKEFLAGS)};
31
32 my $Perl = which_perl();
33 my $Makefile = makefile_name();
34 my $Is_VMS = $^O eq 'VMS';
35
36 chdir 't';
37 perl_lib;
38
39 $| = 1;
40
41 ok( setup_recurs(), 'setup' );
42 END {
43     ok( chdir File::Spec->updir );
44     ok( teardown_recurs(), 'teardown' );
45 }
46
47 ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
48   diag("chdir failed: $!");
49
50 unlink $Makefile;
51 my $prereq_out = run(qq{$Perl Makefile.PL "PREREQ_PRINT=1"});
52 ok( !-r $Makefile, "PREREQ_PRINT produces no $Makefile" );
53 is( $?, 0,         '  exited normally' );
54 {
55     package _Prereq::Print;
56     no strict;
57     $PREREQ_PM = undef;  # shut up "used only once" warning.
58     eval $prereq_out;
59     ::is_deeply( $PREREQ_PM, { strict => 0 }, 'prereqs dumped' );
60     ::is( $@, '',                             '  without error' );
61 }
62
63
64 $prereq_out = run(qq{$Perl Makefile.PL "PRINT_PREREQ=1"});
65 ok( !-r $Makefile, "PRINT_PREREQ produces no $Makefile" );
66 is( $?, 0,         '  exited normally' );
67 ::like( $prereq_out, qr/^perl\(strict\) \s* >= \s* 0 \s*$/x, 
68                                                       'prereqs dumped' );
69
70
71 # Currently a bug.
72 #my $prereq_out = run(qq{$Perl Makefile.PL "PREREQ_PRINT=0"});
73 #ok( -r $Makefile, "PREREQ_PRINT=0 produces a $Makefile" );
74 #is( $?, 0,         '  exited normally' );
75 #unlink $Makefile;
76
77 # Currently a bug.
78 #my $prereq_out = run(qq{$Perl Makefile.PL "PRINT_PREREQ=1"});
79 #ok( -r $Makefile, "PRINT_PREREQ=0 produces a $Makefile" );
80 #is( $?, 0,         '  exited normally' );
81 #unlink $Makefile;