blob: 1fa66da804d82a884871b9c0c8d588799ac84975 (
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
|
#!/bin/sh
# Copyright 2022 by Roger Knecht <rknecht@pm.me>
# Licensed under GPLv2, see file LICENSE in this source tree.
. ./testing.sh -v
# testing "description" "command" "result" "infile" "stdin"
testing "tree error opening dir" \
"tree tree.tempdir" \
"\
tree.tempdir [error opening dir]\n\
\n\
0 directories, 0 files\n" \
"" ""
mkdir -p tree2.tempdir
touch tree2.tempdir/testfile
optional UNICODE_SUPPORT
testing "tree single file" \
"cd tree2.tempdir && tree" \
"\
.\n\
└── testfile\n\
\n\
0 directories, 1 files\n" \
"" ""
mkdir -p tree3.tempdir/test1 \
tree3.tempdir/test2/a \
tree3.tempdir/test2/b \
tree3.tempdir/test3/c \
tree3.tempdir/test3/d
touch tree3.tempdir/test2/a/testfile1 \
tree3.tempdir/test2/a/testfile2 \
tree3.tempdir/test2/a/testfile3 \
tree3.tempdir/test2/b/testfile4 \
tree3.tempdir/test3/c/testfile5 \
tree3.tempdir/test3/d/testfile6 \
tree3.tempdir/test3/d/.testfile7
(cd tree3.tempdir/test2/a && ln -s ../b/testfile4 .)
(cd tree3.tempdir/test2/b && ln -s ../../test3 .)
testing "tree nested directories and files" \
"cd tree3.tempdir && tree" \
"\
.\n\
├── test1\n\
├── test2\n\
│ ├── a\n\
│ │ ├── testfile1\n\
│ │ ├── testfile2\n\
│ │ ├── testfile3\n\
│ │ └── testfile4 -> ../b/testfile4\n\
│ └── b\n\
│ ├── test3 -> ../../test3\n\
│ └── testfile4\n\
└── test3\n\
├── c\n\
│ └── testfile5\n\
└── d\n\
└── testfile6\n\
\n\
7 directories, 8 files\n" \
"" ""
#note: tree v2.0.1 says "8 directories, 7 files":
#it counts "test3 -> ../../test3" as a directory, even though it does not follow this symlink
testing "tree multiple directories" \
"tree tree2.tempdir tree3.tempdir" \
"\
tree2.tempdir\n\
└── testfile\n\
tree3.tempdir\n\
├── test1\n\
├── test2\n\
│ ├── a\n\
│ │ ├── testfile1\n\
│ │ ├── testfile2\n\
│ │ ├── testfile3\n\
│ │ └── testfile4 -> ../b/testfile4\n\
│ └── b\n\
│ ├── test3 -> ../../test3\n\
│ └── testfile4\n\
└── test3\n\
├── c\n\
│ └── testfile5\n\
└── d\n\
└── testfile6\n\
\n\
7 directories, 9 files\n" \
"" ""
#note: tree v2.0.1 says "8 directories, 7 files" (not "8 files", probably a/testfile4 -> ../b/testfile4 and b/testfile4 are counted as one file, not 2?)
rm -rf tree.tempdir tree2.tempdir tree3.tempdir
exit $FAILCOUNT
|