]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0060-path-utils.sh
Merge branch 'maint'
[thirdparty/git.git] / t / t0060-path-utils.sh
CommitLineData
ae299be0
DR
1#!/bin/sh
2#
3# Copyright (c) 2008 David Reiss
4#
5
6test_description='Test various path utilities'
7
8. ./test-lib.sh
9
10norm_abs() {
f42302b4
JS
11 test_expect_success "normalize absolute: $1 => $2" \
12 "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
ae299be0
DR
13}
14
0454dd93 15ancestor() {
f42302b4
JS
16 test_expect_success "longest ancestor: $1 $2 => $3" \
17 "test \"\$(test-path-utils longest_ancestor_length '$1' '$2')\" = '$3'"
0454dd93
DR
18}
19
f42302b4 20norm_abs "" ""
ae299be0
DR
21norm_abs / /
22norm_abs // /
23norm_abs /// /
24norm_abs /. /
25norm_abs /./ /
f42302b4
JS
26norm_abs /./.. ++failed++
27norm_abs /../. ++failed++
28norm_abs /./../.// ++failed++
ae299be0
DR
29norm_abs /dir/.. /
30norm_abs /dir/sub/../.. /
f42302b4 31norm_abs /dir/sub/../../.. ++failed++
ae299be0 32norm_abs /dir /dir
f42302b4 33norm_abs /dir// /dir/
ae299be0 34norm_abs /./dir /dir
f42302b4
JS
35norm_abs /dir/. /dir/
36norm_abs /dir///./ /dir/
37norm_abs /dir//sub/.. /dir/
38norm_abs /dir/sub/../ /dir/
39norm_abs //dir/sub/../. /dir/
40norm_abs /dir/s1/../s2/ /dir/s2/
41norm_abs /d1/s1///s2/..//../s3/ /d1/s3/
ae299be0
DR
42norm_abs /d1/s1//../s2/../../d2 /d2
43norm_abs /d1/.../d2 /d1/.../d2
44norm_abs /d1/..././../d2 /d1/d2
45
0454dd93
DR
46ancestor / "" -1
47ancestor / / -1
48ancestor /foo "" -1
49ancestor /foo : -1
50ancestor /foo ::. -1
51ancestor /foo ::..:: -1
52ancestor /foo / 0
53ancestor /foo /fo -1
54ancestor /foo /foo -1
55ancestor /foo /foo/ -1
56ancestor /foo /bar -1
57ancestor /foo /bar/ -1
58ancestor /foo /foo/bar -1
59ancestor /foo /foo:/bar/ -1
60ancestor /foo /foo/:/bar/ -1
61ancestor /foo /foo::/bar/ -1
62ancestor /foo /:/foo:/bar/ 0
63ancestor /foo /foo:/:/bar/ 0
64ancestor /foo /:/bar/:/foo 0
65ancestor /foo/bar "" -1
66ancestor /foo/bar / 0
67ancestor /foo/bar /fo -1
68ancestor /foo/bar foo -1
69ancestor /foo/bar /foo 4
70ancestor /foo/bar /foo/ 4
71ancestor /foo/bar /foo/ba -1
72ancestor /foo/bar /:/fo 0
73ancestor /foo/bar /foo:/foo/ba 4
74ancestor /foo/bar /bar -1
75ancestor /foo/bar /bar/ -1
76ancestor /foo/bar /fo: -1
77ancestor /foo/bar :/fo -1
78ancestor /foo/bar /foo:/bar/ 4
79ancestor /foo/bar /:/foo:/bar/ 4
80ancestor /foo/bar /foo:/:/bar/ 4
81ancestor /foo/bar /:/bar/:/fo 0
82ancestor /foo/bar /:/bar/ 0
83ancestor /foo/bar :://foo/. 4
84ancestor /foo/bar :://foo/.:: 4
85ancestor /foo/bar //foo/./::/bar 4
86ancestor /foo/bar ::/bar -1
87
ae299be0 88test_done