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 <gitster@pobox.com>

Junio C Hamano committed Feb 6, 2014 at 10:16 UTC c4a7bce1b5d1ad18482a87cb80a6bddabb925f62
1 file changed +30 -22
t/t0003-attributes.sh
+30 -22
@@ -197,39 +197,47 @@ test_expect_success 'root subdir attribute test' '
197 '
198
199 test_expect_success 'setup bare' '
200 - git clone --bare . bare.git &&
201 - cd bare.git
200 + git clone --bare . bare.git
201 '
202
203 test_expect_success 'bare repository: check that .gitattribute is ignored' '
204 (
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 + )
216 '
217
218 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 + )
226 '
227
228 test_expect_success 'bare repository: test info/attributes' '
229 (
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 + )
241 '
242
243 test_done