Skip to content

Commit c9d8f0a

Browse files
mhaggergitster
authored andcommitted
git-check-attr: Drive two tests using the same raw data
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ca0f18 commit c9d8f0a

File tree

1 file changed

+23
-36
lines changed

1 file changed

+23
-36
lines changed

t/t0003-attributes.sh

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,25 @@ test_expect_success 'setup' '
3838
) >a/b/.gitattributes &&
3939
(
4040
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
4260
4361
'
4462

@@ -87,47 +105,16 @@ test_expect_success 'core.attributesfile' '
87105

88106
test_expect_success 'attribute test: read paths from stdin' '
89107
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 &&
106109
sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
107110
test_cmp expect actual
108111
'
109112

110113
test_expect_success 'attribute test: --all option' '
111114
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 &&
131118
test_cmp expect actual
132119
'
133120

0 commit comments

Comments
 (0)