This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade cpan/CPAN-Meta to 2.120630
[perl5.git] / cpan / HTTP-Tiny / t / 00-compile.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8
9
10 use File::Find;
11 use File::Temp qw{ tempdir };
12
13 my @modules;
14 find(
15   sub {
16     return if $File::Find::name !~ /\.pm\z/;
17     my $found = $File::Find::name;
18     $found =~ s{^lib/}{};
19     $found =~ s{[/\\]}{::}g;
20     $found =~ s/\.pm$//;
21     # nothing to skip
22     push @modules, $found;
23   },
24   'lib',
25 );
26
27 my @scripts;
28 if ( -d 'bin' ) {
29     find(
30       sub {
31         return unless -f;
32         my $found = $File::Find::name;
33         # nothing to skip
34         push @scripts, $found;
35       },
36       'bin',
37     );
38 }
39
40 my $plan = scalar(@modules) + scalar(@scripts);
41 $plan ? (plan tests => $plan) : (plan skip_all => "no tests to run");
42
43 {
44     # fake home for cpan-testers
45      local $ENV{HOME} = tempdir( CLEANUP => 1 );
46
47     like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" )
48         for sort @modules;
49
50     SKIP: {
51         eval "use Test::Script 1.05; 1;";
52         skip "Test::Script needed to test script compilation", scalar(@scripts) if $@;
53         foreach my $file ( @scripts ) {
54             my $script = $file;
55             $script =~ s!.*/!!;
56             script_compiles( $file, "$script script compiles" );
57         }
58     }
59 }