git-check-attr: Drive two tests using the same raw data
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Aug 4, 2011 at 06:36 UTC
c9d8f0ac3b9029d825c7d1c049953aacbc489e1c
1 file changed
+23
-36
t/t0003-attributes.sh
+23
-36
@@ -38,7 +38,25 @@ test_expect_success 'setup' '
38
) >a/b/.gitattributes &&
39
(
40
echo "global test=global"
41
- ) >"$HOME"/global-gitattributes
41
+ ) >"$HOME"/global-gitattributes &&
42
+ cat <<EOF >expect-all
43
+f: test: f
44
+a/f: test: f
45
+a/c/f: test: f
46
+a/g: test: a/g
47
+a/b/g: test: a/b/g
48
+b/g: test: unspecified
49
+a/b/h: test: a/b/h
50
+a/b/d/g: test: a/b/d/*
51
+onoff: test: unset
52
+offon: test: set
53
+no: notest: set
54
+no: test: unspecified
55
+a/b/d/no: notest: set
56
+a/b/d/no: test: a/b/d/*
57
+a/b/d/yes: notest: set
58
+a/b/d/yes: test: unspecified
59
+EOF
60
61
'
62
@@ -87,47 +105,16 @@ test_expect_success 'core.attributesfile' '
105
106
test_expect_success 'attribute test: read paths from stdin' '
107
90
- cat <<EOF > expect &&
91
-f: test: f
92
-a/f: test: f
93
-a/c/f: test: f
94
-a/g: test: a/g
95
-a/b/g: test: a/b/g
96
-b/g: test: unspecified
97
-a/b/h: test: a/b/h
98
-a/b/d/g: test: a/b/d/*
99
-onoff: test: unset
100
-offon: test: set
101
-no: test: unspecified
102
-a/b/d/no: test: a/b/d/*
103
-a/b/d/yes: test: unspecified
104
-EOF
105
-
108
+ grep -v notest < expect-all > expect &&
109
sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
110
test_cmp expect actual
111
'
112
113
test_expect_success 'attribute test: --all option' '
114
112
- cat <<EOF > all &&
113
-f: test: f
114
-a/f: test: f
115
-a/c/f: test: f
116
-a/g: test: a/g
117
-a/b/g: test: a/b/g
118
-b/g: test: unspecified
119
-a/b/h: test: a/b/h
120
-a/b/d/g: test: a/b/d/*
121
-onoff: test: unset
122
-offon: test: set
123
-no: notest: set
124
-a/b/d/no: test: a/b/d/*
125
-a/b/d/no: notest: set
126
-a/b/d/yes: notest: set
127
-EOF
128
-
129
- grep -v unspecified < all | sort > expect &&
130
- sed -e "s/:.*//" < all | uniq | git check-attr --stdin --all | sort > actual &&
115
+ grep -v unspecified < expect-all | sort > expect &&
116
+ sed -e "s/:.*//" < expect-all | uniq |
117
+ git check-attr --stdin --all | sort > actual &&
118
test_cmp expect actual
119
'
120