summaryrefslogtreecommitdiff
path: root/t/make_executable.t
diff options
context:
space:
mode:
Diffstat (limited to 't/make_executable.t')
-rw-r--r--t/make_executable.t34
1 files changed, 34 insertions, 0 deletions
diff --git a/t/make_executable.t b/t/make_executable.t
new file mode 100644
index 0000000..330c8ea
--- /dev/null
+++ b/t/make_executable.t
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings FATAL => 'all';
+
+use Config;
+use Test::More tests => 7;
+use ExtUtils::Helpers qw/make_executable/;
+use Cwd qw/cwd/;
+
+my $filename = 'test_exec';
+my @files;
+
+open my $out, '>', $filename or die "Couldn't create $filename: $!";
+print $out "#! perl -w\nexit \$ARGV[0];\n";
+close $out;
+
+make_executable($filename);
+
+foreach my $i (42, 51, 0) {
+ my $cwd = cwd;
+ local $ENV{PATH} = join $Config{path_sep}, $cwd, $ENV{PATH};
+ my $ret = system $filename, $i;
+ is $ret & 0xff, 0, 'test_exec executed successfully';
+ is $ret >> 8, $i, "test_exec $i return value ok";
+}
+
+SKIP: {
+ skip 'No batch file on non-windows', 1 if $^O ne 'MSWin32';
+ push @files, grep { -f } map { $filename.$_ } split / $Config{path_sep} /x, $ENV{PATHEXT};
+ is scalar(@files), 1, "Executable file exists";
+}
+
+unlink $filename, @files;