3 # Here we make sure File::Spec can properly deal with executables.
4 # VMS has some trouble with these.
7 use lib File::Spec->catdir('t', 'lib');
11 : (skip_all => "Can't find an executable file")
14 BEGIN { # Set up a tiny script file
16 open(F, ">rel2abs2rel$$.pl")
17 or die "Can't open rel2abs2rel$$.pl file for script -- $!\n";
18 print F qq(print "ok\\n"\n);
22 1 while unlink("rel2abs2rel$$.pl");
23 1 while unlink("rel2abs2rel$$.tmp");
29 # Change 'perl' to './perl' so the shell doesn't go looking through PATH.
32 $perl = File::Spec->catfile(File::Spec->curdir, $perl) unless
33 File::Spec->file_name_is_absolute($perl);
37 # Make a putative perl binary say "ok\n". We have to do it this way
38 # because the filespec of the binary may contain characters that a
39 # command interpreter considers special, so we can't use the obvious
40 # `$perl -le "print 'ok'"`. And, for portability, we can't use fork().
43 open(STDOUTDUP, '>&STDOUT');
44 open(STDOUT, ">rel2abs2rel$$.tmp")
45 or die "Can't open scratch file rel2abs2rel$$.tmp -- $!\n";
46 system($perl, "rel2abs2rel$$.pl");
47 open(STDOUT, '>&STDOUTDUP');
51 open(F, "rel2abs2rel$$.tmp");
58 print "# Checking manipulations of \$^X=$^X\n";
60 my $perl = safe_rel($^X);
61 is( sayok($perl), "ok\n", "`$perl rel2abs2rel$$.pl` works" );
63 $perl = File::Spec->rel2abs($^X);
64 is( sayok($perl), "ok\n", "`$perl rel2abs2rel$$.pl` works" );
66 $perl = File::Spec->canonpath($perl);
67 is( sayok($perl), "ok\n", "canonpath(rel2abs($^X)) = $perl" );
69 $perl = safe_rel(File::Spec->abs2rel($perl));
70 is( sayok($perl), "ok\n", "safe_rel(abs2rel(canonpath(rel2abs($^X)))) = $perl" );
72 $perl = safe_rel(File::Spec->canonpath($^X));
73 is( sayok($perl), "ok\n", "safe_rel(canonpath($^X)) = $perl" );