diff mbox series

[13/15] t1409: use test_path_is_missing()

Message ID 27b32962427e5b74569b08dc4c0de40b67388615.1576583819.git.liu.denton@gmail.com (mailing list archive)
State New, archived
Headers show
Series t: replace incorrect test_must_fail usage (part 1) | expand

Commit Message

Denton Liu Dec. 17, 2019, 12:01 p.m. UTC
The test_must_fail() function should only be used for git commands since
we should assume that external commands work sanely. Replace
`test_must_fail test -f` with `test_path_is_missing` since we expect
these files to not exist.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t1409-avoid-packing-refs.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Junio C Hamano Dec. 17, 2019, 7:01 p.m. UTC | #1
Denton Liu <liu.denton@gmail.com> writes:

> The test_must_fail() function should only be used for git commands since
> we should assume that external commands work sanely. Replace
> `test_must_fail test -f` with `test_path_is_missing` since we expect
> these files to not exist.

s/these files/these paths/; 

"! test -f FOO" allowed FOO to be a directory, but by using
test_path_is_missing we are no longer allowing FOO to exist in any
form.  I think the changes are correct, but rephrasing "files" to
"paths" would emphasize the reason why it is a good change, I would
say.

Thanks.


> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  t/t1409-avoid-packing-refs.sh | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/t/t1409-avoid-packing-refs.sh b/t/t1409-avoid-packing-refs.sh
> index f74d890e82..be12fb6350 100755
> --- a/t/t1409-avoid-packing-refs.sh
> +++ b/t/t1409-avoid-packing-refs.sh
> @@ -27,15 +27,15 @@ test_expect_success 'setup' '
>  '
>  
>  test_expect_success 'do not create packed-refs file gratuitously' '
> -	test_must_fail test -f .git/packed-refs &&
> +	test_path_is_missing .git/packed-refs &&
>  	git update-ref refs/heads/foo $A &&
> -	test_must_fail test -f .git/packed-refs &&
> +	test_path_is_missing .git/packed-refs &&
>  	git update-ref refs/heads/foo $B &&
> -	test_must_fail test -f .git/packed-refs &&
> +	test_path_is_missing .git/packed-refs &&
>  	git update-ref refs/heads/foo $C $B &&
> -	test_must_fail test -f .git/packed-refs &&
> +	test_path_is_missing .git/packed-refs &&
>  	git update-ref -d refs/heads/foo &&
> -	test_must_fail test -f .git/packed-refs
> +	test_path_is_missing .git/packed-refs
>  '
>  
>  test_expect_success 'check that marking the packed-refs file works' '
diff mbox series

Patch

diff --git a/t/t1409-avoid-packing-refs.sh b/t/t1409-avoid-packing-refs.sh
index f74d890e82..be12fb6350 100755
--- a/t/t1409-avoid-packing-refs.sh
+++ b/t/t1409-avoid-packing-refs.sh
@@ -27,15 +27,15 @@  test_expect_success 'setup' '
 '
 
 test_expect_success 'do not create packed-refs file gratuitously' '
-	test_must_fail test -f .git/packed-refs &&
+	test_path_is_missing .git/packed-refs &&
 	git update-ref refs/heads/foo $A &&
-	test_must_fail test -f .git/packed-refs &&
+	test_path_is_missing .git/packed-refs &&
 	git update-ref refs/heads/foo $B &&
-	test_must_fail test -f .git/packed-refs &&
+	test_path_is_missing .git/packed-refs &&
 	git update-ref refs/heads/foo $C $B &&
-	test_must_fail test -f .git/packed-refs &&
+	test_path_is_missing .git/packed-refs &&
 	git update-ref -d refs/heads/foo &&
-	test_must_fail test -f .git/packed-refs
+	test_path_is_missing .git/packed-refs
 '
 
 test_expect_success 'check that marking the packed-refs file works' '