forked from openresty/openresty-devel-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lua-releng
executable file
·52 lines (43 loc) · 1.37 KB
/
lua-releng
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
#!/usr/bin/env perl
use strict;
use warnings;
use File::Slurp qw(read_file);
sub file_contains ($$);
my $version;
for my $file (map glob, qw{ lib/*.lua lib/*/*.lua lib/*/*/*.lua lib/*/*/*/*.lua lib/*/*/*/*/*.lua }) {
# Check the sanity of each .pm file
open my $in, $file or
die "ERROR: Can't open $file for reading: $!\n";
my $found_ver;
while (<$in>) {
my ($ver, $skipping);
if (/(?x) _VERSION \s* = .*? ([\d\.]*\d+) (.*? SKIP)?/) {
my $orig_ver = $ver = $1;
$found_ver = 1;
$skipping = $2;
$ver =~ s{^(\d+)\.(\d{3})(\d{3})$}{join '.', int($1), int($2), int($3)}e;
warn "$file: $orig_ver ($ver)\n";
}
if ($ver and $version and !$skipping) {
if ($version ne $ver) {
die "$file: $ver != $version\n";
}
} elsif ($ver and !$version) {
$version = $ver;
}
}
if (!$found_ver) {
warn "WARNING: No _VERSION field found in `$file`.\n";
}
close $in;
file_contains($file, "attempt to write to undeclared variable");
}
sub file_contains ($$) {
my ($file, $regex) = @_;
my $content = read_file($file);
#print "$content";
return scalar ($content =~ /$regex/);
}
system("ack '.{81}' `find lib -name '*.lua'`");
system(q{ack '\b(?:ONLY|LAST)\b' t});
system(q{ack -l '\r\n' t});