Add tests for --quiet option of diff programs
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Alex Riesen committed
Mar 14, 2007 at 23:57 UTC
0c66d6be4f888096865b8f3d5fdc00c83e4ecc3f
1 file changed
+80
t/t4017-quiet.sh
new
+80
@@ -0,0 +1,80 @@
1
+#!/bin/sh
2
+
3
+test_description='Return value of diffs'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success 'setup' '
8
+ echo 1 >a &&
9
+ git add . &&
10
+ git commit -m first &&
11
+ echo 2 >b &&
12
+ git add . &&
13
+ git commit -a -m second
14
+'
15
+
16
+test_expect_success 'git diff-tree HEAD^ HEAD' '
17
+ git diff-tree --quiet HEAD^ HEAD >cnt
18
+ test $? = 1 && test $(wc -l <cnt) = 0
19
+'
20
+test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
21
+ git diff-tree --quiet HEAD^ HEAD -- a >cnt
22
+ test $? = 0 && test $(wc -l <cnt) = 0
23
+'
24
+test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
25
+ git diff-tree --quiet HEAD^ HEAD -- b >cnt
26
+ test $? = 1 && test $(wc -l <cnt) = 0
27
+'
28
+# this diff outputs one line: sha1 of the given head
29
+test_expect_success 'echo HEAD | git diff-tree --stdin' '
30
+ echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt
31
+ test $? = 1 && test $(wc -l <cnt) = 1
32
+'
33
+test_expect_success 'git diff-tree HEAD HEAD' '
34
+ git diff-tree --quiet HEAD HEAD >cnt
35
+ test $? = 0 && test $(wc -l <cnt) = 0
36
+'
37
+test_expect_success 'git diff-files' '
38
+ git diff-files --quiet >cnt
39
+ test $? = 0 && test $(wc -l <cnt) = 0
40
+'
41
+test_expect_success 'git diff-index --cached HEAD' '
42
+ git diff-index --quiet --cached HEAD >cnt
43
+ test $? = 0 && test $(wc -l <cnt) = 0
44
+'
45
+test_expect_success 'git diff-index --cached HEAD^' '
46
+ git diff-index --quiet --cached HEAD^ >cnt
47
+ test $? = 1 && test $(wc -l <cnt) = 0
48
+'
49
+test_expect_success 'git diff-index --cached HEAD^' '
50
+ echo text >>b &&
51
+ echo 3 >c &&
52
+ git add . && {
53
+ git diff-index --quiet --cached HEAD^ >cnt
54
+ test $? = 1 && test $(wc -l <cnt) = 0
55
+ }
56
+'
57
+test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
58
+ git commit -m "text in b" && {
59
+ git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt
60
+ test $? = 1 && test $(wc -l <cnt) = 0
61
+ }
62
+'
63
+test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
64
+ git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt
65
+ test $? = 0 && test $(wc -l <cnt) = 0
66
+'
67
+test_expect_success 'git diff-files' '
68
+ echo 3 >>c && {
69
+ git diff-files --quiet >cnt
70
+ test $? = 1 && test $(wc -l <cnt) = 0
71
+ }
72
+'
73
+test_expect_success 'git diff-index --cached HEAD' '
74
+ git update-index c && {
75
+ git diff-index --quiet --cached HEAD >cnt
76
+ test $? = 1 && test $(wc -l <cnt) = 0
77
+ }
78
+'
79
+
80
+test_done