blob: fb01e371044b2080feb77df0ad754bdfcfec594b (
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
|
# file : tests/function/path/testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
.include ../../common.testscript
s = ($cxx.target.class != 'windows' ? '/' : '\')
: canonicalize
:
{
$* <'print $canonicalize([path] a/b)' >"a$(s)b" : path
$* <'print $canonicalize([paths] a/b a/c)' >"a$(s)b a$(s)c" : paths
$* <'print $canonicalize([dir_path] a/b)' >"a$(s)b$s" : dir-path
$* <'print $canonicalize([dir_paths] a/b a/c/)' >"a$(s)b$s a$(s)c$s" : dir-paths
$* <'print $path.canonicalize(a/b)' >"a$(s)b" : untyped
$* <'print $path.canonicalize(a/b/ a/c)' >"a$(s)b$s a$(s)c" : mixed
}
: normalize
:
{
$* <'print $normalize([path] a/../b)' >"b" : path
$* <'print $normalize([paths] a/../b a/../c)' >"b c" : paths
$* <'print $normalize([dir_path] a/../b)' >"b$s" : dir-path
$* <'print $normalize([dir_paths] a/../b a/../c/)' >"b$s c$s" : dir-paths
$* <'print $path.normalize(a/../b)' >"b" : untyped
$* <'print $path.normalize(a/../b/ a/../c)' >"b$s c" : mixed
: actualize
:
if ($cxx.target.class == 'windows')
{
mkdir Foo;
$* <'print $path.normalize($out_base/foo, true)' >~'/.+\\Foo/'
}
}
: directory
:
{
$* <'print $directory([path] a/b)' >"a/" : path
$* <'print $directory([dir_path] a/b)' >"a/" : dir-path
$* <'print $directory([paths] a/b c/d/)' >"a/ c/" : paths
$* <'print $directory([dir_paths] a/b c/d/)' >"a/ c/" : dir-paths
$* <'print $path.directory(a/b c/d/)' >"a/ c/" : dir-names
}
: base
:
{
$* <'print $base([path] a.c)' >"a" : path
$* <'print $base([dir_path] a.tmp)' >"a$s" : dir-path
$* <'print $base([paths] a.c b.tmp/)' >"a b/" : paths
$* <'print $base([dir_paths] a.tmp b.tmp/)' >"a$s b/" : dir-paths
$* <'print $path.base(a.c b.tmp/)' >"a b/" : dir-names
}
: leaf
:
{
$* <'print $leaf([path] a/b)' >"b" : path
$* <'print $leaf([dir_path] a/b)' >"b$s" : dir-path
$* <'print $leaf([path] a/b/c, [dir_path] a)' >"b/c" : sub-path
$* <'print $leaf([dir_path] a/b/c, [dir_path] a)' >"b/c$s" : sub-dir-path
$* <'print $leaf([paths] a/b/c a/b/e, [dir_path] a/b)' >"c e" : sub-paths
$* <'print $leaf([dir_paths] a/b/c, [dir_path] a/b)' >"c$s" : sub-dir-paths
$* <'print $path.leaf(a/b c/d/)' >"b d/" : dir-names
$* <'print $path.leaf(a/b/c a/b/d/, [dir_path] a)' >"b/c b/d/" : sub-dir-names
: not-prefix
:
$* <'print $leaf([path] a/b/c, [dir_path] a/d)' 2>>"EOE" != 0
error: 'a/d$s' is not a prefix of 'a/b/c'
EOE
}
: extension
:
{
$* <'print $extension([path] a.c)' >"c" : path
$* <'print $extension([dir_path] a.tmp/)' >"tmp" : dir_path
$* <'print $path.extension(a.c)' >"c" : untyped
$* <'print $path.extension(a)' >"[null]" : null
}
: combined
:
{
mkdir -p a/b;
touch a/b/c.t.cpp;
$* <<EOI >>/EOO
t = $src_base/a/b/c.t.cpp
d = $path.leaf($path.directory($t), $src_base)
n = $path.base($path.base($path.leaf($t)))
print $d/exe{$n}
print $d/{+$n*.cpp}
EOI
a/b/exe{c}
a/b/c.t.cpp
EOO
}
: invalid-path
:
p = ($cxx.target.class != 'windows' ? /../foo : 'c:/../foo');
$* <"\$path.normalize\('$p')" 2>>"EOE" != 0
error: invalid path: '$p'
EOE
|