Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit c4a7bce

Browse files
committed
t0003: do not chdir the whole test process
Moving to some other directory and letting the remainder of the test pieces to expect that they start there is a bad practice. The test that contains chdir itself may fail (or by mistake skipped via the GIT_SKIP_TESTS mechanism) in which case the remainder may operate on files in unexpected places. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1599999 commit c4a7bce

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

t/t0003-attributes.sh

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,39 +197,47 @@ test_expect_success 'root subdir attribute test' '
197197
'
198198

199199
test_expect_success 'setup bare' '
200-
git clone --bare . bare.git &&
201-
cd bare.git
200+
git clone --bare . bare.git
202201
'
203202

204203
test_expect_success 'bare repository: check that .gitattribute is ignored' '
205204
(
206-
echo "f test=f"
207-
echo "a/i test=a/i"
208-
) >.gitattributes &&
209-
attr_check f unspecified &&
210-
attr_check a/f unspecified &&
211-
attr_check a/c/f unspecified &&
212-
attr_check a/i unspecified &&
213-
attr_check subdir/a/i unspecified
205+
cd bare.git &&
206+
(
207+
echo "f test=f"
208+
echo "a/i test=a/i"
209+
) >.gitattributes &&
210+
attr_check f unspecified &&
211+
attr_check a/f unspecified &&
212+
attr_check a/c/f unspecified &&
213+
attr_check a/i unspecified &&
214+
attr_check subdir/a/i unspecified
215+
)
214216
'
215217

216218
test_expect_success 'bare repository: check that --cached honors index' '
217-
GIT_INDEX_FILE=../.git/index \
218-
git check-attr --cached --stdin --all <../stdin-all |
219-
sort >actual &&
220-
test_cmp ../specified-all actual
219+
(
220+
cd bare.git &&
221+
GIT_INDEX_FILE=../.git/index \
222+
git check-attr --cached --stdin --all <../stdin-all |
223+
sort >actual &&
224+
test_cmp ../specified-all actual
225+
)
221226
'
222227

223228
test_expect_success 'bare repository: test info/attributes' '
224229
(
225-
echo "f test=f"
226-
echo "a/i test=a/i"
227-
) >info/attributes &&
228-
attr_check f f &&
229-
attr_check a/f f &&
230-
attr_check a/c/f f &&
231-
attr_check a/i a/i &&
232-
attr_check subdir/a/i unspecified
230+
cd bare.git &&
231+
(
232+
echo "f test=f"
233+
echo "a/i test=a/i"
234+
) >info/attributes &&
235+
attr_check f f &&
236+
attr_check a/f f &&
237+
attr_check a/c/f f &&
238+
attr_check a/i a/i &&
239+
attr_check subdir/a/i unspecified
240+
)
233241
'
234242

235243
test_done

0 commit comments

Comments
 (0)