Skip to content

Commit

Permalink
Item13023: Unit tests are not happy with fork to grep
Browse files Browse the repository at this point in the history
The TestBootstrapPlugin loops in the fork to `grep -V` during test to
determine if there is a valid grep program on the default path.

SMELL:  I was unable to debug this.  Perl debugger also failed due to
the fork. Not sure what is going on here.  Temporarily skipping the
probe.  I'd rather use File::Which to actually find the path location
rather than trusting that the path will be stable.  But that's not a
core module, and it's not worth adding another dependency.
  • Loading branch information
gac410 committed Dec 5, 2014
1 parent c2ffab5 commit 28cedb5
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions core/lib/Foswiki/Configure/Load.pm
Expand Up @@ -523,24 +523,34 @@ sub _bootstrapStoreSettings {
"AUTOCONFIG: Detected FastCGI or MS Windows. {Store}{SearchAlgorithm} set to PurePerl\n";
}
else {
# Untaint PATH so we can check for grep on the path
my $x = $ENV{PATH};
$x =~ /^(.*)$/;
$ENV{PATH} = $1;
`grep -V 2>&1`;
if ($!) {
print STDERR
# SMELL: The fork to `grep goes into a loop in the unit tests
# Not sure why, for now just default to pure perl bootstrapping
# in the unit tests.
if ( !$Foswiki::inUnitTestMode ) {

# Untaint PATH so we can check for grep on the path
my $x = $ENV{PATH};
$x =~ /^(.*)$/;
$ENV{PATH} = $1;
`grep -V 2>&1`;
if ($!) {
print STDERR
"AUTOCONFIG: Unable to find a valid 'grep' on the path. Forcing PurePerl search\n";
$Foswiki::cfg{Store}{SearchAlgorithm} =
'Foswiki::Store::SearchAlgorithms::PurePerl';
$Foswiki::cfg{Store}{SearchAlgorithm} =
'Foswiki::Store::SearchAlgorithms::PurePerl';
}
else {
$Foswiki::cfg{Store}{SearchAlgorithm} =
'Foswiki::Store::SearchAlgorithms::Forking';
print STDERR
"AUTOCONFIG: {Store}{SearchAlgorithm} set to Forking\n";
}
$ENV{PATH} = $x; # re-taint
}
else {
$Foswiki::cfg{Store}{SearchAlgorithm} =
'Foswiki::Store::SearchAlgorithms::Forking';
print STDERR
"AUTOCONFIG: {Store}{SearchAlgorithm} set to Forking\n";
'Foswiki::Store::SearchAlgorithms::PurePerl';
}
$ENV{PATH} = $x; # re-taint
}
}

Expand Down

0 comments on commit 28cedb5

Please sign in to comment.