Skip Menu |

This queue is for tickets about the Apache-Filter CPAN distribution.

Report information
The Basics
Id: 13288
Status: new
Priority: 0/
Queue: Apache-Filter

People
Owner: Nobody in particular
Requestors: barbie [...] missbarbell.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.023
Fixed in: (no value)



Subject: Endless looping with automated testing
The _ask() function in t/lib/Apache/test.pm can be written as: sub _ask { # Just a function for asking the user questions my ($prompt, $default, $mustfind, $canskip) = @_; my ($responded,$count,$limit) = (0,0,2); my $skip = defined $canskip ? " ('$canskip' to skip)" : ''; my $response; do { print "$prompt [$default]$skip: "; chomp($response = <STDIN>); $response ||= $default; unless(!$mustfind || ($response eq $canskip) || (-e $response || !print("$response not found\n"))) { $count++; } else { $responded = 1; } } until ($responded || $count > $limit); return $canskip if($count > $limit); return $response; } This may be incomplete, but it does stop the cycle of the default path '/usr/lib/httpd/httpd' not being found and then the check looping forever, or until CTL-C is hit. I suspect some of the recent FAIL reports are due to this. <P> Note that the default install location for Win32 is 'C:\Program Files\Apache Group\Apache\Apache.exe'.
From: barbie [...] missbarbell.co.uk
Scratch the previous entry. The attached patch includes the automated testing change to _ask(), as well as fixing the assumptions about Win32. Barbie.
--- Apache-Filter-1.023\t\lib\Apache\test.pm Fri Jun 17 11:30:18 2005 +++ Apache-Filter-1.023-barbie\t\lib\Apache\test.pm Fri Jun 17 11:26:27 2005 @@ -5,6 +5,8 @@ use Exporter (); use Config; use FileHandle (); +use File::Spec; + *import = \&Exporter::import; @EXPORT = qw(test fetch simple_fetch have_module skip_test @@ -89,6 +91,7 @@ sub _ask { # Just a function for asking the user questions my ($prompt, $default, $mustfind, $canskip) = @_; + my ($responded,$count,$limit) = (0,0,2); my $skip = defined $canskip ? " ('$canskip' to skip)" : ''; my $response; @@ -96,8 +99,15 @@ print "$prompt [$default]$skip: "; chomp($response = <STDIN>); $response ||= $default; - } until (!$mustfind || ($response eq $canskip) || (-e $response || !print("$response not found\n"))); + unless(!$mustfind || ($response eq $canskip) || (-e $response || !print("$response not found\n"))) { + $count++; + } else { + $responded = 1; + } + } until ($responded || $count > $limit); + return $canskip if($count > $limit); + return $response; } @@ -109,7 +119,9 @@ my %conf; - my $httpd = $ENV{'APACHE'} || which('apache') || which('httpd') || '/usr/lib/httpd/httpd'; + my $httpd = $ENV{'APACHE'} || + which('apache') || which('httpd') || which('Apache.exe') || + '/usr/lib/httpd/httpd'; $httpd = _ask("\n", $httpd, 1, '!'); if ($httpd eq '!') { @@ -207,8 +219,10 @@ # Find an executable in the PATH. sub which { - foreach (map { "$_/$_[0]" } split /:/, $ENV{PATH}) { - next unless m,^/,; + my $delim = WIN32() ? ';' : ':' ; + foreach (map { File::Spec->catfile($_,$_[0]) } split /$delim/, $ENV{PATH}) { + print STDERR "which: $_\n"; + next unless m,^/, || WIN32(); return $_ if -x; } }