libpath-ruby 0.2.2 → 0.2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +33 -0
- data/README.md +25 -8
- data/examples/path_from_arg0.md +43 -43
- data/examples/path_from_arg0.rb +25 -23
- data/lib/libpath/constants/unix.rb +74 -74
- data/lib/libpath/constants/windows.rb +75 -75
- data/lib/libpath/constants.rb +20 -20
- data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
- data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +118 -118
- data/lib/libpath/form/windows.rb +228 -214
- data/lib/libpath/form.rb +20 -21
- data/lib/libpath/internal_/array.rb +57 -57
- data/lib/libpath/internal_/platform.rb +30 -31
- data/lib/libpath/internal_/string.rb +25 -20
- data/lib/libpath/internal_/unix/form.rb +124 -119
- data/lib/libpath/internal_/windows/drive.rb +80 -75
- data/lib/libpath/internal_/windows/form.rb +205 -194
- data/lib/libpath/libpath.rb +4 -1
- data/lib/libpath/path/unix.rb +120 -118
- data/lib/libpath/path/windows.rb +126 -124
- data/lib/libpath/path.rb +21 -21
- data/lib/libpath/util/unix.rb +261 -261
- data/lib/libpath/util/windows.rb +403 -403
- data/lib/libpath/util.rb +20 -20
- data/lib/libpath/version.rb +25 -26
- data/lib/libpath.rb +1 -1
- data/test/performance/benchmark_drive_letter.rb +50 -10
- data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
- data/test/performance/benchmark_rindex2.rb +56 -48
- data/test/performance/benchmark_split.rb +16 -10
- data/test/unit/compare/ts_all.rb +4 -4
- data/test/unit/equate/ts_all.rb +4 -4
- data/test/unit/equate/unix/ts_all.rb +4 -4
- data/test/unit/equate/windows/ts_all.rb +4 -4
- data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
- data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
- data/test/unit/exceptions/ts_all.rb +4 -4
- data/test/unit/form/tc_absolute_functions.rb +242 -240
- data/test/unit/form/ts_all.rb +4 -4
- data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
- data/test/unit/form/unix/ts_all.rb +4 -4
- data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
- data/test/unit/form/windows/ts_all.rb +4 -4
- data/test/unit/internal_/tc_array.rb +36 -32
- data/test/unit/internal_/ts_all.rb +4 -4
- data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
- data/test/unit/internal_/unix/form/ts_all.rb +4 -4
- data/test/unit/internal_/unix/tc_split_path.rb +387 -384
- data/test/unit/internal_/unix/ts_all.rb +4 -4
- data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
- data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
- data/test/unit/internal_/windows/form/ts_all.rb +4 -4
- data/test/unit/internal_/windows/tc_split_path.rb +874 -869
- data/test/unit/internal_/windows/ts_all.rb +4 -4
- data/test/unit/parse/ts_all.rb +4 -4
- data/test/unit/path/tc_path.rb +732 -732
- data/test/unit/path/ts_all.rb +4 -4
- data/test/unit/path/unix/tc_path.rb +544 -540
- data/test/unit/path/unix/ts_all.rb +4 -4
- data/test/unit/path/windows/tc_path.rb +608 -603
- data/test/unit/path/windows/ts_all.rb +4 -4
- data/test/unit/tc_version.rb +25 -22
- data/test/unit/ts_all.rb +4 -4
- data/test/unit/util/tc_combine_paths.rb +110 -105
- data/test/unit/util/tc_derive_relative_path.rb +8 -3
- data/test/unit/util/tc_make_path_canonical.rb +142 -138
- data/test/unit/util/ts_all.rb +4 -4
- data/test/unit/util/unix/tc_combine_paths.rb +38 -34
- data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
- data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
- data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
- data/test/unit/util/unix/ts_all.rb +4 -4
- data/test/unit/util/windows/tc_combine_paths.rb +82 -77
- data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
- data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
- data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
- data/test/unit/util/windows/ts_all.rb +4 -4
- metadata +9 -8
@@ -2,154 +2,159 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'libpath/util/windows'
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
10
|
+
|
9
11
|
class Test_LibPath_Util_Windows_derive_relative_path < Test::Unit::TestCase
|
10
12
|
|
11
|
-
|
13
|
+
M = ::LibPath::Util::Windows
|
12
14
|
|
13
|
-
|
15
|
+
def test_nils_and_empties
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
# to get nowhere from nowhere, go nowhere
|
18
|
+
assert_nil M.derive_relative_path(nil, nil)
|
19
|
+
assert_nil M.derive_relative_path('', nil)
|
20
|
+
assert_equal '', M.derive_relative_path('', '')
|
21
|
+
assert_equal '', M.derive_relative_path(nil, '')
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
# to get somewhere from nowhere, just go there
|
24
|
+
assert_equal 'abc', M.derive_relative_path(nil, 'abc')
|
25
|
+
assert_equal 'abc', M.derive_relative_path('', 'abc')
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
# to get nowhere from anywhere else, go nowhere
|
28
|
+
assert_nil M.derive_relative_path('dir', nil)
|
29
|
+
assert_equal '', M.derive_relative_path('dir', '')
|
30
|
+
end
|
29
31
|
|
30
|
-
|
32
|
+
def test_same_location
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
assert_equal '.', M.derive_relative_path('.', '.')
|
35
|
+
assert_equal '.', M.derive_relative_path('..', '..')
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
assert_equal '.', M.derive_relative_path('abc', 'abc')
|
38
|
+
assert_equal './', M.derive_relative_path('abc/', 'abc/')
|
39
|
+
assert_equal './', M.derive_relative_path('abc', 'abc/')
|
38
40
|
|
39
|
-
|
41
|
+
assert_equal './', M.derive_relative_path('/', '/')
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
assert_equal '.', M.derive_relative_path('./abc', 'abc')
|
44
|
+
assert_equal '.', M.derive_relative_path('./abc/', 'abc')
|
45
|
+
assert_equal './', M.derive_relative_path('./abc', 'abc/')
|
46
|
+
assert_equal './', M.derive_relative_path('./abc/', 'abc/')
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
assert_equal '.', M.derive_relative_path('/abc', '/abc')
|
49
|
+
assert_equal '.', M.derive_relative_path('/abc/', '/abc')
|
50
|
+
assert_equal './', M.derive_relative_path('/abc/', '/abc/')
|
51
|
+
end
|
50
52
|
|
51
|
-
|
53
|
+
def test_from_here
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
+
assert_equal 'abc', M.derive_relative_path('.', 'abc')
|
56
|
+
end
|
55
57
|
|
56
|
-
|
58
|
+
def test_ones_above
|
57
59
|
|
58
|
-
|
60
|
+
assert_equal '..\\', M.derive_relative_path('.', '..')
|
59
61
|
|
60
|
-
|
62
|
+
assert_equal '../', M.derive_relative_path('/abc/', '/')
|
61
63
|
|
62
|
-
|
64
|
+
assert_equal '..\\', M.derive_relative_path('abc/def', 'abc')
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
+
assert_equal '..\\', M.derive_relative_path('abc/def/ghi', 'abc/def')
|
67
|
+
assert_equal '../', M.derive_relative_path('abc/def/ghi', 'abc/def/')
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
+
assert_equal '..\\', M.derive_relative_path('abc/def/./ghi', 'abc/def')
|
70
|
+
assert_equal '..\\', M.derive_relative_path('abc/def/ghi/jkl/..', 'abc/def')
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
+
assert_equal '..\\../', M.derive_relative_path('/abc/def/', '/')
|
73
|
+
#assert_equal '..\\../', M.derive_relative_path('/abc/def/', '/', make_path_canonical: true)
|
72
74
|
|
73
|
-
|
75
|
+
assert_equal '..\\..\\', M.derive_relative_path('abc/def/ghi/jkl/', 'abc/def')
|
74
76
|
|
75
|
-
|
77
|
+
assert_equal '..\\..\\', M.derive_relative_path('C:\\dir-1\\dir-2\\', 'C:\\')
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
-
|
79
|
+
assert_equal '..\\..\\', M.derive_relative_path('\\dir1\\dir2\\dir3\\dir4', '\\dir1\\dir2')
|
80
|
+
assert_equal '..\\..\\', M.derive_relative_path('/dir1/dir2/dir3/dir4', '/dir1/dir2')
|
81
|
+
end
|
80
82
|
|
81
|
-
|
83
|
+
def test_ones_below
|
82
84
|
|
83
|
-
|
85
|
+
assert_equal 'dir-1\\', M.derive_relative_path('..', '.', pwd: '/dir-1/')
|
84
86
|
|
85
|
-
|
87
|
+
assert_equal '..\\', M.derive_relative_path('.', '..', pwd: '/dir-1/')
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
89
|
+
assert_equal 'def', M.derive_relative_path('abc', 'abc/def')
|
90
|
+
assert_equal 'def\\', M.derive_relative_path('abc', 'abc/def/')
|
91
|
+
assert_equal 'def\\', M.derive_relative_path('abc', 'abc\\def\\')
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
-
|
93
|
+
assert_equal 'def\\ghi', M.derive_relative_path('abc', 'abc/def/ghi')
|
94
|
+
assert_equal 'def\\ghi\\', M.derive_relative_path('abc', 'abc/def/ghi/')
|
95
|
+
end
|
94
96
|
|
95
|
-
|
97
|
+
def test_ones_across
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
+
assert_equal '..\\e-1', M.derive_relative_path('abc/d-1', 'abc/e-1')
|
100
|
+
assert_equal '..\\e-1', M.derive_relative_path('abc/d-1/', 'abc/e-1')
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
assert_equal '..\\e-1\\e-2', M.derive_relative_path('abc/d-1/', 'abc/e-1/e-2')
|
103
|
+
assert_equal '..\\..\\e-1\\e-2', M.derive_relative_path('abc/d-1/d-2/', 'abc/e-1/e-2')
|
104
|
+
end
|
103
105
|
|
104
|
-
|
106
|
+
def test_simple_cases
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
assert_equal 'def', M.derive_relative_path('\\abc', '\\abc\\def')
|
109
|
+
assert_equal 'def', M.derive_relative_path('/abc', '/abc/def')
|
110
|
+
end
|
109
111
|
|
110
|
-
|
112
|
+
def test_absolute_path_cases
|
111
113
|
|
112
|
-
|
114
|
+
assert_equal '..\\..\\def', M.derive_relative_path('/abc/ghi', '/def')
|
113
115
|
|
114
|
-
|
116
|
+
assert_equal '..\\..\\def', M.derive_relative_path('ghi', '/def', pwd: 'C:/abc')
|
115
117
|
|
116
|
-
|
118
|
+
assert_equal '..\\def', M.derive_relative_path('abc', '\\\\?\\C:/def', pwd: '\\\\?\\C:/')
|
117
119
|
|
118
|
-
|
119
|
-
|
120
|
-
|
120
|
+
assert_equal '..\\..\abc', M.derive_relative_path('\\\\?\\UNC\\10.11.12.13:4567\\share/def/ghi', '\\\\?\\UNC\\10.11.12.13:4567\\share\abc')
|
121
|
+
assert_equal '..\\def\\ghi', M.derive_relative_path('\\\\?\\UNC\\10.11.12.13:4567\\share\\abc', '\\\\?\\UNC\\10.11.12.13:4567\\share/def/ghi')
|
122
|
+
end
|
121
123
|
|
122
|
-
|
124
|
+
def test_mixed
|
123
125
|
|
124
|
-
|
126
|
+
assert_equal 'D:\\dir-1\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', '/dir-1/dir-3', pwd: 'D:')
|
125
127
|
|
126
|
-
|
128
|
+
assert_equal '..\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', '/dir-1/dir-3', pwd: 'C:')
|
127
129
|
|
128
|
-
|
129
|
-
|
130
|
+
assert_equal '..\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', 'dir-3', pwd: 'C:\\dir-1')
|
131
|
+
end
|
130
132
|
|
131
|
-
|
133
|
+
def test_both_relative
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
+
assert_equal '..\\def', M.derive_relative_path('abc', 'def', pwd: '/')
|
136
|
+
end
|
135
137
|
|
136
|
-
|
138
|
+
def test_different_drives
|
137
139
|
|
138
|
-
|
139
|
-
|
140
|
+
assert_equal 'B:\\abc', M.derive_relative_path('A:\\abc', 'B:\\abc')
|
141
|
+
end
|
140
142
|
|
141
|
-
|
143
|
+
def test_same_drives
|
142
144
|
|
143
|
-
|
144
|
-
|
145
|
-
|
145
|
+
assert_equal '.', M.derive_relative_path('A:\\abc', 'A:\\abc')
|
146
|
+
assert_equal '.', M.derive_relative_path('A:\\.\abc', 'A:\\abc')
|
147
|
+
end
|
146
148
|
|
147
|
-
|
149
|
+
def test_cases_from_Path
|
148
150
|
|
149
|
-
|
150
|
-
|
151
|
+
srd = 'C:\\dir-1\\dir-2\\dir-C\\dir-D'
|
152
|
+
target = 'C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext'
|
151
153
|
|
152
|
-
|
153
|
-
|
154
|
+
assert_equal '..\\..\\dir-3\\dir-4\\dir-5\\file.ext', M.derive_relative_path(srd, target)
|
155
|
+
end
|
154
156
|
end
|
155
157
|
|
158
|
+
|
159
|
+
# ############################## end of file ############################# #
|
160
|
+
|
@@ -2,162 +2,166 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'libpath/util/windows'
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
9
|
-
class Test_LibPath_Util_Windows_make_path_absolute < Test::Unit::TestCase
|
10
10
|
|
11
|
-
|
11
|
+
class Test_LibPath_Util_Windows_make_path_absolute < Test::Unit::TestCase
|
12
12
|
|
13
|
-
|
13
|
+
F = ::LibPath::Util::Windows
|
14
14
|
|
15
|
-
|
15
|
+
def test_nil
|
16
16
|
|
17
|
-
|
18
|
-
else
|
17
|
+
if $DEBUG
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
19
|
+
assert_raise(::ArgumentError) { F.make_path_absolute(nil) }
|
20
|
+
else
|
23
21
|
|
24
|
-
|
22
|
+
assert_nil F.make_path_absolute(nil)
|
23
|
+
end
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
end
|
26
|
+
def test_empty
|
28
27
|
|
29
|
-
|
28
|
+
assert_equal '', F.make_path_absolute('')
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
assert_equal 'C:\\.', F.make_path_absolute('\\.', pwd: 'C:/Users/libpath-tester')
|
33
|
-
assert_equal 'C:\\a', F.make_path_absolute('\\a', pwd: 'C:/Users/libpath-tester')
|
34
|
-
assert_equal 'C:\\a\\.', F.make_path_absolute('\\a\\.', pwd: 'C:/Users/libpath-tester')
|
31
|
+
def test_absolute_paths
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
assert_equal 'C:\\', F.make_path_absolute('\\', pwd: 'C:/Users/libpath-tester')
|
34
|
+
assert_equal 'C:\\.', F.make_path_absolute('\\.', pwd: 'C:/Users/libpath-tester')
|
35
|
+
assert_equal 'C:\\a', F.make_path_absolute('\\a', pwd: 'C:/Users/libpath-tester')
|
36
|
+
assert_equal 'C:\\a\\.', F.make_path_absolute('\\a\\.', pwd: 'C:/Users/libpath-tester')
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
assert_equal 'C:/', F.make_path_absolute('/', pwd: 'C:/Users/libpath-tester')
|
39
|
+
assert_equal 'C:/.', F.make_path_absolute('/.', pwd: 'C:/Users/libpath-tester')
|
40
|
+
assert_equal 'C:/a', F.make_path_absolute('/a', pwd: 'C:/Users/libpath-tester')
|
41
|
+
assert_equal 'C:/a/.', F.make_path_absolute('/a/.', pwd: 'C:/Users/libpath-tester')
|
45
42
|
|
46
|
-
|
43
|
+
assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\abc\\')
|
44
|
+
assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\\\abc\\\\')
|
45
|
+
assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\\\abc\\\\', pwd: 'C:/Users/libpath-tester')
|
46
|
+
end
|
47
47
|
|
48
|
-
|
48
|
+
def test_absolute_paths_with_canonicalisation
|
49
49
|
|
50
|
-
|
50
|
+
pwd = 'X:\\some-dir'
|
51
51
|
|
52
|
-
|
53
|
-
assert_equal 'X:/', F.make_path_absolute('/.', **options, pwd: pwd)
|
54
|
-
assert_equal 'X:/a', F.make_path_absolute('/a', **options, pwd: pwd)
|
55
|
-
assert_equal 'X:/a/', F.make_path_absolute('/a/.', **options, pwd: pwd)
|
56
|
-
end
|
52
|
+
options = { make_canonical: true }
|
57
53
|
|
58
|
-
|
54
|
+
assert_equal 'X:/', F.make_path_absolute('/', **options, pwd: pwd)
|
55
|
+
assert_equal 'X:/', F.make_path_absolute('/.', **options, pwd: pwd)
|
56
|
+
assert_equal 'X:/a', F.make_path_absolute('/a', **options, pwd: pwd)
|
57
|
+
assert_equal 'X:/a/', F.make_path_absolute('/a/.', **options, pwd: pwd)
|
58
|
+
end
|
59
59
|
|
60
|
-
|
60
|
+
def test_relative_path_with_fixed_pwd
|
61
61
|
|
62
|
-
|
63
|
-
assert_equal 'X:\\some-path\\or-other\\', F.make_path_absolute('.', pwd: pwd, make_canonical: true)
|
62
|
+
pwd = 'X:\\some-path\\\\or-other'
|
64
63
|
|
65
|
-
|
66
|
-
|
64
|
+
assert_equal 'X:\\some-path\\or-other\\.', F.make_path_absolute('.', pwd: pwd)
|
65
|
+
assert_equal 'X:\\some-path\\or-other\\', F.make_path_absolute('.', pwd: pwd, make_canonical: true)
|
67
66
|
|
68
|
-
|
69
|
-
|
67
|
+
assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('abc', pwd: pwd)
|
68
|
+
assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('abc', pwd: pwd, make_canonical: true)
|
70
69
|
|
71
|
-
|
72
|
-
|
70
|
+
assert_equal 'X:\\some-path\\or-other\\./abc', F.make_path_absolute('./abc', pwd: pwd)
|
71
|
+
assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('./abc', pwd: pwd, make_canonical: true)
|
73
72
|
|
74
|
-
|
75
|
-
|
73
|
+
assert_equal 'X:\\some-path\\or-other\\./abc/', F.make_path_absolute('./abc/', pwd: pwd)
|
74
|
+
assert_equal 'X:\\some-path\\or-other\\abc/', F.make_path_absolute('./abc/', pwd: pwd, make_canonical: true)
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
end
|
76
|
+
assert_equal 'X:\\some-path\\or-other\\def/../abc', F.make_path_absolute('def/../abc', pwd: pwd)
|
77
|
+
assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('def/../abc', pwd: pwd, make_canonical: true)
|
80
78
|
|
81
|
-
|
79
|
+
assert_equal 'X:\\some-path\\or-other\\def/../abc/', F.make_path_absolute('def/../abc/', pwd: pwd)
|
80
|
+
assert_equal 'X:\\some-path\\or-other\\abc/', F.make_path_absolute('def/../abc/', pwd: pwd, make_canonical: true)
|
81
|
+
end
|
82
82
|
|
83
|
-
|
83
|
+
def test_relative_path_with_fixed_home
|
84
84
|
|
85
|
-
|
86
|
-
assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home, make_canonical: true)
|
85
|
+
home = 'X:\\Documents and Settings\\libpath-tester'
|
87
86
|
|
88
|
-
|
89
|
-
|
87
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home)
|
88
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home, make_canonical: true)
|
90
89
|
|
91
|
-
|
92
|
-
|
90
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/.', F.make_path_absolute('~/.', home: home)
|
91
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/', F.make_path_absolute('~/.', home: home, make_canonical: true)
|
93
92
|
|
94
|
-
|
95
|
-
|
93
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\.', F.make_path_absolute('~\\.', home: home)
|
94
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~\\.', home: home, make_canonical: true)
|
96
95
|
|
97
|
-
|
98
|
-
|
96
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/abc', home: home)
|
97
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/abc', home: home, make_canonical: true)
|
99
98
|
|
100
|
-
|
101
|
-
|
99
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/./abc', F.make_path_absolute('~/./abc', home: home)
|
100
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/./abc', home: home, make_canonical: true)
|
102
101
|
|
103
|
-
|
104
|
-
|
102
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/./abc/', F.make_path_absolute('~/./abc/', home: home)
|
103
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/abc/', F.make_path_absolute('~/./abc/', home: home, make_canonical: true)
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
end
|
105
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/def/../abc', F.make_path_absolute('~/def/../abc', home: home)
|
106
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/def/../abc', home: home, make_canonical: true)
|
109
107
|
|
110
|
-
|
108
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/def/../abc/', F.make_path_absolute('~/def/../abc/', home: home)
|
109
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester/abc/', F.make_path_absolute('~/def/../abc/', home: home, make_canonical: true)
|
110
|
+
end
|
111
111
|
|
112
|
-
|
112
|
+
def test_relative_path_with_fixed_home_2
|
113
113
|
|
114
|
-
|
115
|
-
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home, make_canonical: true)
|
114
|
+
home = 'X:\\Documents and Settings\\libpath-tester\\'
|
116
115
|
|
117
|
-
|
118
|
-
|
116
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home)
|
117
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home, make_canonical: true)
|
119
118
|
|
120
|
-
|
121
|
-
|
119
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/', home: home)
|
120
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/', home: home, make_canonical: true)
|
122
121
|
|
123
|
-
|
124
|
-
|
122
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\.', F.make_path_absolute('~/.', home: home)
|
123
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/.', home: home, make_canonical: true)
|
125
124
|
|
126
|
-
|
127
|
-
|
125
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/abc', home: home)
|
126
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/abc', home: home, make_canonical: true)
|
128
127
|
|
129
|
-
|
130
|
-
|
128
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\./abc', F.make_path_absolute('~/./abc', home: home)
|
129
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/./abc', home: home, make_canonical: true)
|
131
130
|
|
132
|
-
|
133
|
-
|
131
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\./abc/', F.make_path_absolute('~/./abc/', home: home)
|
132
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc/', F.make_path_absolute('~/./abc/', home: home, make_canonical: true)
|
134
133
|
|
135
|
-
|
136
|
-
|
137
|
-
end
|
134
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\def/../abc', F.make_path_absolute('~/def/../abc', home: home)
|
135
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/def/../abc', home: home, make_canonical: true)
|
138
136
|
|
139
|
-
|
137
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\def/../abc/', F.make_path_absolute('~/def/../abc/', home: home)
|
138
|
+
assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc/', F.make_path_absolute('~/def/../abc/', home: home, make_canonical: true)
|
139
|
+
end
|
140
140
|
|
141
|
-
|
141
|
+
def test_nonhome_tilde_with_fixed_pwd
|
142
142
|
|
143
|
-
|
144
|
-
assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd, make_canonical: true)
|
143
|
+
pwd = 'X:\\some-other-path\\'
|
145
144
|
|
146
|
-
|
147
|
-
|
145
|
+
assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd)
|
146
|
+
assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd, make_canonical: true)
|
148
147
|
|
149
|
-
|
150
|
-
|
148
|
+
assert_equal 'X:\\some-other-path\\~abc', F.make_path_absolute('~abc', pwd: pwd)
|
149
|
+
assert_equal 'X:\\some-other-path\\~abc', F.make_path_absolute('~abc', pwd: pwd, make_canonical: true)
|
151
150
|
|
152
|
-
|
153
|
-
|
151
|
+
assert_equal 'X:\\some-other-path\\~./abc', F.make_path_absolute('~./abc', pwd: pwd)
|
152
|
+
assert_equal 'X:\\some-other-path\\~./abc', F.make_path_absolute('~./abc', pwd: pwd, make_canonical: true)
|
154
153
|
|
155
|
-
|
156
|
-
|
154
|
+
assert_equal 'X:\\some-other-path\\~./abc/', F.make_path_absolute('~./abc/', pwd: pwd)
|
155
|
+
assert_equal 'X:\\some-other-path\\~./abc/', F.make_path_absolute('~./abc/', pwd: pwd, make_canonical: true)
|
157
156
|
|
158
|
-
|
159
|
-
|
160
|
-
end
|
157
|
+
assert_equal 'X:\\some-other-path\\~def/../abc', F.make_path_absolute('~def/../abc', pwd: pwd)
|
158
|
+
assert_equal 'X:\\some-other-path\\abc', F.make_path_absolute('~def/../abc', pwd: pwd, make_canonical: true)
|
161
159
|
|
160
|
+
assert_equal 'X:\\some-other-path\\~def/../abc/', F.make_path_absolute('~def/../abc/', pwd: pwd)
|
161
|
+
assert_equal 'X:\\some-other-path\\abc/', F.make_path_absolute('~def/../abc/', pwd: pwd, make_canonical: true)
|
162
|
+
end
|
162
163
|
end
|
163
164
|
|
165
|
+
|
166
|
+
# ############################## end of file ############################# #
|
167
|
+
|