summaryrefslogtreecommitdiff
path: root/vms/ext/filespec.t
blob: 3415400b21644c8e6ebf6fc1466f517e765ea7e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!./perl

BEGIN { unshift(@INC,'../lib') if -d '../lib'; }

use VMS::Filespec;
use File::Spec;

foreach (<DATA>) {
  chomp;
  s/\s*#.*//;
  next if /^\s*$/;
  push(@tests,$_);
}

require './test.pl';
plan(tests => scalar(2*@tests)+6);

foreach $test (@tests) {
  ($arg,$func,$expect) = split(/\s+/,$test);

  $expect = undef if $expect eq 'undef';
  $rslt = eval "$func('$arg')";
  is($@, '', "eval ${func}('$arg')");
  is(lc($rslt), lc($expect), "${func}('$arg'): '$rslt'");
}

$defwarn = <<'EOW';
# Note: This failure may have occurred because your default device
# was set using a non-concealed logical name.  If this is the case,
# you will need to determine by inspection that the two resultant
# file specifications shown above are in fact equivalent.
EOW

is(uc(rmsexpand('[]')),   "\U$ENV{DEFAULT}", 'rmsexpand()') || print $defwarn;
is(lc(rmsexpand('from.here')),"\L$ENV{DEFAULT}from.here") || print $defwarn;
is(lc(rmsexpand('from')),     "\L$ENV{DEFAULT}from")      || print $defwarn;

is(lc(rmsexpand('from.here','cant:[get.there];2')),
   'cant:[get.there]from.here;2')                     || print $defwarn;


# Make sure we're using redirected mkdir, which strips trailing '/', since
# the CRTL's mkdir can't handle this.
ok(mkdir('testdir/',0777),      'using redirected mkdir()');
ok(rmdir('testdir/'),           '    rmdir()');

__DATA__

# lots of underscores used to minimize collision with existing logical names

# Basic VMS to Unix filespecs
__some_:[__where_.__over_]__the_.__rainbow_    unixify /__some_/__where_/__over_/__the_.__rainbow_
[.__some_.__where_.__over_]__the_.__rainbow_   unixify __some_/__where_/__over_/__the_.__rainbow_
[-.__some_.__where_.__over_]__the_.__rainbow_  unixify ../__some_/__where_/__over_/__the_.__rainbow_
[.__some_.--.__where_.__over_]__the_.__rainbow_        unixify __some_/../../__where_/__over_/__the_.__rainbow_
[.__some_...__where_.__over_]__the_.__rainbow_ unixify __some_/.../__where_/__over_/__the_.__rainbow_
[...__some_.__where_.__over_]__the_.__rainbow_ unixify .../__some_/__where_/__over_/__the_.__rainbow_
[.__some_.__where_.__over_...]__the_.__rainbow_        unixify __some_/__where_/__over_/.../__the_.__rainbow_
[.__some_.__where_.__over_...] unixify __some_/__where_/__over_/.../
[.__some_.__where_.__over_.-]  unixify __some_/__where_/__over_/../
[]	unixify		./
[-]	unixify		../
[--]	unixify		../../
[...]	unixify		.../
__lyrics_:[__are_.__very_^.__sappy_]__but_^.__rhymes_^.__are_.__true_    unixify /__lyrics_/__are_/__very_.__sappy_/__but_.__rhymes_.__are_.__true_

# and back again
/__some_/__where_/__over_/__the_.__rainbow_    vmsify  __some_:[__where_.__over_]__the_.__rainbow_
__some_/__where_/__over_/__the_.__rainbow_     vmsify  [.__some_.__where_.__over_]__the_.__rainbow_
../__some_/__where_/__over_/__the_.__rainbow_  vmsify  [-.__some_.__where_.__over_]__the_.__rainbow_
__some_/../../__where_/__over_/__the_.__rainbow_       vmsify  [-.__where_.__over_]__the_.__rainbow_
.../__some_/__where_/__over_/__the_.__rainbow_ vmsify  [...__some_.__where_.__over_]__the_.__rainbow_
__some_/.../__where_/__over_/__the_.__rainbow_ vmsify  [.__some_...__where_.__over_]__the_.__rainbow_
/__some_/.../__where_/__over_/__the_.__rainbow_        vmsify  __some_:[...__where_.__over_]__the_.__rainbow_
__some_/__where_/...   vmsify  [.__some_.__where_...]
/__where_/...  vmsify  __where_:[...]
.	vmsify	[]
..	vmsify	[-]
../..	vmsify	[--]
.../	vmsify	[...]
/	vmsify	sys$disk:[000000]

