# New Ticket Created by  James Keenan 
# Please include the string:  [perl #52528]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=52528 >


Since the Parrot buildfest we held at the March 27 Toronto Perlmongers
meeting, Seneca Cunningham has pointed out a number of problems which
occur when you try to configure and build Parrot on Darwin in various
ways.  In RT 52214, for example, she pointed out that you can get
adverse results in certain circumstances when you try to build with the
Apple-supplied version of Perl 5.8 rather than a Perl you have built
yourself from source.

Inspired by that, I decided to try Parrot with the Apple-supplied Perl
5.8.6 and the corresponding version of 'prove' (v1.04, using
Test::Harness v2.42 and Perl v5.8.6).  I encountered two problems in the
pre-configuration tests, one of which I will discuss in this ticket.

Calling '/usr/bin/prove t/configure/036-config_steps.t', almost all the
tests fail with output like this:

t/configure/036-config_steps....Warning: Use of "require" without parentheses 
is ambiguous at (eval 4) line 2.
Bareword found where operator expected at (eval 4) line 2, near "/auto/aio"
        (Missing operator before aio?)
#     Failed test (t/configure/036-config_steps.t at line 41)
#     Tried to require 'config/auto/aio.pm'.
#     Error:  syntax error at (eval 4) line 2, near "require config/auto/"
Warning: Use of "require" without parentheses is ambiguous at (eval 5) line 2.
Bareword found where operator expected at (eval 5) line 2, near 
"/auto/alignptrs"
        (Missing operator before alignptrs?)
#     Failed test (t/configure/036-config_steps.t at line 41)
#     Tried to require 'config/auto/alignptrs.pm'.
#     Error:  syntax error at (eval 5) line 2, near "require config/auto/"

This test file always passes when I use my own Perl 5 and the latest
version of 'prove'.

The code failing in 036-config_steps.t is this:

foreach my $step (@steps) {
    require_ok($step);
}

.... where each $step element in @steps has the form 'config/*/*.pm' or
'config/*/*/*.pm'.

The juxtaposition of 'require' and 'bareword' in the error message
called to mind certain parts of 'perldoc -f require':

Test::More::require_ok() does not get much attention in that module's
documentation.  It seems as if it *should* work exactly the same way if
you call:

    require_ok($file)
    # where $file is 'config/init/defaults.pm' (currently used in 036)

... or:

    require_ok($module)
    # where $module is 'init::defaults' and 'config/' has been placed in @INC

... but, for reasons I don't understand, it doesn't in this case.

I figured I would rewrite 036-config_steps.t so that a module was being
required rather than a file.  With this modification, the test again
passes with the Apple-supplied Perl 5.8.6 and the associated 'prove'.  I
have tested this with a vendor-supplied Perl 5 and 'prove' on Debian
Linux as well, and it Does No Harm.

Please review and test out on various OSes with both vendor-supplied
Perl and 'prove' and any user-built or installed Perl or 'prove'.

Thank you very much.
kid51



Index: t/configure/036-config_steps.t
===================================================================
--- t/configure/036-config_steps.t      (revision 26795)
+++ t/configure/036-config_steps.t      (working copy)
@@ -25,7 +25,13 @@
 =cut
 
 my @steps;
-sub wanted { /^.*\.pm\z/s && push @steps, $File::Find::name; }
+sub wanted { $File::Find::name =~ m{^config\/(.*)\.pm\z}s &&
+    do {
+        my $mod = $1;
+        my $class = join '::', ( split /\//, $mod );
+        push @steps, $class;
+    };
+}
 find( { wanted => \&wanted }, 'config' );
 
 if ( $^O !~ /win32/i ) {
@@ -33,10 +39,9 @@
 }
 
 my $testcount = @steps + 2;
+plan tests => $testcount;
+unshift @INC, 'config';
 
-# my $testcount = @steps;
-
-plan tests => $testcount;
 foreach my $step (@steps) {
     require_ok($step);
 }

Reply via email to