X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fstructure%2Fno_lexicals_in_postif.t;h=3f906937fd57337d1bc5a2067bb88cc73cd98347;hb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44;hp=960b9ab60ec06fbb05a81aa3a871a6ee5f260750;hpb=267b9e4f94878ad8e03bf0021ece5b6306fd8074;p=kivitendo-erp.git diff --git a/t/structure/no_lexicals_in_postif.t b/t/structure/no_lexicals_in_postif.t index 960b9ab60..3f906937f 100644 --- a/t/structure/no_lexicals_in_postif.t +++ b/t/structure/no_lexicals_in_postif.t @@ -1,11 +1,13 @@ use strict; - use lib 't'; - use Support::Files; +use Test::More; -use Test::More tests => scalar(@Support::Files::testitems); -use PPI; +if (eval { require PPI; 1 }) { + plan tests => scalar(@Support::Files::testitems); +} else { + plan skip_all => "PPI not installed"; +} my $fh; { @@ -23,7 +25,25 @@ my @testitems = @Support::Files::testitems; foreach my $file (@testitems) { my $clean = 1; - my $doc = PPI::Document->new($file); + my $source; + { + # due to a bug in PPI it cannot determine the encoding of a source file by + # use utf8; normaly this would be no problem but some people instist on + # putting strange stuff into the source. as a workaround read in the source + # with :utf8 layer and pass it to PPI by reference + # there are still some latin chars, but it's not the purpose of this test + # to find them, so warnings about it will be ignored + local $^W = 0; # don't care about invalid chars in comments + local $/ = undef; + open my $fh, '<:utf8', $file or die $!; + $source = <$fh>; + } + + my $doc = PPI::Document->new(\$source) or do { + print $fh "?: PPI error for file $file: " . PPI::Document::errstr() . "\n"; + ok 0, $file; + next; + }; my $stmts = $doc->find('Statement::Variable'); for my $var (@{ $stmts || [] }) {