[svn:Module-Build] r12875 - in Module-Build/trunk: . lib/Module/Build t

[email protected]
Newsgroups perl.module.build.checkins
Message-ID <[email protected]>
Author: kwilliams
Date: Sun Jun 21 19:08:53 2009
New Revision: 12875

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/t/basic.t

Log:
Fix include_dirs to accept a single string argument, as documented

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes	(original)
+++ Module-Build/trunk/Changes	Sun Jun 21 19:08:53 2009
@@ -12,6 +12,8 @@
  - Run PL files that don't generate any file (RT#39365)
  - HTML generation failure no longer fatal (RT#36660)
  - realclean might not delete Build.bat on Windows (RT#43863)
+ - include_dirs parameter now works correctly when given a single
+   string argument (RT#40177)
 
  Other
  - On MSWin32, bumped File::Spec prereq to 3.30 for a variety of fixes

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm	(original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm	Sun Jun 21 19:08:53 2009
@@ -165,11 +165,16 @@
   $p->{requires} = delete $p->{prereq} if defined $p->{prereq};
   $p->{script_files} = delete $p->{scripts} if defined $p->{scripts};
 
-  # Convert to arrays
+  # Convert to from shell strings to arrays
   for ('extra_compiler_flags', 'extra_linker_flags') {
     $p->{$_} = [ $self->split_like_shell($p->{$_}) ] if exists $p->{$_};
   }
 
+  # Convert to arrays
+  for ('include_dirs') {
+    $p->{$_} = [ $p->{$_} ] if exists $p->{$_} && !ref $p->{$_}
+  }
+
   $self->add_to_cleanup( @{delete $p->{add_to_cleanup}} )
     if $p->{add_to_cleanup};
 
@@ -1760,6 +1765,11 @@
     $args{$_} = [ $self->split_like_shell($args{$_}) ] if exists $args{$_};
   }
 
+  # Convert to arrays
+  for ('include_dirs') {
+    $args{$_} = [ $args{$_} ] if exists $args{$_} && !ref $args{$_}
+  }
+
   # Hashify these parameters
   for ($self->hash_properties, 'config') {
     next unless exists $args{$_};

Modified: Module-Build/trunk/t/basic.t
==============================================================================
--- Module-Build/trunk/t/basic.t	(original)
+++ Module-Build/trunk/t/basic.t	Sun Jun 21 19:08:53 2009
@@ -2,7 +2,7 @@
 
 use strict;
 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
-use MBTest tests => 52;
+use MBTest tests => 60;
 
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
@@ -203,6 +203,38 @@
   is_deeply $mb->extra_linker_flags,   ['-L/foo', '-L/bar'], "Should split shell string into list";
 }
 
+# Test include_dirs.
+{
+  ok my $mb = Module::Build->new(
+    module_name => $dist->name,
+    include_dirs => [qw(/foo /bar)],
+  );
+  is_deeply $mb->include_dirs, ['/foo', '/bar'], 'Should have include dirs';
+
+  # Try a string.
+  ok $mb = Module::Build->new(
+    module_name => $dist->name,
+    include_dirs => '/foo',
+  );
+  is_deeply $mb->include_dirs, ['/foo'], 'Should have string include dir';
+
+  # Try again with command-line args
+  eval { Module::Build->run_perl_script(
+      'Build.PL', [],
+      ['--include_dirs', '/foo', '--include_dirs', '/bar' ],
+  ) };
+
+  ok $mb = Module::Build->resume;
+  is_deeply $mb->include_dirs, ['/foo', '/bar'], 'Should have include dirs';
+
+  eval { Module::Build->run_perl_script(
+      'Build.PL', [],
+      ['--include_dirs', '/foo' ],
+  ) };
+
+  ok $mb = Module::Build->resume;
+  is_deeply $mb->include_dirs, ['/foo'], 'Should have single include dir';
+}
 
 # cleanup
 $dist->remove;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.