summaryrefslogtreecommitdiff
path: root/t/maint
diff options
context:
space:
mode:
Diffstat (limited to 't/maint')
-rw-r--r--t/maint/eol-style.t35
-rw-r--r--t/maint/php-lint.t33
-rw-r--r--t/maint/php-tag.t29
-rw-r--r--t/maint/unix-newlines.t28
4 files changed, 125 insertions, 0 deletions
diff --git a/t/maint/eol-style.t b/t/maint/eol-style.t
new file mode 100644
index 00000000..d877a264
--- /dev/null
+++ b/t/maint/eol-style.t
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+#
+# Based on php-tag.t
+#
+use strict;
+use warnings;
+
+use Test::More;
+use File::Find;
+use IPC::Open3;
+use File::Spec;
+use Symbol qw(gensym);
+
+my $ext = qr/(?: php | inc | txt | sql | t)/x;
+my @files;
+
+find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' );
+
+plan tests => scalar @files ;
+
+for my $file (@files) {
+ open NULL, '+>', File::Spec->devnull and \*NULL or die;
+ my $pid = open3('<&NULL', \*P, '>&NULL', qw'svn propget svn:eol-style', $file);
+ my $res = do { local $/; <P> . "" };
+ chomp $res;
+ waitpid $pid, 0;
+
+ if ( $? != 0 ) {
+ ok 1 => "svn propget failed, $file probably not under version control";
+ } elsif ( $res eq 'native' ) {
+ ok 1 => "$file svn:eol-style is 'native'";
+ } else {
+ ok 0 => "$file svn:eol-style is '$res', should be 'native'";
+ }
+}
diff --git a/t/maint/php-lint.t b/t/maint/php-lint.t
new file mode 100644
index 00000000..e65d6895
--- /dev/null
+++ b/t/maint/php-lint.t
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+#
+# Based on php-tag.t and eol-style
+#
+use strict;
+use warnings;
+
+use Test::More;
+use File::Find;
+use IPC::Open3;
+use File::Spec;
+use Symbol qw(gensym);
+
+my $ext = qr/(?: php | inc )/x;
+my @files;
+
+find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' );
+
+plan tests => scalar @files ;
+
+for my $file (@files) {
+ open NULL, '+>', File::Spec->devnull and \*NULL or die;
+ my $pid = open3('<&NULL', \*P, '>&NULL', qw'php -l', $file);
+ my $res = do { local $/; <P> . "" };
+ chomp $res;
+ waitpid $pid, 0;
+
+ if ( $? == 0 ) {
+ ok 1 => "Looks fine";
+ } else {
+ ok 0 => "$file does not pass php linter. Error was: $res";
+ }
+}
diff --git a/t/maint/php-tag.t b/t/maint/php-tag.t
new file mode 100644
index 00000000..80b870b7
--- /dev/null
+++ b/t/maint/php-tag.t
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More;;
+
+use File::Find;
+use File::Slurp qw< slurp >;
+
+my $ext = qr/(?: php | inc )/x;
+
+my @files;
+find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' );
+
+plan tests => scalar @files;
+
+for my $file (@files) {
+ my $cont = slurp $file;
+ if ( $cont =~ m<<\?php .* \?>>xs ) {
+ ok 1 => "$file has <?php ?>";
+ } elsif ( $cont =~ m<<\? .* \?>>xs ) {
+ ok 0 => "$file does not use <? ?>";
+ } else {
+ ok 1 => "$file has neither <?php ?> nor <? ?>, check it";
+ }
+}
+
+
+
diff --git a/t/maint/unix-newlines.t b/t/maint/unix-newlines.t
new file mode 100644
index 00000000..91a24ad7
--- /dev/null
+++ b/t/maint/unix-newlines.t
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More;;
+
+use File::Find;
+use File::Slurp qw< slurp >;
+use Socket qw< $CRLF $LF >;
+
+my $ext = qr/(?: t | pm | sql | js | php | inc | xml )/x;
+
+my @files;
+find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' );
+
+plan tests => scalar @files;
+
+for my $file (@files) {
+ my $cont = slurp $file;
+ if ( $cont and $cont =~ $CRLF ) {
+ ok 0 => "$file contains windows newlines";
+ } else {
+ ok 1 => "$file is made of unix newlines and win";
+ }
+}
+
+
+