-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuse.t
executable file
·84 lines (70 loc) · 2.25 KB
/
use.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env perl
# -*- mode: perl; coding: utf-8 -*-
#----------------------------------------
use strict;
use warnings qw(FATAL all NONFATAL misc);
use FindBin; BEGIN { do "$FindBin::Bin/t_lib.pl" }
#----------------------------------------
use Test::More;
chdir $FindBin::Bin
or die "chdir to test dir failed: $!";
my $dist_root = "$FindBin::Bin/..";
use File::Find;
my @CORO = qw/Coro Coro::AIO AnyEvent/;
my @M4I = qw/File::AddInc MOP4Import::Base::CLI_JSON/;
my %prereq
= ('YATT::Lite::WebMVC0::DBSchema::DBIC' => [qw/DBIx::Class::Schema/]
, 'YATT::Lite::Test::TestFCGI' => [qw/HTTP::Response/]
, 'YATT::Lite::WebMVC0::Partial::Session3' => [qw/Session::ExpiryFriendly/]
, 'YATT::Lite::Inspector' => [@M4I, qw/Text::Glob/]
, 'YATT::Lite::LanguageServer' => [@M4I, @CORO]
, 'YATT::Lite::LanguageServer::Generic' => [@M4I, @CORO]
, 'YATT::Lite::LanguageServer::Protocol' => [@M4I]
, 'YATT::Lite::LanguageServer::SpecParser' => [@M4I]
, 'YATT::Lite::LanguageServer::Spec2Types' => [@M4I]
, 'YATT::Lite::LRXML::AltTree' => [@M4I]
);
my %ignore; map ++$ignore{$_}, ();
my @modules = ('YATT::Lite');
my (%modules) = ('YATT::Lite' => "$dist_root/Lite.pm");
find {
no_chdir => 1,
wanted => sub {
my $name = $File::Find::name;
return unless $name =~ m{(?:^|/)\w+\.pm$};
$name =~ s{^\Q$dist_root\E/}{YATT/};
$name =~ s{/}{::}g;
$name =~ s{\.pm$}{}g;
return if $ignore{$name};
print "$File::Find::name => $name\n" if $ENV{VERBOSE};
$modules{$name} = $File::Find::name;
push @modules, untaint_any($name);
}}, untaint_any("$dist_root/Lite");
plan tests => 3 * @modules;
foreach my $mod (@modules) {
SKIP: {
if (my $req = $prereq{$mod}) {
foreach my $m (@$req) {
unless (eval "require $m") {
skip "testing $mod requires $m", 3;
}
}
}
require_ok($mod);
ok scalar fgrep(qr/^use strict;$/, $modules{$mod})
, "is strict: $mod";
ok scalar fgrep(qr{^use warnings qw\(FATAL all NONFATAL misc}, $modules{$mod})
, "is warnings $mod";
}
}
sub fgrep {
my ($pattern, $file) = @_;
open my $fh, '<', $file or die "Can't open $file: $!";
my @result;
while (defined(my $line = <$fh>)) {
next unless $line =~ $pattern;
push @result, $line;
}
@result;
}
done_testing();