16fb12b70Safresh1#!./perl 26fb12b70Safresh1 36fb12b70Safresh1use VMS::Filespec; 46fb12b70Safresh1use File::Spec; 56fb12b70Safresh1 66fb12b70Safresh1foreach (<DATA>) { 76fb12b70Safresh1 chomp; 86fb12b70Safresh1 s/\s*#.*//; 96fb12b70Safresh1 next if /^\s*$/; 106fb12b70Safresh1 push(@tests,$_); 116fb12b70Safresh1} 126fb12b70Safresh1 136fb12b70Safresh1require 'test.pl'; 146fb12b70Safresh1plan(tests => scalar(2*@tests)+6); 156fb12b70Safresh1 166fb12b70Safresh1my $vms_unix_rpt; 176fb12b70Safresh1my $vms_efs; 186fb12b70Safresh1 196fb12b70Safresh1if ($^O eq 'VMS') { 206fb12b70Safresh1 if (eval 'require VMS::Feature') { 216fb12b70Safresh1 $vms_unix_rpt = VMS::Feature::current("filename_unix_report"); 226fb12b70Safresh1 $vms_efs = VMS::Feature::current("efs_charset"); 236fb12b70Safresh1 } else { 246fb12b70Safresh1 my $unix_rpt = $ENV{'DECC$FILENAME_UNIX_REPORT'} || ''; 256fb12b70Safresh1 my $efs_charset = $ENV{'DECC$EFS_CHARSET'} || ''; 266fb12b70Safresh1 $vms_unix_rpt = $unix_rpt =~ /^[ET1]/i; 276fb12b70Safresh1 $vms_efs = $efs_charset =~ /^[ET1]/i; 286fb12b70Safresh1 } 296fb12b70Safresh1} 306fb12b70Safresh1 316fb12b70Safresh1 326fb12b70Safresh1 336fb12b70Safresh1foreach $test (@tests) { 346fb12b70Safresh1 ($arg,$func,$expect2,$expect5) = split(/(?<!\\)\s+/,$test); 356fb12b70Safresh1 366fb12b70Safresh1 $arg =~ s/\\//g; # to get whitespace into the argument escape with \ 37b8851fccSafresh1 $expect2 =~ s/\\//g; 38b8851fccSafresh1 $expect5 =~ s/\\//g; 396fb12b70Safresh1 $expect2 = undef if $expect2 eq 'undef'; 406fb12b70Safresh1 $expect2 = undef if $expect2 eq '^'; 416fb12b70Safresh1 $expect5 = undef if $expect5 eq 'undef'; 426fb12b70Safresh1 $expect5 = $expect2 if $expect5 eq '^'; 436fb12b70Safresh1 446fb12b70Safresh1 if ($vms_efs) { 456fb12b70Safresh1 $expect = $expect5; 466fb12b70Safresh1 } 476fb12b70Safresh1 else { 486fb12b70Safresh1 $expect = $expect2; 496fb12b70Safresh1 } 506fb12b70Safresh1 516fb12b70Safresh1 $rslt = eval "$func('$arg')"; 526fb12b70Safresh1 is($@, '', "eval ${func}('$arg')"); 536fb12b70Safresh1 if ($expect ne '^*') { 546fb12b70Safresh1 is(lc($rslt), lc($expect), "${func}('$arg'): '$rslt'"); 556fb12b70Safresh1 } 566fb12b70Safresh1 else { 576fb12b70Safresh1 is(lc($rslt), lc($expect), "${func}('$arg'): '$rslt' # TODO fix ODS-5 test"); 586fb12b70Safresh1 } 596fb12b70Safresh1} 606fb12b70Safresh1 616fb12b70Safresh1$defwarn = <<'EOW'; 626fb12b70Safresh1# Note: This failure may have occurred because your default device 636fb12b70Safresh1# was set using a non-concealed logical name. If this is the case, 646fb12b70Safresh1# you will need to determine by inspection that the two resultant 656fb12b70Safresh1# file specifications shown above are in fact equivalent. 666fb12b70Safresh1EOW 676fb12b70Safresh1 686fb12b70Safresh1is(uc(rmsexpand('[]')), "\U$ENV{DEFAULT}", 'rmsexpand()') || print $defwarn; 696fb12b70Safresh1is(lc(rmsexpand('from.here')),"\L$ENV{DEFAULT}from.here") || print $defwarn; 706fb12b70Safresh1is(lc(rmsexpand('from')), "\L$ENV{DEFAULT}from") || print $defwarn; 716fb12b70Safresh1 726fb12b70Safresh1is(lc(rmsexpand('from.here','cant:[get.there];2')), 736fb12b70Safresh1 'cant:[get.there]from.here;2') || print $defwarn; 746fb12b70Safresh1 756fb12b70Safresh1 766fb12b70Safresh1# Make sure we're using redirected mkdir, which strips trailing '/', since 776fb12b70Safresh1# the CRTL's mkdir can't handle this. 786fb12b70Safresh1ok(mkdir('testdir/',0777), 'using redirected mkdir()'); 796fb12b70Safresh1ok(rmdir('testdir/'), ' rmdir()'); 806fb12b70Safresh1 816fb12b70Safresh1__DATA__ 826fb12b70Safresh1 836fb12b70Safresh1# Column definitions: 846fb12b70Safresh1# 856fb12b70Safresh1# Column 1: Argument (path spec to be transformed) 866fb12b70Safresh1# Column 2: Function that is to do the transformation 876fb12b70Safresh1# Column 3: Expected result when DECC$EFS_CHARSET is not in effect 886fb12b70Safresh1# Column 4: Expected result when DECC$EFS_CHARSET is in effect 896fb12b70Safresh1# ^ means expect same result for EFS as for non-EFS 906fb12b70Safresh1# ^* means TODO when EFS is in effect 916fb12b70Safresh1 926fb12b70Safresh1# lots of underscores used to minimize collision with existing logical names 936fb12b70Safresh1 946fb12b70Safresh1# Basic VMS to Unix filespecs 956fb12b70Safresh1__some_:[__where_.__over_]__the_.__rainbow_ unixify /__some_/__where_/__over_/__the_.__rainbow_ ^ 966fb12b70Safresh1__some_:<__where_.__over_>__the_.__rainbow_ unixify /__some_/__where_/__over_/__the_.__rainbow_ ^ 976fb12b70Safresh1[.__some_.__where_.__over_]__the_.__rainbow_ unixify __some_/__where_/__over_/__the_.__rainbow_ ^ 986fb12b70Safresh1[-.__some_.__where_.__over_]__the_.__rainbow_ unixify ../__some_/__where_/__over_/__the_.__rainbow_ ^ 996fb12b70Safresh1[.__some_.--.__where_.__over_]__the_.__rainbow_ unixify __some_/../../__where_/__over_/__the_.__rainbow_ ^ 1006fb12b70Safresh1[.__some_...__where_.__over_]__the_.__rainbow_ unixify __some_/.../__where_/__over_/__the_.__rainbow_ ^ 1016fb12b70Safresh1[...__some_.__where_.__over_]__the_.__rainbow_ unixify .../__some_/__where_/__over_/__the_.__rainbow_ ^ 1026fb12b70Safresh1[.__some_.__where_.__over_...]__the_.__rainbow_ unixify __some_/__where_/__over_/.../__the_.__rainbow_ ^ 1036fb12b70Safresh1[.__some_.__where_.__over_...] unixify __some_/__where_/__over_/.../ ^ 1046fb12b70Safresh1[.__some_.__where_.__over_.-] unixify __some_/__where_/__over_/../ ^ 1056fb12b70Safresh1[] unixify ./ ^ 1066fb12b70Safresh1[-] unixify ../ ^ 1076fb12b70Safresh1[--] unixify ../../ ^ 1086fb12b70Safresh1[...] unixify .../ ^ 1096fb12b70Safresh1__lyrics_:[__are_.__very_^.__sappy_]__but_^.__rhymes_^.__are_.__true_ unixify /__lyrics_/__are_/__very_.__sappy_/__but_.__rhymes_.__are_.__true_ ^ 1106fb12b70Safresh1[.$(macro)] unixify $(macro)/ ^ 111b8851fccSafresh1^+foo.tmp unixify +foo.tmp ^ 112b8851fccSafresh1[-.foo^_^_bar] unixify ../foo\ \ bar/ ^ 113b8851fccSafresh1[]foo.tmp unixify ./foo.tmp ^ 1146fb12b70Safresh1 1156fb12b70Safresh1# and back again 1166fb12b70Safresh1/__some_/__where_/__over_/__the_.__rainbow_ vmsify __some_:[__where_.__over_]__the_.__rainbow_ ^ 1176fb12b70Safresh1__some_/__where_/__over_/__the_.__rainbow_ vmsify [.__some_.__where_.__over_]__the_.__rainbow_ ^ 1186fb12b70Safresh1../__some_/__where_/__over_/__the_.__rainbow_ vmsify [-.__some_.__where_.__over_]__the_.__rainbow_ ^ 1196fb12b70Safresh1__some_/../../__where_/__over_/__the_.__rainbow_ vmsify [.__some_.--.__where_.__over_]__the_.__rainbow_ ^ 1206fb12b70Safresh1.../__some_/__where_/__over_/__the_.__rainbow_ vmsify [...__some_.__where_.__over_]__the_.__rainbow_ ^ 1216fb12b70Safresh1__some_/.../__where_/__over_/__the_.__rainbow_ vmsify [.__some_...__where_.__over_]__the_.__rainbow_ ^ 1226fb12b70Safresh1/__some_/.../__where_/__over_/__the_.__rainbow_ vmsify __some_:[...__where_.__over_]__the_.__rainbow_ ^ 1236fb12b70Safresh1__some_/__where_.DIR;1 vmsify [.__some_]__where_.DIR;1 ^ 1246fb12b70Safresh1__some_/_;_where_.DIR;1 vmsify [.__some_]_^;_where_.DIR;1 ^ 1256fb12b70Safresh1__some_/__where_/... vmsify [.__some_.__where_...] ^ 1266fb12b70Safresh1/__where_/... vmsify __where_:[...] ^ 1276fb12b70Safresh1. vmsify [] ^ 1286fb12b70Safresh1.. vmsify [-] ^ 1296fb12b70Safresh1../.. vmsify [--] ^ 1306fb12b70Safresh1.../ vmsify [...] ^ 1316fb12b70Safresh1/ vmsify sys$disk:[000000] ^ 1326fb12b70Safresh1./$(macro)/ vmsify [.$(macro)] ^ 1336fb12b70Safresh1./$(macro) vmsify []$(macro) ^ 1346fb12b70Safresh1./$(m+ vmsify []$^(m^+ ^ 1356fb12b70Safresh1foo-bar-0^.01/ vmsify [.foo-bar-0_01] [.foo-bar-0^.01] 1366fb12b70Safresh1\ foo.tmp vmsify ^_foo.tmp ^ 137b8851fccSafresh1+foo.tmp vmsify ^+foo.tmp ^ 138b8851fccSafresh1../foo\ \ bar/ vmsify [-.foo^_^_bar] ^ 139b8851fccSafresh1./foo.tmp vmsify []foo.tmp ^ 140*9f11ffb7Safresh1x/r*??????? vmsify [.x]r*??????? ^ 141b8851fccSafresh1 1426fb12b70Safresh1# Fileifying directory specs 1436fb12b70Safresh1__down_:[__the_.__garden_.__path_] fileify __down_:[__the_.__garden_]__path_.dir;1 ^ 1446fb12b70Safresh1[.__down_.__the_.__garden_.__path_] fileify [.__down_.__the_.__garden_]__path_.dir;1 ^ 1456fb12b70Safresh1/__down_/__the_/__garden_/__path_ fileify /__down_/__the_/__garden_/__path_.dir;1 ^ 1466fb12b70Safresh1/__down_/__the_/__garden_/__path_/ fileify /__down_/__the_/__garden_/__path_.dir;1 ^ 1476fb12b70Safresh1__down_/__the_/__garden_/__path_ fileify __down_/__the_/__garden_/__path_.dir;1 ^ 1486fb12b70Safresh1__down_:[__the_.__garden_]__path_ fileify __down_:[__the_.__garden_]__path_.dir;1 ^ 1496fb12b70Safresh1__down_:[__the_.__garden_]__path_. fileify ^ __down_:[__the_.__garden_]__path_^..dir;1 # N.B. trailing . ==> null type 1506fb12b70Safresh1__down_:[__the_]__garden_.__path_ fileify ^ __down_:[__the_]__garden_^.__path_.dir;1 #undef 1516fb12b70Safresh1/__down_/__the_/__garden_/__path_. fileify ^ /__down_/__the_/__garden_/__path_..dir;1 # N.B. trailing . ==> null type 1526fb12b70Safresh1/__down_/__the_/__garden_.__path_ fileify ^ /__down_/__the_/__garden_.__path_.dir;1 1536fb12b70Safresh1__down_::__the_:[__garden_.__path_] fileify __down_::__the_:[__garden_]__path_.dir;1 ^ 1546fb12b70Safresh1__down_::__the_:[__garden_] fileify __down_::__the_:[000000]__garden_.dir;1 ^ 1556fb12b70Safresh1 1566fb12b70Safresh1# and pathifying them 1576fb12b70Safresh1__down_:[__the_.__garden_]__path_.dir;1 pathify __down_:[__the_.__garden_.__path_] ^ 1586fb12b70Safresh1[.__down_.__the_.__garden_]__path_.dir pathify [.__down_.__the_.__garden_.__path_] ^ 1596fb12b70Safresh1/__down_/__the_/__garden_/__path_.dir pathify /__down_/__the_/__garden_/__path_/ ^ 1606fb12b70Safresh1__down_/__the_/__garden_/__path_.dir pathify __down_/__the_/__garden_/__path_/ ^ 1616fb12b70Safresh1__down_:[__the_.__garden_]__path_ pathify __down_:[__the_.__garden_.__path_] ^ 1626fb12b70Safresh1__down_:[__the_.__garden_]__path_. pathify ^ __down_:[__the_.__garden_.__path_^.] # N.B. trailing . ==> null type 1636fb12b70Safresh1__down_:[__the_]__garden_.__path_ pathify ^ __down_:[__the_.__garden_^.__path_] # undef 1646fb12b70Safresh1/__down_/__the_/__garden_/__path_. pathify /__down_/__the_/__garden_/__path__/ /__down_/__the_/__garden_/__path_./ # N.B. trailing . ==> null type 1656fb12b70Safresh1/__down_/__the_/__garden_.__path_ pathify /__down_/__the_/__garden____path_/ /__down_/__the_/__garden_.__path_/ 1666fb12b70Safresh1__down_:[__the_.__garden_]__path_.dir;2 pathify ^ #N.B. ;2 1676fb12b70Safresh1__path_ pathify __path_/ ^ 1686fb12b70Safresh1/__down_/__the_/__garden_/. pathify /__down_/__the_/__garden_/./ ^ 1696fb12b70Safresh1/__down_/__the_/__garden_/.. pathify /__down_/__the_/__garden_/../ ^ 1706fb12b70Safresh1/__down_/__the_/__garden_/... pathify /__down_/__the_/__garden_/.../ ^ 1716fb12b70Safresh1__path_.notdir pathify __path__notdir/ __path_.notdir/ 1726fb12b70Safresh1 1736fb12b70Safresh1# Both VMS/Unix and file/path conversions 1746fb12b70Safresh1__down_:[__the_.__garden_]__path_.dir;1 unixpath /__down_/__the_/__garden_/__path_/ ^ 1756fb12b70Safresh1/__down_/__the_/__garden_/__path_ vmspath __down_:[__the_.__garden_.__path_] ^ 1766fb12b70Safresh1__down_:[__the_.__garden_.__path_] unixpath /__down_/__the_/__garden_/__path_/ ^ 1776fb12b70Safresh1__down_:[__the_.__garden_.__path_...] unixpath /__down_/__the_/__garden_/__path_/.../ ^ 1786fb12b70Safresh1/__down_/__the_/__garden_/__path_.dir vmspath __down_:[__the_.__garden_.__path_] ^ 1796fb12b70Safresh1[.__down_.__the_.__garden_]__path_.dir unixpath __down_/__the_/__garden_/__path_/ ^ 1806fb12b70Safresh1__down_/__the_/__garden_/__path_ vmspath [.__down_.__the_.__garden_.__path_] ^ 1816fb12b70Safresh1__path_ vmspath [.__path_] ^ 1826fb12b70Safresh1/ vmspath sys$disk:[000000] ^ 1836fb12b70Safresh1/sys$scratch vmspath sys$scratch: ^ 1846fb12b70Safresh1 1856fb12b70Safresh1# Redundant characters in Unix paths 1866fb12b70Safresh1//__some_/__where_//__over_/../__the_.__rainbow_ vmsify __some_:[__where_.__over_.-]__the_.__rainbow_ ^ 1876fb12b70Safresh1/__some_/__where_//__over_/./__the_.__rainbow_ vmsify __some_:[__where_.__over_]__the_.__rainbow_ ^ 1886fb12b70Safresh1..//../ vmspath [--] ^ 1896fb12b70Safresh1./././ vmspath [] ^ 1906fb12b70Safresh1./../. vmsify [-] ^ 1916fb12b70Safresh1 1926fb12b70Safresh1# Our override of File::Spec->canonpath can do some strange things 1936fb12b70Safresh1__dev:[__dir.000000]__foo File::Spec->canonpath __dev:[__dir.000000]__foo ^ 1946fb12b70Safresh1__dev:[__dir.][000000]__foo File::Spec->canonpath __dev:[__dir]__foo ^ 195