use Test::More tests => 4; use Data::Dumper; use Config; =head1 DESCRIPTION This test checks whether the current directory (".") is included in the list returned from File::Spec->path and whether a program in the current directory can be run. The test succeeds when both match. =cut use_ok 'File::Spec'; diag "\$File::Spec::VERSION is $File::Spec::VERSION"; my $tempfile = 'does_only_exist_in_current_directory.cmd'; $/ = ""; my %os = map { split /\r?\n/, $_, 2 } ; my $os = $os{$^O} || $os{'fallback'}; open my $fh, ">", $tempfile or die "Couldn't create '$tempfile': $!"; print {$fh} $os; close $fh; chmod 700, $tempfile; ok -x $tempfile, "'$tempfile' is executable"; my $explicit = File::Spec->catfile( ".", $tempfile ); is system($explicit), 0, "'$tempfile' can be executed as '$explicit'"; my $dot_in_path = grep { $_ eq '.'} File::Spec->path; my $implicit_execution = system( $tempfile ) == 0; diag "The current directory is " . ($dot_in_path ? "" : "not ") . "in File::Spec->path."; diag $_ for File::Spec->path; diag "---"; diag $_ for split /$Config{path_sep}/, $ENV{PATH}; diag "Programs in the current directory can " . ($implicit_execution ? "" : "not ") . "be launched."; is (($dot_in_path xor $implicit_execution), '', "dot is in File::Spec->path or files in the current directory don't get launched") or do { }; END { unlink $tempfile or diag "Couldn't remove '$tempfile': $!"; }; __DATA__ MSWin32 @echo off fallback #!/bin/sh