Skip to content

Commit 633734d

Browse files
peffgitster
authored andcommitted
t0001: use test_path_is_*
t0001 predates the test_path_is_* helpers, and uses "test -f" and "test -d" directly. Using the helpers provides better debugging output, and are a little more robust. As opposed to "! test -d", test_path_is_missing will actually makes sure the path does not exist at all. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3d06c5f commit 633734d

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

t/t0001-init.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ test_expect_success 'init with --template (blank)' '
199199
cd template-plain &&
200200
git init
201201
) &&
202-
test -f template-plain/.git/info/exclude &&
202+
test_path_is_file template-plain/.git/info/exclude &&
203203
(
204204
mkdir template-blank &&
205205
cd template-blank &&
206206
git init --template=
207207
) &&
208-
! test -f template-blank/.git/info/exclude
208+
test_path_is_missing template-blank/.git/info/exclude
209209
'
210210

211211
test_expect_success 'init with init.templatedir set' '
@@ -263,15 +263,15 @@ test_expect_success 'init creates a new directory' '
263263
rm -fr newdir &&
264264
(
265265
git init newdir &&
266-
test -d newdir/.git/refs
266+
test_path_is_dir newdir/.git/refs
267267
)
268268
'
269269

270270
test_expect_success 'init creates a new bare directory' '
271271
rm -fr newdir &&
272272
(
273273
git init --bare newdir &&
274-
test -d newdir/refs
274+
test_path_is_dir newdir/refs
275275
)
276276
'
277277

@@ -280,7 +280,7 @@ test_expect_success 'init recreates a directory' '
280280
(
281281
mkdir newdir &&
282282
git init newdir &&
283-
test -d newdir/.git/refs
283+
test_path_is_dir newdir/.git/refs
284284
)
285285
'
286286

@@ -289,14 +289,14 @@ test_expect_success 'init recreates a new bare directory' '
289289
(
290290
mkdir newdir &&
291291
git init --bare newdir &&
292-
test -d newdir/refs
292+
test_path_is_dir newdir/refs
293293
)
294294
'
295295

296296
test_expect_success 'init creates a new deep directory' '
297297
rm -fr newdir &&
298298
git init newdir/a/b/c &&
299-
test -d newdir/a/b/c/.git/refs
299+
test_path_is_dir newdir/a/b/c/.git/refs
300300
'
301301

302302
test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shared)' '
@@ -306,7 +306,7 @@ test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shar
306306
# the repository itself should follow "shared"
307307
umask 002 &&
308308
git init --bare --shared=0660 newdir/a/b/c &&
309-
test -d newdir/a/b/c/refs &&
309+
test_path_is_dir newdir/a/b/c/refs &&
310310
ls -ld newdir/a newdir/a/b > lsab.out &&
311311
! grep -v "^drwxrw[sx]r-x" lsab.out &&
312312
ls -ld newdir/a/b/c > lsc.out &&
@@ -319,7 +319,7 @@ test_expect_success 'init notices EEXIST (1)' '
319319
(
320320
>newdir &&
321321
test_must_fail git init newdir &&
322-
test -f newdir
322+
test_path_is_file newdir
323323
)
324324
'
325325

@@ -329,7 +329,7 @@ test_expect_success 'init notices EEXIST (2)' '
329329
mkdir newdir &&
330330
>newdir/a
331331
test_must_fail git init newdir/a/b &&
332-
test -f newdir/a
332+
test_path_is_file newdir/a
333333
)
334334
'
335335

@@ -345,23 +345,23 @@ test_expect_success POSIXPERM,SANITY 'init notices EPERM' '
345345
test_expect_success 'init creates a new bare directory with global --bare' '
346346
rm -rf newdir &&
347347
git --bare init newdir &&
348-
test -d newdir/refs
348+
test_path_is_dir newdir/refs
349349
'
350350

351351
test_expect_success 'init prefers command line to GIT_DIR' '
352352
rm -rf newdir &&
353353
mkdir otherdir &&
354354
GIT_DIR=otherdir git --bare init newdir &&
355-
test -d newdir/refs &&
356-
! test -d otherdir/refs
355+
test_path_is_dir newdir/refs &&
356+
test_path_is_missing otherdir/refs
357357
'
358358

359359
test_expect_success 'init with separate gitdir' '
360360
rm -rf newdir &&
361361
git init --separate-git-dir realgitdir newdir &&
362362
echo "gitdir: `pwd`/realgitdir" >expected &&
363363
test_cmp expected newdir/.git &&
364-
test -d realgitdir/refs
364+
test_path_is_dir realgitdir/refs
365365
'
366366

367367
test_expect_success 're-init on .git file' '
@@ -375,8 +375,8 @@ test_expect_success 're-init to update git link' '
375375
) &&
376376
echo "gitdir: `pwd`/surrealgitdir" >expected &&
377377
test_cmp expected newdir/.git &&
378-
test -d surrealgitdir/refs &&
379-
! test -d realgitdir/refs
378+
test_path_is_dir surrealgitdir/refs &&
379+
test_path_is_missing realgitdir/refs
380380
'
381381

382382
test_expect_success 're-init to move gitdir' '
@@ -388,7 +388,7 @@ test_expect_success 're-init to move gitdir' '
388388
) &&
389389
echo "gitdir: `pwd`/realgitdir" >expected &&
390390
test_cmp expected newdir/.git &&
391-
test -d realgitdir/refs
391+
test_path_is_dir realgitdir/refs
392392
'
393393

394394
test_expect_success SYMLINKS 're-init to move gitdir symlink' '
@@ -403,7 +403,7 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
403403
echo "gitdir: `pwd`/realgitdir" >expected &&
404404
test_cmp expected newdir/.git &&
405405
test_cmp expected newdir/here &&
406-
test -d realgitdir/refs
406+
test_path_is_dir realgitdir/refs
407407
'
408408

409409
test_done

0 commit comments

Comments
 (0)