# Fileifying directory specs
__down_:[__the_.__garden_.__path_]     fileify __down_:[__the_.__garden_]__path_.dir;1
[.__down_.__the_.__garden_.__path_]    fileify [.__down_.__the_.__garden_]__path_.dir;1
/__down_/__the_/__garden_/__path_      fileify /__down_/__the_/__garden_/__path_.dir;1
/__down_/__the_/__garden_/__path_/     fileify /__down_/__the_/__garden_/__path_.dir;1
__down_/__the_/__garden_/__path_       fileify __down_/__the_/__garden_/__path_.dir;1
__down_:[__the_.__garden_]__path_      fileify __down_:[__the_.__garden_]__path_.dir;1
__down_:[__the_.__garden_]__path_.     fileify # N.B. trailing . ==> null type
__down_:[__the_]__garden_.__path_      fileify undef
/__down_/__the_/__garden_/__path_.     fileify # N.B. trailing . ==> null type
/__down_/__the_/__garden_.__path_      fileify undef

# and pathifying them
__down_:[__the_.__garden_]__path_.dir;1        pathify __down_:[__the_.__garden_.__path_]
[.__down_.__the_.__garden_]__path_.dir pathify [.__down_.__the_.__garden_.__path_]
/__down_/__the_/__garden_/__path_.dir  pathify /__down_/__the_/__garden_/__path_/
__down_/__the_/__garden_/__path_.dir   pathify __down_/__the_/__garden_/__path_/
__down_:[__the_.__garden_]__path_      pathify __down_:[__the_.__garden_.__path_]
__down_:[__the_.__garden_]__path_.     pathify # N.B. trailing . ==> null type
__down_:[__the_]__garden_.__path_      pathify undef
/__down_/__the_/__garden_/__path_.     pathify # N.B. trailing . ==> null type
/__down_/__the_/__garden_.__path_      pathify undef
__down_:[__the_.__garden_]__path_.dir;2        pathify #N.B. ;2
__path_        pathify __path_/
/__down_/__the_/__garden_/.    pathify /__down_/__the_/__garden_/./
/__down_/__the_/__garden_/..   pathify /__down_/__the_/__garden_/../
/__down_/__the_/__garden_/...  pathify /__down_/__the_/__garden_/.../
__path_.notdir pathify undef

# Both VMS/Unix and file/path conversions
__down_:[__the_.__garden_]__path_.dir;1        unixpath        /__down_/__the_/__garden_/__path_/
/__down_/__the_/__garden_/__path_      vmspath __down_:[__the_.__garden_.__path_]
__down_:[__the_.__garden_.__path_]     unixpath        /__down_/__the_/__garden_/__path_/
__down_:[__the_.__garden_.__path_...]  unixpath        /__down_/__the_/__garden_/__path_/.../
/__down_/__the_/__garden_/__path_.dir  vmspath __down_:[__the_.__garden_.__path_]
[.__down_.__the_.__garden_]__path_.dir unixpath        __down_/__the_/__garden_/__path_/
__down_/__the_/__garden_/__path_       vmspath [.__down_.__the_.__garden_.__path_]
__path_        vmspath [.__path_]
/	vmspath	sys$disk:[000000]

# Redundant characters in Unix paths
//__some_/__where_//__over_/../__the_.__rainbow_       vmsify  __some_:[__where_]__the_.__rainbow_
/__some_/__where_//__over_/./__the_.__rainbow_ vmsify  __some_:[__where_.__over_]__the_.__rainbow_
..//../	vmspath	[--]
./././	vmspath	[]
./../.	vmsify	[-]

# Our override of File::Spec->canonpath can do some strange things
__dev:[__dir.000000]__foo     File::Spec->canonpath   __dev:[__dir.000000]__foo
__dev:[__dir.][000000]__foo   File::Spec->canonpath   __dev:[__dir]__foo