Permalink
Browse files

Let's try using a File::Spec function for testing for absoluteness. A…

…dd a regression test for invalid value to '--prefix'.
  • Loading branch information...
1 parent f1d2865 commit 1a0a31c75e4c78a67099ca508e5398aa8ef95b18 @jkeenan jkeenan committed with Reini Urban Aug 6, 2011
Showing with 15 additions and 3 deletions.
  1. +4 −2 lib/Parrot/Configure/Options.pm
  2. +11 −1 t/configure/001-options.t
@@ -9,6 +9,7 @@ our @EXPORT_OK = qw(
process_options
);
use Carp;
+use File::Spec;
use lib qw( lib );
use Parrot::Configure::Options::Conf::CLI ();
use Parrot::Configure::Options::Conf::File ();
@@ -92,8 +93,9 @@ sub _initial_pass {
unless ( $valid_opts{$key} ) {
die qq/Invalid option "$key". See "perl $script --help" for valid options\n/;
}
- if ( $key eq 'prefix' and $value !~ m[^/] ) {
- die qq/Relative path given to --prefix, please pass an absolute path\n/;
+ if ( $key eq 'prefix' and
+ ! File::Spec->file_name_is_absolute( $value) ) {
+ die qq/Relative path given to --prefix, please pass an absolute path/;
}
if ( $options_components->{short_circuits}{$key} ) {
push @short_circuits_seen, $key;
View
@@ -11,7 +11,7 @@ BEGIN {
our $topdir = realpath($Bin) . "/../..";
unshift @INC, qq{$topdir/lib};
}
-use Test::More tests => 51;
+use Test::More tests => 52;
use Carp;
use Parrot::Configure::Options qw| process_options |;
use Parrot::Configure::Options::Conf::CLI ();
@@ -88,6 +88,16 @@ like(
"process_options() failed due to invalid 'mode' argument"
);
+eval { ($args, $step_list_ref) = process_options( {
+ argv => [ '--prefix=my/relative/path' ],
+ mode => q{configure}, } );
+};
+like(
+ $@,
+ qr/Relative path given to --prefix, please pass an absolute path/,
+ "process_options() failed due to relative path as value of 'prefix'",
+);
+
($args, $step_list_ref) = process_options(
{
mode => q{configure},

0 comments on commit 1a0a31c

Please sign in to comment.