From cecb985bee3bdd252e1b8dc0bd500b37cd52be01 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 16 May 2007 20:58:53 +0000 Subject: Aktualisierung auf MediaWiki 1.10.0 Plugins angepasst und verbessert kleine Korrekturen am Design --- t/maint/eol-style.t | 35 +++++++++++++++++++++++++++++++++++ t/maint/php-lint.t | 33 +++++++++++++++++++++++++++++++++ t/maint/php-tag.t | 29 +++++++++++++++++++++++++++++ t/maint/unix-newlines.t | 28 ++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 t/maint/eol-style.t create mode 100644 t/maint/php-lint.t create mode 100644 t/maint/php-tag.t create mode 100644 t/maint/unix-newlines.t (limited to 't/maint') 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 $/;

. "" }; + 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 $/;

. "" }; + 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 "; + } elsif ( $cont =~ m<<\? .* \?>>xs ) { + ok 0 => "$file does not use "; + } else { + ok 1 => "$file has neither 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"; + } +} + + + -- cgit v1.2.3-54-g00ecf