git-p4: chdir now properly sets PWD environment variable in msysGit
[git/git-p4.git] / t / t0060-path-utils.sh
blob6e7501f352ee97636280357da54c50d73ceb0138
1 #!/bin/sh
3 # Copyright (c) 2008 David Reiss
6 test_description='Test various path utilities'
8 . ./test-lib.sh
10 norm_abs() {
11 test_expect_success "normalize absolute" \
12 "test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
15 ancestor() {
16 test_expect_success "longest ancestor" \
17 "test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
20 norm_abs "" /
21 norm_abs / /
22 norm_abs // /
23 norm_abs /// /
24 norm_abs /. /
25 norm_abs /./ /
26 norm_abs /./.. /
27 norm_abs /../. /
28 norm_abs /./../.// /
29 norm_abs /dir/.. /
30 norm_abs /dir/sub/../.. /
31 norm_abs /dir /dir
32 norm_abs /dir// /dir
33 norm_abs /./dir /dir
34 norm_abs /dir/. /dir
35 norm_abs /dir///./ /dir
36 norm_abs /dir//sub/.. /dir
37 norm_abs /dir/sub/../ /dir
38 norm_abs //dir/sub/../. /dir
39 norm_abs /dir/s1/../s2/ /dir/s2
40 norm_abs /d1/s1///s2/..//../s3/ /d1/s3
41 norm_abs /d1/s1//../s2/../../d2 /d2
42 norm_abs /d1/.../d2 /d1/.../d2
43 norm_abs /d1/..././../d2 /d1/d2
45 ancestor / "" -1
46 ancestor / / -1
47 ancestor /foo "" -1
48 ancestor /foo : -1
49 ancestor /foo ::. -1
50 ancestor /foo ::..:: -1
51 ancestor /foo / 0
52 ancestor /foo /fo -1
53 ancestor /foo /foo -1
54 ancestor /foo /foo/ -1
55 ancestor /foo /bar -1
56 ancestor /foo /bar/ -1
57 ancestor /foo /foo/bar -1
58 ancestor /foo /foo:/bar/ -1
59 ancestor /foo /foo/:/bar/ -1
60 ancestor /foo /foo::/bar/ -1
61 ancestor /foo /:/foo:/bar/ 0
62 ancestor /foo /foo:/:/bar/ 0
63 ancestor /foo /:/bar/:/foo 0
64 ancestor /foo/bar "" -1
65 ancestor /foo/bar / 0
66 ancestor /foo/bar /fo -1
67 ancestor /foo/bar foo -1
68 ancestor /foo/bar /foo 4
69 ancestor /foo/bar /foo/ 4
70 ancestor /foo/bar /foo/ba -1
71 ancestor /foo/bar /:/fo 0
72 ancestor /foo/bar /foo:/foo/ba 4
73 ancestor /foo/bar /bar -1
74 ancestor /foo/bar /bar/ -1
75 ancestor /foo/bar /fo: -1
76 ancestor /foo/bar :/fo -1
77 ancestor /foo/bar /foo:/bar/ 4
78 ancestor /foo/bar /:/foo:/bar/ 4
79 ancestor /foo/bar /foo:/:/bar/ 4
80 ancestor /foo/bar /:/bar/:/fo 0
81 ancestor /foo/bar /:/bar/ 0
82 ancestor /foo/bar :://foo/. 4
83 ancestor /foo/bar :://foo/.:: 4
84 ancestor /foo/bar //foo/./::/bar 4
85 ancestor /foo/bar ::/bar -1
87 test_done