summaryrefslogtreecommitdiff
path: root/t/t0066-dir-iterator.sh
blob: 59bce868f4c08231a66b9f389f696ed1be8ba9f8 (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
#!/bin/sh
 
test_description='Test the dir-iterator functionality'
 
. ./test-lib.sh
 
test_expect_success 'setup' '
	mkdir -p dir &&
	mkdir -p dir/a/b/c/ &&
	>dir/b &&
	>dir/c &&
	mkdir -p dir/d/e/d/ &&
	>dir/a/b/c/d &&
	>dir/a/e &&
	>dir/d/e/d/a &&
 
	mkdir -p dir2/a/b/c/ &&
	>dir2/a/b/c/d
'
 
test_expect_success 'dir-iterator should iterate through all files' '
	cat >expected-iteration-sorted-output <<-EOF &&
	[d] (a) [a] ./dir/a
	[d] (a/b) [b] ./dir/a/b
	[d] (a/b/c) [c] ./dir/a/b/c
	[d] (d) [d] ./dir/d
	[d] (d/e) [e] ./dir/d/e
	[d] (d/e/d) [d] ./dir/d/e/d
	[f] (a/b/c/d) [d] ./dir/a/b/c/d
	[f] (a/e) [e] ./dir/a/e
	[f] (b) [b] ./dir/b
	[f] (c) [c] ./dir/c
	[f] (d/e/d/a) [a] ./dir/d/e/d/a
	EOF
 
	test-tool dir-iterator ./dir >out &&
	sort out >./actual-iteration-sorted-output &&
 
	test_cmp expected-iteration-sorted-output actual-iteration-sorted-output
'
 
test_expect_success 'dir-iterator should list files in the correct order' '
	cat >expected-pre-order-output <<-EOF &&
	[d] (a) [a] ./dir2/a
	[d] (a/b) [b] ./dir2/a/b
	[d] (a/b/c) [c] ./dir2/a/b/c
	[f] (a/b/c/d) [d] ./dir2/a/b/c/d
	EOF
 
	test-tool dir-iterator ./dir2 >actual-pre-order-output &&
 
	test_cmp expected-pre-order-output actual-pre-order-output
'
 
test_done