[Rt-commit] rt branch, 4.2/strict-upgrade-scripts, updated. rt-4.0.8-428-g0975b75
Alex Vandiver
alexmv at bestpractical.com
Tue Nov 13 13:44:58 EST 2012
The branch, 4.2/strict-upgrade-scripts has been updated
via 0975b758a7ec0475aef5d41d18870bf68013c41b (commit)
from 6232f784729467566c1c75dd069c737c9c3d0454 (commit)
Summary of changes:
t/99-policy.t | 47 +++++++++++++----------------------------------
1 file changed, 13 insertions(+), 34 deletions(-)
- Log -----------------------------------------------------------------
commit 0975b758a7ec0475aef5d41d18870bf68013c41b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Nov 13 13:39:34 2012 -0500
Use existing check() infrastructure
While this is a slightly looser check than currently exists (use
strict/warnings may occur anywhere in the file), it should suffice as a
base test for all upgrade scrips going forward -- and allows code reuse.
diff --git a/t/99-policy.t b/t/99-policy.t
index c11bfcb..4413040 100644
--- a/t/99-policy.t
+++ b/t/99-policy.t
@@ -7,7 +7,7 @@ use IPC::Run3;
my @files;
find( sub { push @files, $File::Find::name if -f },
- qw{lib share t bin sbin devel/tools} );
+ qw{lib share t bin sbin devel/tools etc} );
if ( my $dir = `git rev-parse --git-dir 2>/dev/null` ) {
# We're in a git repo, use the ignore list
chomp $dir;
@@ -25,6 +25,7 @@ sub check {
shebang => 0,
exec => 0,
bps_tag => 0,
+ compile => 0,
@_,
);
@@ -75,6 +76,15 @@ sub check {
} elsif ($check{exec} == -1) {
ok( !$executable, "$file permission is u-x" );
}
+
+ if ($check{compile}) {
+ my ($input, $output, $error) = ('', '', '');
+ run3(
+ [$^X, '-Ilib', '-Mstrict', '-Mwarnings', '-c', $file],
+ \$input, \$output, \$error,
+ );
+ is $error, "$file syntax OK\n", "$file syntax is OK";
+ }
}
check( $_, shebang => -1, exec => -1, warnings => 1, strict => 1, bps_tag => 1 )
@@ -98,36 +108,5 @@ check( $_, exec => -1 )
check( $_, exec => -1 )
for grep {m{^t/data/}} @files;
-{ # Check to make sure all our upgrade files compile
-my @files = upgrade_files();
-ok( scalar @files, "found content files" );
-
-test_it($_) foreach @files;
-
-sub test_it {
- my $file = shift;
-
- my ($input, $output, $error) = ('', '', '');
- run3(
- [$^X, '-Ilib', '-Mstrict', '-Mwarnings', '-c', $file],
- \$input, \$output, \$error,
- );
- is $error, "$file syntax OK\n", "syntax is OK";
-
- open my $fh, "<", $file or die "$!";
- my ($first, $second) = (grep /\S/, map { chomp; $_ } <$fh>);
- close $fh;
-
- is $first, 'use strict;', 'first not empty line is "use strict;"';
- is $second, 'use warnings;', 'second not empty line is "use warnings;"';
-}
-
-sub upgrade_files {
- my @res;
- find(
- sub { push @res, $File::Find::name if -f && $_ eq 'content' },
- 'etc/upgrade/'
- );
- return @res;
-}
-}
+check( $_, warnings => 1, strict => 1, compile => 1 )
+ for grep {m{^etc/upgrade/.*/content$}} @files;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list