From: Ilmari Karonen Date: Sat, 27 Jan 2007 15:37:02 +0000 (+0000) Subject: backtick version broke on file names with shell metachars (like spaces); rewrite... X-Git-Tag: 1.31.0-rc.0~54174 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=6cbb854b7ad558c48520950cb4690798deb538b5;p=lhc%2Fweb%2Fwiklou.git backtick version broke on file names with shell metachars (like spaces); rewrite to use open3() --- diff --git a/t/maint/eol-style.t b/t/maint/eol-style.t index eb5be1bd5b..d877a264f5 100644 --- a/t/maint/eol-style.t +++ b/t/maint/eol-style.t @@ -7,6 +7,9 @@ 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; @@ -16,15 +19,17 @@ find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' ); plan tests => scalar @files ; for my $file (@files) { - my $res = `svn propget svn:eol-style $file 2>&1` ; + 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( $res =~ 'native' ) { + 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'"; - } elsif( $res =~ substr( $file, 2 ) ) { - # not under version control - ok 1 => "File not under version control"; - next; } else { - ok 0 => "svn:eol-style not native $file"; + ok 0 => "$file svn:eol-style is '$res', should be 'native'"; } }