* [PATCH] t7300-clean.sh: use test_path_* helper functions
@ 2024-10-07 19:19 Samuel Adekunle Abraham via GitGitGadget
2024-10-07 23:01 ` Usman Akinyemi
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Samuel Adekunle Abraham via GitGitGadget @ 2024-10-07 19:19 UTC (permalink / raw)
To: git; +Cc: Samuel Adekunle Abraham, Abraham Samuel Adekunle
From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
The test_path_* helper functions provide error messages which show the cause
of the test failures. Hence they are used to replace every instance of
test - [def] uses in the script.
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
---
[Outreachy] [PATCH] t7300-clean.sh: replace instances of test - [def]
with test_path_* helper functions.
The test_path_* helper functions provide error messages which show the
cause of the test failure should a failure occur. This is more useful
and helpful when debugging errors.
Signed-off-by: Abraham Samuel Adekunle abrahamadekunle50@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1811%2Fdevdekunle%2Fupdate_tests-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1811/devdekunle/update_tests-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1811
t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
1 file changed, 185 insertions(+), 185 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 0aae0dee670..5c97eb0dfe9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so &&
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so &&
git update-index --no-skip-worktree .gitignore &&
git checkout .gitignore
'
@@ -47,15 +47,15 @@ test_expect_success 'git clean' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
mkdir -p build docs src/test &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
(cd src/ && git clean) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f src/test/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file src/test/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
mkdir -p build docs src/feature &&
touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
(cd src/ && git clean -d feature/) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test ! -f src/feature/file.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing src/feature/file.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
ln -s docs/manual.txt src/part4.c &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -f src/part4.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing src/part4.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
touch a.clean b.clean other.c &&
git clean "*.clean" &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.clean &&
- test ! -f b.clean &&
- test -f other.c
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.clean &&
+ test_path_is_missing b.clean &&
+ test_path_is_file other.c
'
@@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
mkdir -p build docs examples &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
git clean -d src/ examples/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test ! -f examples/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing examples/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
test_expect_success 'clean.requireForce and -f' '
git clean -f &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -d &&
- test -f foo/.git/index &&
- test -f foo/hello.world &&
- test -f baz/boo/.git/index &&
- test -f baz/boo/deeper.world &&
- ! test -d bar
+ test_path_is_file foo/.git/index &&
+ test_path_is_file foo/hello.world &&
+ test_path_is_file baz/boo/.git/index &&
+ test_path_is_file baz/boo/deeper.world &&
+ test_path_is_missing bar
'
test_expect_success 'should clean things that almost look like git but are not' '
@@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -f -d &&
- ! test -d foo &&
- ! test -d bar &&
- ! test -d baz
+ test_path_is_missing foo &&
+ test_path_is_missing bar &&
+ test_path_is_missing baz
'
test_expect_success 'git clean -e' '
@@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
touch known 1 2 3 &&
git add known &&
git clean -f -e 1 -e 2 &&
- test -e 1 &&
- test -e 2 &&
- ! (test -e 3) &&
- test -e known
+ test_path_exists 1 &&
+ test_path_exists 2 &&
+ test_path_is_missing 3 &&
+ test_path_exists known
)
'
@@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
mkdir foo &&
chmod a= foo &&
git clean -dfx foo &&
- ! test -d foo
+ test_path_is_missing foo
'
test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-07 19:19 [PATCH] t7300-clean.sh: use test_path_* helper functions Samuel Adekunle Abraham via GitGitGadget
@ 2024-10-07 23:01 ` Usman Akinyemi
2024-10-08 1:48 ` Junio C Hamano
2024-10-08 12:22 ` [PATCH v2] t7300-clean.sh: use test_path_* helper functions for error logging Samuel Adekunle Abraham via GitGitGadget
2 siblings, 0 replies; 15+ messages in thread
From: Usman Akinyemi @ 2024-10-07 23:01 UTC (permalink / raw)
To: Samuel Adekunle Abraham via GitGitGadget; +Cc: git, Samuel Adekunle Abraham
On Mon, Oct 7, 2024 at 7:19 PM Samuel Adekunle Abraham via
GitGitGadget <gitgitgadget@gmail.com> wrote:
>
> From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
>
> The test_path_* helper functions provide error messages which show the cause
> of the test failures. Hence they are used to replace every instance of
> test - [def] uses in the script.
Maybe also adding what they are being replaced with might make the
description much clearer.
>
> Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
> ---
> [Outreachy] [PATCH] t7300-clean.sh: replace instances of test - [def]
> with test_path_* helper functions.
Hello Samuel,
Good Job here, just a simple observation.
I think it might be much clearer if you used test -(d|e|f) instead of
test - [def], as it much clearer.
Overall it looks good to me.
>
> The test_path_* helper functions provide error messages which show the
> cause of the test failure should a failure occur. This is more useful
> and helpful when debugging errors.
>
> Signed-off-by: Abraham Samuel Adekunle abrahamadekunle50@gmail.com
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1811%2Fdevdekunle%2Fupdate_tests-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1811/devdekunle/update_tests-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1811
>
> t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
> 1 file changed, 185 insertions(+), 185 deletions(-)
>
> diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> index 0aae0dee670..5c97eb0dfe9 100755
> --- a/t/t7300-clean.sh
> +++ b/t/t7300-clean.sh
> @@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so &&
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so &&
> git update-index --no-skip-worktree .gitignore &&
> git checkout .gitignore
> '
> @@ -47,15 +47,15 @@ test_expect_success 'git clean' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean src/ &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean src/ src/ &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
> mkdir -p build docs src/test &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
> (cd src/ && git clean) &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f src/test/1.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file src/test/1.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
> mkdir -p build docs src/feature &&
> touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
> (cd src/ && git clean -d feature/) &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test ! -f src/feature/file.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_missing src/feature/file.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> ln -s docs/manual.txt src/part4.c &&
> git clean &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -f src/part4.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing src/part4.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
>
> touch a.clean b.clean other.c &&
> git clean "*.clean" &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.clean &&
> - test ! -f b.clean &&
> - test -f other.c
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.clean &&
> + test_path_is_missing b.clean &&
> + test_path_is_file other.c
>
> '
>
> @@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -n &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -d docs &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing docs &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
> mkdir -p build docs examples &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
> git clean -d src/ examples/ &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -f examples/1.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing examples/1.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -x &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -x &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -d docs &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing docs &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -x -e src &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test -f src/part3.c &&
> - test ! -d docs &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_missing docs &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -X &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -X &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -X -e src &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -n &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> test_expect_success 'clean.requireForce and -f' '
>
> git clean -f &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
> test_commit deeply.nested deeper.world
> ) &&
> git clean -f -d &&
> - test -f foo/.git/index &&
> - test -f foo/hello.world &&
> - test -f baz/boo/.git/index &&
> - test -f baz/boo/deeper.world &&
> - ! test -d bar
> + test_path_is_file foo/.git/index &&
> + test_path_is_file foo/hello.world &&
> + test_path_is_file baz/boo/.git/index &&
> + test_path_is_file baz/boo/deeper.world &&
> + test_path_is_missing bar
> '
>
> test_expect_success 'should clean things that almost look like git but are not' '
> @@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
> test_commit deeply.nested deeper.world
> ) &&
> git clean -f -f -d &&
> - ! test -d foo &&
> - ! test -d bar &&
> - ! test -d baz
> + test_path_is_missing foo &&
> + test_path_is_missing bar &&
> + test_path_is_missing baz
> '
>
> test_expect_success 'git clean -e' '
> @@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
> touch known 1 2 3 &&
> git add known &&
> git clean -f -e 1 -e 2 &&
> - test -e 1 &&
> - test -e 2 &&
> - ! (test -e 3) &&
> - test -e known
> + test_path_exists 1 &&
> + test_path_exists 2 &&
> + test_path_is_missing 3 &&
> + test_path_exists known
> )
> '
>
> @@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
> mkdir foo &&
> chmod a= foo &&
> git clean -dfx foo &&
> - ! test -d foo
> + test_path_is_missing foo
> '
>
> test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
>
> base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
> --
> gitgitgadget
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-07 19:19 [PATCH] t7300-clean.sh: use test_path_* helper functions Samuel Adekunle Abraham via GitGitGadget
2024-10-07 23:01 ` Usman Akinyemi
@ 2024-10-08 1:48 ` Junio C Hamano
2024-10-08 5:12 ` Samuel Abraham
2024-10-08 8:58 ` Samuel Abraham
2024-10-08 12:22 ` [PATCH v2] t7300-clean.sh: use test_path_* helper functions for error logging Samuel Adekunle Abraham via GitGitGadget
2 siblings, 2 replies; 15+ messages in thread
From: Junio C Hamano @ 2024-10-08 1:48 UTC (permalink / raw)
To: Samuel Adekunle Abraham via GitGitGadget; +Cc: git, Samuel Adekunle Abraham
"Samuel Adekunle Abraham via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
>
> The test_path_* helper functions provide error messages which show the cause
> of the test failures.
> Hence they are used to replace every instance of
> test - [def] uses in the script.
It is unclear the use of present tense "they are used" describes the
status quo, or the way you wish the test script were written.
The usual way to compose a log message of this project is to
- Give an observation on how the current system work in the present
tense (so no need to say "Currently X is Y", just "X is Y"), and
discuss what you perceive as a problem in it.
- Propose a solution (optional---often, problem description
trivially leads to an obvious solution in reader's minds).
- Give commands to the codebase to "become like so".
in this order.
Also, for a patch like this one, which is rather large, repetitious,
and tire reviewers to miss simple typos easily, giving a procedure
to mechanically validate the patch would help. Instead of having to
match up "test -f" that was removed with "test_is_file" that was
added, while ensuring the pathname given to them are the same, a
reader can reason about what the mechanical rewrite is doing, and
when the reader is convinced that the mechanical rewrite is doing
the right thing, being able to mechanically compare the result of
the procedure with the result of applying a patch is a really
powerful thing.
I probably would have written your two paragraphs more like the
first two paragraphs below, followed by the validation procedure,
like this:
This test script uses "test -[edf]", but when a test fails
because a file given to "test -f" does not exist, it fails
silently.
Use test_path_* helpers, which are designed to give better error
messages when their expectations are not met.
If you pass the current test script through
sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
-e 's/^\( *\)test -d /\1test_path_is_dir /' \
-e 's/^\( *\)test -e /\1test_path_exists /' \
-e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
-e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /'
and then compare the result with the result of applying this
patch, you will see an instance of "! (test -e 3)", which was
manually replaced with "test_path_is_missing 3", and everything
else should match.
And I did perform the sed script, aka "how would I reproduce what is
in this patch" procedure, and compared the result with this patch.
The patch seems to be doing the right thing.
Manual validation is still needed for "test ! -f foo". If the
original expects 'foo' to be gone, and has a reason to expect 'foo'
to be a file when the code being tested is broken, then rewriting it
into "test_path_is_missing" is OK. But otherwise, the original
would have been happy when 'foo' existed as a directory and
rewriting it into "test_path_is_missing" is not quite right.
This check cannot be done mechanically, unfortunately. Hits from
$ git show | grep -e 'test ! -[df]'
need to be eyeballed to make sure that it is reasonable to rewrite
"test ! -f foo" into "test_path_is_missing foo".
For example:
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean &&
> ...
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
this test creates a.out and src/part3.c as regular files before
running "git clean", so the expected failure modes do not include
a.out to be a directory (which would also make "test ! -f a.out"
happy), and rewriting it to "test_path_is_missing a.out" is fine.
I did *not* go through all the instances of test_path_is_missing
in the postimage of this patch. Instead of forcing reviewers to
do so on their own, mentioning that the author did that already
would probably help the process.
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-08 1:48 ` Junio C Hamano
@ 2024-10-08 5:12 ` Samuel Abraham
2024-10-08 8:58 ` Samuel Abraham
1 sibling, 0 replies; 15+ messages in thread
From: Samuel Abraham @ 2024-10-08 5:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Samuel Adekunle Abraham via GitGitGadget, git
On Tue, Oct 8, 2024 at 2:48 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Samuel Adekunle Abraham via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
> >
> > The test_path_* helper functions provide error messages which show the cause
> > of the test failures.
>
> > Hence they are used to replace every instance of
> > test - [def] uses in the script.
>
> It is unclear the use of present tense "they are used" describes the
> status quo, or the way you wish the test script were written.
>
> The usual way to compose a log message of this project is to
>
> - Give an observation on how the current system work in the present
> tense (so no need to say "Currently X is Y", just "X is Y"), and
> discuss what you perceive as a problem in it.
>
> - Propose a solution (optional---often, problem description
> trivially leads to an obvious solution in reader's minds).
>
> - Give commands to the codebase to "become like so".
>
> in this order.
>
> Also, for a patch like this one, which is rather large, repetitious,
> and tire reviewers to miss simple typos easily, giving a procedure
> to mechanically validate the patch would help. Instead of having to
> match up "test -f" that was removed with "test_is_file" that was
> added, while ensuring the pathname given to them are the same, a
> reader can reason about what the mechanical rewrite is doing, and
> when the reader is convinced that the mechanical rewrite is doing
> the right thing, being able to mechanically compare the result of
> the procedure with the result of applying a patch is a really
> powerful thing.
>
> I probably would have written your two paragraphs more like the
> first two paragraphs below, followed by the validation procedure,
> like this:
>
> This test script uses "test -[edf]", but when a test fails
> because a file given to "test -f" does not exist, it fails
> silently.
>
> Use test_path_* helpers, which are designed to give better error
> messages when their expectations are not met.
>
> If you pass the current test script through
>
> sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
> -e 's/^\( *\)test -d /\1test_path_is_dir /' \
> -e 's/^\( *\)test -e /\1test_path_exists /' \
> -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
> -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /'
>
> and then compare the result with the result of applying this
> patch, you will see an instance of "! (test -e 3)", which was
> manually replaced with "test_path_is_missing 3", and everything
> else should match.
>
> And I did perform the sed script, aka "how would I reproduce what is
> in this patch" procedure, and compared the result with this patch.
> The patch seems to be doing the right thing.
>
> Manual validation is still needed for "test ! -f foo". If the
> original expects 'foo' to be gone, and has a reason to expect 'foo'
> to be a file when the code being tested is broken, then rewriting it
> into "test_path_is_missing" is OK. But otherwise, the original
> would have been happy when 'foo' existed as a directory and
> rewriting it into "test_path_is_missing" is not quite right.
>
> This check cannot be done mechanically, unfortunately. Hits from
>
> $ git show | grep -e 'test ! -[df]'
>
> need to be eyeballed to make sure that it is reasonable to rewrite
> "test ! -f foo" into "test_path_is_missing foo".
>
> For example:
>
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean &&
> > ...
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
>
> this test creates a.out and src/part3.c as regular files before
> running "git clean", so the expected failure modes do not include
> a.out to be a directory (which would also make "test ! -f a.out"
> happy), and rewriting it to "test_path_is_missing a.out" is fine.
>
> I did *not* go through all the instances of test_path_is_missing
> in the postimage of this patch. Instead of forcing reviewers to
> do so on their own, mentioning that the author did that already
> would probably help the process.
>
> Thanks.
Hi Junio,
Thank you very much for your time and very detailed review. I will
make corrections in my next patch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-08 1:48 ` Junio C Hamano
2024-10-08 5:12 ` Samuel Abraham
@ 2024-10-08 8:58 ` Samuel Abraham
2024-10-08 18:13 ` Junio C Hamano
1 sibling, 1 reply; 15+ messages in thread
From: Samuel Abraham @ 2024-10-08 8:58 UTC (permalink / raw)
To: Junio C Hamano
Cc: Samuel Adekunle Abraham via GitGitGadget, git, ps, phillip.wood,
christian.couder
On Tue, Oct 8, 2024 at 2:48 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Samuel Adekunle Abraham via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
> >
> Manual validation is still needed for "test ! -f foo". If the
> original expects 'foo' to be gone, and has a reason to expect 'foo'
> to be a file when the code being tested is broken, then rewriting it
> into "test_path_is_missing" is OK. But otherwise, the original
> would have been happy when 'foo' existed as a directory and
> rewriting it into "test_path_is_missing" is not quite right.
>
> This check cannot be done mechanically, unfortunately. Hits from
>
> $ git show | grep -e 'test ! -[df]'
>
> need to be eyeballed to make sure that it is reasonable to rewrite
> "test ! -f foo" into "test_path_is_missing foo".
>
> For example:
>
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean &&
> > ...
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
>
> this test creates a.out and src/part3.c as regular files before
> running "git clean", so the expected failure modes do not include
> a.out to be a directory (which would also make "test ! -f a.out"
> happy), and rewriting it to "test_path_is_missing a.out" is fine.
>
Hi Junio,
Thanks again for your time and review.
I have gone through all the instances of "test ! - [df]" and for each
test case where "test ! -f foo" was used, foo was first created as a
regular file in the control flow before "git clean" was called and is
expected not to exist afterwards.
a few more examples are to the one you referenced above are shown below;
> mkdir -p build docs src/test &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
> (cd src/ && git clean) &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
and
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -X -e src &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
Also for the tests where "test ! -d foo" was used, the control flow
followed similar pattern as mentioned above where foo was created as a
directory and then "git clean -d" was called. The control flow
expected foo to be a directory which could have been removed
afterwards as can be seen below.
> @@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -x -e src &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test -f src/part3.c &&
> - test ! -d docs &&
> - test ! -f obj.o &&
> - test ! -d build
and
> test_expect_success 'should clean things that almost look like git but are not' '
> @@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
> test_commit deeply.nested deeper.world
> ) &&
> git clean -f -f -d &&
> - ! test -d foo &&
> - ! test -d bar &&
> - ! test -d baz
This was the reason for replacing "test ! -[df]" with
"test_path_is_missing" where I think is appropriate. I will appreciate
it and be very grateful if test instances in this script where
"test_path_is_missing" is inappropriate to be used are pointed out by
other maintainers as well.
Thanks once again for your time.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2] t7300-clean.sh: use test_path_* helper functions for error logging
2024-10-07 19:19 [PATCH] t7300-clean.sh: use test_path_* helper functions Samuel Adekunle Abraham via GitGitGadget
2024-10-07 23:01 ` Usman Akinyemi
2024-10-08 1:48 ` Junio C Hamano
@ 2024-10-08 12:22 ` Samuel Adekunle Abraham via GitGitGadget
2024-10-09 17:02 ` [PATCH v3] " Samuel Adekunle Abraham via GitGitGadget
2 siblings, 1 reply; 15+ messages in thread
From: Samuel Adekunle Abraham via GitGitGadget @ 2024-10-08 12:22 UTC (permalink / raw)
To: git; +Cc: Usman Akinyemi, Samuel Adekunle Abraham, Abraham Samuel Adekunle
From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
This test script uses "test - [def]", but when a test fails because
the file passed to it does not exist,
it fails silently without an error message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
---
[Outreachy][PATCH] t7300-clean.sh: use test_path_* helper functions for
error logging
This test script uses "test - [def]", but when a test fails because the
file passed to it does not exist, it fails silently without an error
message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
I have added a mechanical validation that applies the same
transformation done in this patch, when the script is passed to a sed
script as shown below
#!/bin/bash
sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
-e 's/^\( *\)test -d /\1test_path_is_dir /' \
-e 's/^\( *\)test -e /\1test_path_exists /' \
-e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
-e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
"$1" >foo.sh
Reviewers can use the sed script to transform the original test script
and compare the results in foo.sh with the results of applying this
patch You will see an instance of "! (test -e 3)" which was manually
replaced with "test_path_is_missing", and everything else should match.
I have carefully studied the instances where "test ! - [df] foo" were
used in the script to make sure that the test instances were expecting a
file or a directory to not exist as the case may be before replacing
with "test_path_is_missing".
Signed-off-by: Abraham Samuel Adekunle abrahamadekunle50@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1811%2Fdevdekunle%2Fupdate_tests-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1811/devdekunle/update_tests-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1811
Range-diff vs v1:
1: fef842b7013 ! 1: 62d57156dcf t7300-clean.sh: use test_path_* helper functions
@@ Metadata
Author: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
## Commit message ##
- t7300-clean.sh: use test_path_* helper functions
+ t7300-clean.sh: use test_path_* helper functions for error logging
- The test_path_* helper functions provide error messages which show the cause
- of the test failures. Hence they are used to replace every instance of
- test - [def] uses in the script.
+ This test script uses "test - [def]", but when a test fails because
+ the file passed to it does not exist,
+ it fails silently without an error message.
+ Use test_path_* helper functions, which are designed to give better
+ error messages when their expectations are not met.
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
1 file changed, 185 insertions(+), 185 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 0aae0dee670..5c97eb0dfe9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so &&
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so &&
git update-index --no-skip-worktree .gitignore &&
git checkout .gitignore
'
@@ -47,15 +47,15 @@ test_expect_success 'git clean' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
mkdir -p build docs src/test &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
(cd src/ && git clean) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f src/test/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file src/test/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
mkdir -p build docs src/feature &&
touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
(cd src/ && git clean -d feature/) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test ! -f src/feature/file.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing src/feature/file.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
ln -s docs/manual.txt src/part4.c &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -f src/part4.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing src/part4.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
touch a.clean b.clean other.c &&
git clean "*.clean" &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.clean &&
- test ! -f b.clean &&
- test -f other.c
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.clean &&
+ test_path_is_missing b.clean &&
+ test_path_is_file other.c
'
@@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
mkdir -p build docs examples &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
git clean -d src/ examples/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test ! -f examples/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing examples/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
test_expect_success 'clean.requireForce and -f' '
git clean -f &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -d &&
- test -f foo/.git/index &&
- test -f foo/hello.world &&
- test -f baz/boo/.git/index &&
- test -f baz/boo/deeper.world &&
- ! test -d bar
+ test_path_is_file foo/.git/index &&
+ test_path_is_file foo/hello.world &&
+ test_path_is_file baz/boo/.git/index &&
+ test_path_is_file baz/boo/deeper.world &&
+ test_path_is_missing bar
'
test_expect_success 'should clean things that almost look like git but are not' '
@@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -f -d &&
- ! test -d foo &&
- ! test -d bar &&
- ! test -d baz
+ test_path_is_missing foo &&
+ test_path_is_missing bar &&
+ test_path_is_missing baz
'
test_expect_success 'git clean -e' '
@@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
touch known 1 2 3 &&
git add known &&
git clean -f -e 1 -e 2 &&
- test -e 1 &&
- test -e 2 &&
- ! (test -e 3) &&
- test -e known
+ test_path_exists 1 &&
+ test_path_exists 2 &&
+ test_path_is_missing 3 &&
+ test_path_exists known
)
'
@@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
mkdir foo &&
chmod a= foo &&
git clean -dfx foo &&
- ! test -d foo
+ test_path_is_missing foo
'
test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-08 8:58 ` Samuel Abraham
@ 2024-10-08 18:13 ` Junio C Hamano
2024-10-09 3:35 ` Samuel Abraham
0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2024-10-08 18:13 UTC (permalink / raw)
To: Samuel Abraham
Cc: Samuel Adekunle Abraham via GitGitGadget, git, ps, phillip.wood,
christian.couder
Samuel Abraham <abrahamadekunle50@gmail.com> writes:
> ...
> This was the reason for replacing "test ! -[df]" with
> "test_path_is_missing" where I think is appropriate.
Telling that concisely in the proposed log message will help those
who are reviewing the patch and those who are reading "git log -p"
later, and that is what I would want to see after a review exchange
like this.
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-08 18:13 ` Junio C Hamano
@ 2024-10-09 3:35 ` Samuel Abraham
2024-10-09 7:20 ` Patrick Steinhardt
0 siblings, 1 reply; 15+ messages in thread
From: Samuel Abraham @ 2024-10-09 3:35 UTC (permalink / raw)
To: Junio C Hamano
Cc: Samuel Adekunle Abraham via GitGitGadget, git, ps, phillip.wood,
christian.couder
On Tue, Oct 8, 2024 at 7:13 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Samuel Abraham <abrahamadekunle50@gmail.com> writes:
>
> > ...
> > This was the reason for replacing "test ! -[df]" with
> > "test_path_is_missing" where I think is appropriate.
>
> Telling that concisely in the proposed log message will help those
> who are reviewing the patch and those who are reading "git log -p"
> later, and that is what I would want to see after a review exchange
> like this.
>
> Thanks.
Hi, Junio
I want to express my gratitude to you and every member for your time,
guidance and patience and to my Outreachy mentors Patrick and Phillip.
It has been a great learning experience. I can see the patch has been
integrated into seen.
I look forward to working on #leftoverbits projects to enhance my understanding
of the git codebase. Thank you very much once again.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-09 3:35 ` Samuel Abraham
@ 2024-10-09 7:20 ` Patrick Steinhardt
2024-10-09 15:41 ` Samuel Abraham
2024-10-09 17:31 ` Junio C Hamano
0 siblings, 2 replies; 15+ messages in thread
From: Patrick Steinhardt @ 2024-10-09 7:20 UTC (permalink / raw)
To: Samuel Abraham
Cc: Junio C Hamano, Samuel Adekunle Abraham via GitGitGadget, git,
phillip.wood, christian.couder
On Wed, Oct 09, 2024 at 04:35:04AM +0100, Samuel Abraham wrote:
> On Tue, Oct 8, 2024 at 7:13 PM Junio C Hamano <gitster@pobox.com> wrote:
> >
> > Samuel Abraham <abrahamadekunle50@gmail.com> writes:
> >
> > > ...
> > > This was the reason for replacing "test ! -[df]" with
> > > "test_path_is_missing" where I think is appropriate.
> >
> > Telling that concisely in the proposed log message will help those
> > who are reviewing the patch and those who are reading "git log -p"
> > later, and that is what I would want to see after a review exchange
> > like this.
> >
> > Thanks.
> Hi, Junio
> I want to express my gratitude to you and every member for your time,
> guidance and patience and to my Outreachy mentors Patrick and Phillip.
> It has been a great learning experience. I can see the patch has been
> integrated into seen.
> I look forward to working on #leftoverbits projects to enhance my understanding
> of the git codebase. Thank you very much once again.
Note that a patch that has been merged into "seen" does not yet say that
it will be part of the next release. "seen" is only an integration
branch for topics which are currently in-flight on the mailing list and
in the process of being reviewed. The intent is that we can catch any
incompatibilities between two different in-flight patch series early.
So declaring victory is a bit too early :) A better indicator is that
the patch has been merged to "next". This is described in
Documentation/MyFirstContribution.txt, section "After Review Approval",
and more in-depth in Documentation/howto/maintain-git.txt.
I think that your v2 isn't quite there yet. As Junio mentions, he'd like
to see an updated commit message that includes your explanations why you
have done certain conversions the way you did. The fact that some parts
of the patch required discussion to arrive at a common understanding is
a good telling factor that a summarized form of the discussion should
likely be part of the commit message such that future readers of the
patch will get the same context.
Patrick
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-09 7:20 ` Patrick Steinhardt
@ 2024-10-09 15:41 ` Samuel Abraham
2024-10-09 17:31 ` Junio C Hamano
1 sibling, 0 replies; 15+ messages in thread
From: Samuel Abraham @ 2024-10-09 15:41 UTC (permalink / raw)
To: Patrick Steinhardt
Cc: Junio C Hamano, Samuel Adekunle Abraham via GitGitGadget, git,
phillip.wood, christian.couder
On Wed, Oct 9, 2024 at 8:20 AM Patrick Steinhardt <ps@pks.im> wrote:
>
> On Wed, Oct 09, 2024 at 04:35:04AM +0100, Samuel Abraham wrote:
> > On Tue, Oct 8, 2024 at 7:13 PM Junio C Hamano <gitster@pobox.com> wrote:
> > >
> > > Samuel Abraham <abrahamadekunle50@gmail.com> writes:
> > >
> > > > ...
> > > > This was the reason for replacing "test ! -[df]" with
> > > > "test_path_is_missing" where I think is appropriate.
> > >
> > > Telling that concisely in the proposed log message will help those
> > > who are reviewing the patch and those who are reading "git log -p"
> > > later, and that is what I would want to see after a review exchange
> > > like this.
> > >
> > > Thanks.
> > Hi, Junio
> > I want to express my gratitude to you and every member for your time,
> > guidance and patience and to my Outreachy mentors Patrick and Phillip.
> > It has been a great learning experience. I can see the patch has been
> > integrated into seen.
> > I look forward to working on #leftoverbits projects to enhance my understanding
> > of the git codebase. Thank you very much once again.
>
> Note that a patch that has been merged into "seen" does not yet say that
> it will be part of the next release. "seen" is only an integration
> branch for topics which are currently in-flight on the mailing list and
> in the process of being reviewed. The intent is that we can catch any
> incompatibilities between two different in-flight patch series early.
>
> So declaring victory is a bit too early :) A better indicator is that
> the patch has been merged to "next". This is described in
> Documentation/MyFirstContribution.txt, section "After Review Approval",
> and more in-depth in Documentation/howto/maintain-git.txt.
>
> I think that your v2 isn't quite there yet. As Junio mentions, he'd like
> to see an updated commit message that includes your explanations why you
> have done certain conversions the way you did. The fact that some parts
> of the patch required discussion to arrive at a common understanding is
> a good telling factor that a summarized form of the discussion should
> likely be part of the commit message such that future readers of the
> patch will get the same context.
>
> Patrick
Hello Patrick,
Thank you very much for the clarification. Yes I was almost
celebrating already :).
I will write a detailed commit message and send an updated patch.
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3] t7300-clean.sh: use test_path_* helper functions for error logging
2024-10-08 12:22 ` [PATCH v2] t7300-clean.sh: use test_path_* helper functions for error logging Samuel Adekunle Abraham via GitGitGadget
@ 2024-10-09 17:02 ` Samuel Adekunle Abraham via GitGitGadget
2024-10-09 17:47 ` Junio C Hamano
2024-10-09 18:22 ` [PATCH v4] " Samuel Adekunle Abraham via GitGitGadget
0 siblings, 2 replies; 15+ messages in thread
From: Samuel Adekunle Abraham via GitGitGadget @ 2024-10-09 17:02 UTC (permalink / raw)
To: git
Cc: Usman Akinyemi, Patrick Steinhardt, Junio C Hamano,
Samuel Adekunle Abraham, Abraham Samuel Adekunle
From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
This test script uses "test - [def]", but when a test fails because
the file passed to it does not exist,
it fails silently without an error message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
I have added a mechanical validation that applies the same transformation
done in this patch, when the test script is passed to a sed script as shown
below.
sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
-e 's/^\( *\)test -d /\1test_path_is_dir /' \
-e 's/^\( *\)test -e /\1test_path_exists /' \
-e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
-e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
"$1" >foo.sh
Reviewers can use the sed script to tranform the original test script and
compare the result in foo.sh with the results of applying the patch.
You will see an instance of "!(test -e 3)" which was manually replaced with
""test_path_is_missing 3", and everything else should match.
Careful and deliberate observation was done to check instances where
"test ! - [df] foo" was used in the test script to make sure that the test
instances were expecting foo to EITHER be a file or a directory, and NOT a
possibility of being both as this would make replacing "test ! -f foo" with
"test_path_is_missing foo" unreasonable.
In the tests control flow, foo has been created as EITHER a
reguar file OR a directory and should NOT exist
after "git clean" or "git clean -d", as the case maybe, has been called.
This made it reasonable to replace
"test ! -[df] foo" with "test_path_is_missing foo".
Examples for each case is shown below
test_expect_success 'git clean with prefix' '
mkdir -p build docs src/test &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
(cd src/ && git clean) &&
test -f Makefile &&
test -f README &&
test -f src/part1.c &&
test -f src/part2.c &&
test -f a.out &&
test ! -f src/part3.c &&
test_expect_success 'git clean -d -x with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X -e src &&
test -f Makefile &&
test -f README &&
test -f src/part1.c &&
test -f src/part2.c &&
test -f a.out &&
test ! -f src/part3.c &&
test -f docs/manual.txt &&
test ! -f obj.o &&
and
test_expect_success 'git clean -d -x with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x -e src &&
test -f Makefile &&
test -f README &&
test -f src/part1.c &&
test -f src/part2.c &&
test ! -f a.out &&
test -f src/part3.c &&
test ! -d docs &&
test ! -f obj.o &&
test ! -d build
and
test_expect_success 'should clean things that almost look like git ...'
test_expect_success 'force removal of nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -f -d &&
! test -d foo &&
! test -d bar &&
! test -d baz
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
---
[Outreachy][PATCH] t7300-clean.sh: use test_path_* helper functions for
error logging
This test script uses "test - [def]", but when a test fails because the
file passed to it does not exist, it fails silently without an error
message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
I have added a mechanical validation that applies the same
transformation done in this patch, when the script is passed to a sed
script as shown below
#!/bin/bash
sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
-e 's/^\( *\)test -d /\1test_path_is_dir /' \
-e 's/^\( *\)test -e /\1test_path_exists /' \
-e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
-e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
"$1" >foo.sh
Reviewers can use the sed script to transform the original test script
and compare the results in foo.sh with the results of applying this
patch You will see an instance of "! (test -e 3)" which was manually
replaced with "test_path_is_missing", and everything else should match.
I have carefully studied the instances where "test ! - [df] foo" were
used in the script to make sure that the test instances were expecting a
file or a directory to not exist as the case may be before replacing
with "test_path_is_missing".
Signed-off-by: Abraham Samuel Adekunle abrahamadekunle50@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1811%2Fdevdekunle%2Fupdate_tests-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1811/devdekunle/update_tests-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1811
Range-diff vs v2:
1: 62d57156dcf ! 1: ca008b23a25 t7300-clean.sh: use test_path_* helper functions for error logging
@@ Commit message
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
+ I have added a mechanical validation that applies the same transformation
+ done in this patch, when the test script is passed to a sed script as shown
+ below.
+
+ sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
+ -e 's/^\( *\)test -d /\1test_path_is_dir /' \
+ -e 's/^\( *\)test -e /\1test_path_exists /' \
+ -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
+ -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
+ "$1" >foo.sh
+
+ Reviewers can use the sed script to tranform the original test script and
+ compare the result in foo.sh with the results of applying the patch.
+ You will see an instance of "!(test -e 3)" which was manually replaced with
+ ""test_path_is_missing 3", and everything else should match.
+
+ Careful and deliberate observation was done to check instances where
+ "test ! - [df] foo" was used in the test script to make sure that the test
+ instances were expecting foo to EITHER be a file or a directory, and NOT a
+ possibility of being both as this would make replacing "test ! -f foo" with
+ "test_path_is_missing foo" unreasonable.
+ In the tests control flow, foo has been created as EITHER a
+ reguar file OR a directory and should NOT exist
+ after "git clean" or "git clean -d", as the case maybe, has been called.
+ This made it reasonable to replace
+ "test ! -[df] foo" with "test_path_is_missing foo".
+ Examples for each case is shown below
+
+ test_expect_success 'git clean with prefix' '
+ mkdir -p build docs src/test &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
+ (cd src/ && git clean) &&
+ test -f Makefile &&
+ test -f README &&
+ test -f src/part1.c &&
+ test -f src/part2.c &&
+ test -f a.out &&
+ test ! -f src/part3.c &&
+
+ test_expect_success 'git clean -d -x with ignored tracked directory' '
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ git clean -d -X -e src &&
+ test -f Makefile &&
+ test -f README &&
+ test -f src/part1.c &&
+ test -f src/part2.c &&
+ test -f a.out &&
+ test ! -f src/part3.c &&
+ test -f docs/manual.txt &&
+ test ! -f obj.o &&
+
+ and
+
+ test_expect_success 'git clean -d -x with ignored tracked directory' '
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ git clean -d -x -e src &&
+ test -f Makefile &&
+ test -f README &&
+ test -f src/part1.c &&
+ test -f src/part2.c &&
+ test ! -f a.out &&
+ test -f src/part3.c &&
+ test ! -d docs &&
+ test ! -f obj.o &&
+ test ! -d build
+
+ and
+
+ test_expect_success 'should clean things that almost look like git ...'
+ test_expect_success 'force removal of nested git work tree' '
+ test_commit deeply.nested deeper.world
+ ) &&
+ git clean -f -f -d &&
+ ! test -d foo &&
+ ! test -d bar &&
+ ! test -d baz
+
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
## t/t7300-clean.sh ##
t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
1 file changed, 185 insertions(+), 185 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 0aae0dee670..5c97eb0dfe9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so &&
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so &&
git update-index --no-skip-worktree .gitignore &&
git checkout .gitignore
'
@@ -47,15 +47,15 @@ test_expect_success 'git clean' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
mkdir -p build docs src/test &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
(cd src/ && git clean) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f src/test/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file src/test/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
mkdir -p build docs src/feature &&
touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
(cd src/ && git clean -d feature/) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test ! -f src/feature/file.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing src/feature/file.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
ln -s docs/manual.txt src/part4.c &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -f src/part4.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing src/part4.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
touch a.clean b.clean other.c &&
git clean "*.clean" &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.clean &&
- test ! -f b.clean &&
- test -f other.c
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.clean &&
+ test_path_is_missing b.clean &&
+ test_path_is_file other.c
'
@@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
mkdir -p build docs examples &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
git clean -d src/ examples/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test ! -f examples/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing examples/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
test_expect_success 'clean.requireForce and -f' '
git clean -f &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -d &&
- test -f foo/.git/index &&
- test -f foo/hello.world &&
- test -f baz/boo/.git/index &&
- test -f baz/boo/deeper.world &&
- ! test -d bar
+ test_path_is_file foo/.git/index &&
+ test_path_is_file foo/hello.world &&
+ test_path_is_file baz/boo/.git/index &&
+ test_path_is_file baz/boo/deeper.world &&
+ test_path_is_missing bar
'
test_expect_success 'should clean things that almost look like git but are not' '
@@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -f -d &&
- ! test -d foo &&
- ! test -d bar &&
- ! test -d baz
+ test_path_is_missing foo &&
+ test_path_is_missing bar &&
+ test_path_is_missing baz
'
test_expect_success 'git clean -e' '
@@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
touch known 1 2 3 &&
git add known &&
git clean -f -e 1 -e 2 &&
- test -e 1 &&
- test -e 2 &&
- ! (test -e 3) &&
- test -e known
+ test_path_exists 1 &&
+ test_path_exists 2 &&
+ test_path_is_missing 3 &&
+ test_path_exists known
)
'
@@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
mkdir foo &&
chmod a= foo &&
git clean -dfx foo &&
- ! test -d foo
+ test_path_is_missing foo
'
test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] t7300-clean.sh: use test_path_* helper functions
2024-10-09 7:20 ` Patrick Steinhardt
2024-10-09 15:41 ` Samuel Abraham
@ 2024-10-09 17:31 ` Junio C Hamano
1 sibling, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2024-10-09 17:31 UTC (permalink / raw)
To: Patrick Steinhardt
Cc: Samuel Abraham, Samuel Adekunle Abraham via GitGitGadget, git,
phillip.wood, christian.couder
Patrick Steinhardt <ps@pks.im> writes:
> I think that your v2 isn't quite there yet. As Junio mentions, he'd like
> to see an updated commit message that includes your explanations why you
> have done certain conversions the way you did. The fact that some parts
> of the patch required discussion to arrive at a common understanding is
> a good telling factor that a summarized form of the discussion should
> likely be part of the commit message such that future readers of the
> patch will get the same context.
What v2 had after the three-dash line seemed to me an OK material
for a proposed commit log message, but it should have been before
the line. I suspect that it was from typical GGG gotcha?
Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3] t7300-clean.sh: use test_path_* helper functions for error logging
2024-10-09 17:02 ` [PATCH v3] " Samuel Adekunle Abraham via GitGitGadget
@ 2024-10-09 17:47 ` Junio C Hamano
2024-10-09 18:24 ` Samuel Abraham
2024-10-09 18:22 ` [PATCH v4] " Samuel Adekunle Abraham via GitGitGadget
1 sibling, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2024-10-09 17:47 UTC (permalink / raw)
To: Samuel Adekunle Abraham via GitGitGadget
Cc: git, Usman Akinyemi, Patrick Steinhardt, Samuel Adekunle Abraham
"Samuel Adekunle Abraham via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
>
> This test script uses "test - [def]", but when a test fails because
> the file passed to it does not exist,
> it fails silently without an error message.
> Use test_path_* helper functions, which are designed to give better
> error messages when their expectations are not met.
>
> I have added a mechanical validation that applies the same transformation
> done in this patch, when the test script is passed to a sed script as shown
> below.
>
> sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
> -e 's/^\( *\)test -d /\1test_path_is_dir /' \
> -e 's/^\( *\)test -e /\1test_path_exists /' \
> -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
> -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
> "$1" >foo.sh
>
> Reviewers can use the sed script to tranform the original test script and
> compare the result in foo.sh with the results of applying the patch.
> You will see an instance of "!(test -e 3)" which was manually replaced with
> ""test_path_is_missing 3", and everything else should match.
>
> Careful and deliberate observation was done to check instances where
> "test ! - [df] foo" was used in the test script to make sure that the test
> instances were expecting foo to EITHER be a file or a directory, and NOT a
> possibility of being both as this would make replacing "test ! -f foo" with
> "test_path_is_missing foo" unreasonable.
> In the tests control flow, foo has been created as EITHER a
> reguar file OR a directory and should NOT exist
> after "git clean" or "git clean -d", as the case maybe, has been called.
> This made it reasonable to replace
> "test ! -[df] foo" with "test_path_is_missing foo".
This is a good place to stop (but perhaps have a paragraph break
before "In the tests control"). The "examples" you have below is
like telling readers to go read the patch and verify the correctness
of it themselves, which is not adding much value.
Other than that, looking very good.
Thanks.
> t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
> 1 file changed, 185 insertions(+), 185 deletions(-)
>
> diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> index 0aae0dee670..5c97eb0dfe9 100755
> --- a/t/t7300-clean.sh
> +++ b/t/t7300-clean.sh
> @@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so &&
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so &&
> git update-index --no-skip-worktree .gitignore &&
> git checkout .gitignore
> '
> @@ -47,15 +47,15 @@ test_expect_success 'git clean' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean src/ &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean src/ src/ &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
> mkdir -p build docs src/test &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
> (cd src/ && git clean) &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f src/test/1.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file src/test/1.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
> mkdir -p build docs src/feature &&
> touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
> (cd src/ && git clean -d feature/) &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test ! -f src/feature/file.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_missing src/feature/file.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> ln -s docs/manual.txt src/part4.c &&
> git clean &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -f src/part4.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing src/part4.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
>
> touch a.clean b.clean other.c &&
> git clean "*.clean" &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.clean &&
> - test ! -f b.clean &&
> - test -f other.c
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.clean &&
> + test_path_is_missing b.clean &&
> + test_path_is_file other.c
>
> '
>
> @@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -n &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -d docs &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing docs &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
> mkdir -p build docs examples &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
> git clean -d src/ examples/ &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -f examples/1.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing examples/1.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -x &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -x &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test ! -d docs &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_missing docs &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -x -e src &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test -f src/part3.c &&
> - test ! -d docs &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_missing docs &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -X &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -X &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -d -X -e src &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test ! -f obj.o &&
> - test ! -d build
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_missing obj.o &&
> + test_path_is_missing build
>
> '
>
> @@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
> mkdir -p build docs &&
> touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> git clean -n &&
> - test -f Makefile &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test -f a.out &&
> - test -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file Makefile &&
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_file a.out &&
> + test_path_is_file src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> test_expect_success 'clean.requireForce and -f' '
>
> git clean -f &&
> - test -f README &&
> - test -f src/part1.c &&
> - test -f src/part2.c &&
> - test ! -f a.out &&
> - test ! -f src/part3.c &&
> - test -f docs/manual.txt &&
> - test -f obj.o &&
> - test -f build/lib.so
> + test_path_is_file README &&
> + test_path_is_file src/part1.c &&
> + test_path_is_file src/part2.c &&
> + test_path_is_missing a.out &&
> + test_path_is_missing src/part3.c &&
> + test_path_is_file docs/manual.txt &&
> + test_path_is_file obj.o &&
> + test_path_is_file build/lib.so
>
> '
>
> @@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
> test_commit deeply.nested deeper.world
> ) &&
> git clean -f -d &&
> - test -f foo/.git/index &&
> - test -f foo/hello.world &&
> - test -f baz/boo/.git/index &&
> - test -f baz/boo/deeper.world &&
> - ! test -d bar
> + test_path_is_file foo/.git/index &&
> + test_path_is_file foo/hello.world &&
> + test_path_is_file baz/boo/.git/index &&
> + test_path_is_file baz/boo/deeper.world &&
> + test_path_is_missing bar
> '
>
> test_expect_success 'should clean things that almost look like git but are not' '
> @@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
> test_commit deeply.nested deeper.world
> ) &&
> git clean -f -f -d &&
> - ! test -d foo &&
> - ! test -d bar &&
> - ! test -d baz
> + test_path_is_missing foo &&
> + test_path_is_missing bar &&
> + test_path_is_missing baz
> '
>
> test_expect_success 'git clean -e' '
> @@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
> touch known 1 2 3 &&
> git add known &&
> git clean -f -e 1 -e 2 &&
> - test -e 1 &&
> - test -e 2 &&
> - ! (test -e 3) &&
> - test -e known
> + test_path_exists 1 &&
> + test_path_exists 2 &&
> + test_path_is_missing 3 &&
> + test_path_exists known
> )
> '
>
> @@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
> mkdir foo &&
> chmod a= foo &&
> git clean -dfx foo &&
> - ! test -d foo
> + test_path_is_missing foo
> '
>
> test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
>
> base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4] t7300-clean.sh: use test_path_* helper functions for error logging
2024-10-09 17:02 ` [PATCH v3] " Samuel Adekunle Abraham via GitGitGadget
2024-10-09 17:47 ` Junio C Hamano
@ 2024-10-09 18:22 ` Samuel Adekunle Abraham via GitGitGadget
1 sibling, 0 replies; 15+ messages in thread
From: Samuel Adekunle Abraham via GitGitGadget @ 2024-10-09 18:22 UTC (permalink / raw)
To: git
Cc: Usman Akinyemi, Patrick Steinhardt, Junio C Hamano, Phillip Wood,
Samuel Adekunle Abraham, Abraham Samuel Adekunle
From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
This test script uses "test - [def]", but when a test fails because
the file passed to it does not exist,
it fails silently without an error message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
I have added a mechanical validation that applies the same transformation
done in this patch, when the test script is passed to a sed script as shown
below.
sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
-e 's/^\( *\)test -d /\1test_path_is_dir /' \
-e 's/^\( *\)test -e /\1test_path_exists /' \
-e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
-e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
"$1" >foo.sh
Reviewers can use the sed script to tranform the original test script and
compare the result in foo.sh with the results of applying the patch.
You will see an instance of "!(test -e 3)" which was manually replaced with
""test_path_is_missing 3", and everything else should match.
Careful and deliberate observation was done to check instances where
"test ! - [df] foo" was used in the test script to make sure that the test
instances were expecting foo to EITHER be a file or a directory, and NOT a
possibility of being both as this would make replacing "test ! -f foo" with
"test_path_is_missing foo" unreasonable.
In the tests control flow, foo has been created as EITHER a
reguar file OR a directory and should NOT exist
after "git clean" or "git clean -d", as the case maybe, has been called.
This made it reasonable to replace
"test ! -[df] foo" with "test_path_is_missing foo".
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
---
[Outreachy][PATCH] t7300-clean.sh: use test_path_* helper functions for
error logging
This test script uses "test - [def]", but when a test fails because the
file passed to it does not exist, it fails silently without an error
message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.
I have added a mechanical validation that applies the same
transformation done in this patch, when the script is passed to a sed
script as shown below
#!/bin/bash
sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
-e 's/^\( *\)test -d /\1test_path_is_dir /' \
-e 's/^\( *\)test -e /\1test_path_exists /' \
-e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
-e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
"$1" >foo.sh
Reviewers can use the sed script to transform the original test script
and compare the results in foo.sh with the results of applying this
patch You will see an instance of "! (test -e 3)" which was manually
replaced with "test_path_is_missing", and everything else should match.
I have carefully studied the instances where "test ! - [df] foo" were
used in the script to make sure that the test instances were expecting a
file or a directory to not exist as the case may be before replacing
with "test_path_is_missing".
Signed-off-by: Abraham Samuel Adekunle abrahamadekunle50@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1811%2Fdevdekunle%2Fupdate_tests-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1811/devdekunle/update_tests-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/1811
Range-diff vs v3:
1: ca008b23a25 ! 1: ad61cbe75ac t7300-clean.sh: use test_path_* helper functions for error logging
@@ Commit message
instances were expecting foo to EITHER be a file or a directory, and NOT a
possibility of being both as this would make replacing "test ! -f foo" with
"test_path_is_missing foo" unreasonable.
+
In the tests control flow, foo has been created as EITHER a
reguar file OR a directory and should NOT exist
after "git clean" or "git clean -d", as the case maybe, has been called.
This made it reasonable to replace
"test ! -[df] foo" with "test_path_is_missing foo".
- Examples for each case is shown below
-
- test_expect_success 'git clean with prefix' '
- mkdir -p build docs src/test &&
- touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
- (cd src/ && git clean) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
-
- test_expect_success 'git clean -d -x with ignored tracked directory' '
- mkdir -p build docs &&
- touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
- git clean -d -X -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
-
- and
-
- test_expect_success 'git clean -d -x with ignored tracked directory' '
- mkdir -p build docs &&
- touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
- git clean -d -x -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
-
- and
-
- test_expect_success 'should clean things that almost look like git ...'
- test_expect_success 'force removal of nested git work tree' '
- test_commit deeply.nested deeper.world
- ) &&
- git clean -f -f -d &&
- ! test -d foo &&
- ! test -d bar &&
- ! test -d baz
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
1 file changed, 185 insertions(+), 185 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 0aae0dee670..5c97eb0dfe9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so &&
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so &&
git update-index --no-skip-worktree .gitignore &&
git checkout .gitignore
'
@@ -47,15 +47,15 @@ test_expect_success 'git clean' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean src/ src/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
mkdir -p build docs src/test &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
(cd src/ && git clean) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f src/test/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file src/test/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
mkdir -p build docs src/feature &&
touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
(cd src/ && git clean -d feature/) &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test ! -f src/feature/file.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing src/feature/file.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
ln -s docs/manual.txt src/part4.c &&
git clean &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -f src/part4.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing src/part4.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
touch a.clean b.clean other.c &&
git clean "*.clean" &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.clean &&
- test ! -f b.clean &&
- test -f other.c
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.clean &&
+ test_path_is_missing b.clean &&
+ test_path_is_file other.c
'
@@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
mkdir -p build docs examples &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
git clean -d src/ examples/ &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test ! -f examples/1.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing examples/1.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -x -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test -f src/part3.c &&
- test ! -d docs &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_missing docs &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_file build/lib.so
'
@@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -d -X -e src &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test ! -f obj.o &&
- test ! -d build
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_missing obj.o &&
+ test_path_is_missing build
'
@@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
git clean -n &&
- test -f Makefile &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test -f a.out &&
- test -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file Makefile &&
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_file a.out &&
+ test_path_is_file src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
test_expect_success 'clean.requireForce and -f' '
git clean -f &&
- test -f README &&
- test -f src/part1.c &&
- test -f src/part2.c &&
- test ! -f a.out &&
- test ! -f src/part3.c &&
- test -f docs/manual.txt &&
- test -f obj.o &&
- test -f build/lib.so
+ test_path_is_file README &&
+ test_path_is_file src/part1.c &&
+ test_path_is_file src/part2.c &&
+ test_path_is_missing a.out &&
+ test_path_is_missing src/part3.c &&
+ test_path_is_file docs/manual.txt &&
+ test_path_is_file obj.o &&
+ test_path_is_file build/lib.so
'
@@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -d &&
- test -f foo/.git/index &&
- test -f foo/hello.world &&
- test -f baz/boo/.git/index &&
- test -f baz/boo/deeper.world &&
- ! test -d bar
+ test_path_is_file foo/.git/index &&
+ test_path_is_file foo/hello.world &&
+ test_path_is_file baz/boo/.git/index &&
+ test_path_is_file baz/boo/deeper.world &&
+ test_path_is_missing bar
'
test_expect_success 'should clean things that almost look like git but are not' '
@@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
test_commit deeply.nested deeper.world
) &&
git clean -f -f -d &&
- ! test -d foo &&
- ! test -d bar &&
- ! test -d baz
+ test_path_is_missing foo &&
+ test_path_is_missing bar &&
+ test_path_is_missing baz
'
test_expect_success 'git clean -e' '
@@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
touch known 1 2 3 &&
git add known &&
git clean -f -e 1 -e 2 &&
- test -e 1 &&
- test -e 2 &&
- ! (test -e 3) &&
- test -e known
+ test_path_exists 1 &&
+ test_path_exists 2 &&
+ test_path_is_missing 3 &&
+ test_path_exists known
)
'
@@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
mkdir foo &&
chmod a= foo &&
git clean -dfx foo &&
- ! test -d foo
+ test_path_is_missing foo
'
test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v3] t7300-clean.sh: use test_path_* helper functions for error logging
2024-10-09 17:47 ` Junio C Hamano
@ 2024-10-09 18:24 ` Samuel Abraham
0 siblings, 0 replies; 15+ messages in thread
From: Samuel Abraham @ 2024-10-09 18:24 UTC (permalink / raw)
To: Junio C Hamano
Cc: Samuel Adekunle Abraham via GitGitGadget, git, Usman Akinyemi,
Patrick Steinhardt
On Wed, Oct 9, 2024 at 6:47 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Samuel Adekunle Abraham via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
> >
> > This test script uses "test - [def]", but when a test fails because
> > the file passed to it does not exist,
> > it fails silently without an error message.
> > Use test_path_* helper functions, which are designed to give better
> > error messages when their expectations are not met.
> >
> > I have added a mechanical validation that applies the same transformation
> > done in this patch, when the test script is passed to a sed script as shown
> > below.
> >
> > sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
> > -e 's/^\( *\)test -d /\1test_path_is_dir /' \
> > -e 's/^\( *\)test -e /\1test_path_exists /' \
> > -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
> > -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
> > "$1" >foo.sh
> >
> > Reviewers can use the sed script to tranform the original test script and
> > compare the result in foo.sh with the results of applying the patch.
> > You will see an instance of "!(test -e 3)" which was manually replaced with
> > ""test_path_is_missing 3", and everything else should match.
> >
> > Careful and deliberate observation was done to check instances where
> > "test ! - [df] foo" was used in the test script to make sure that the test
> > instances were expecting foo to EITHER be a file or a directory, and NOT a
> > possibility of being both as this would make replacing "test ! -f foo" with
> > "test_path_is_missing foo" unreasonable.
> > In the tests control flow, foo has been created as EITHER a
> > reguar file OR a directory and should NOT exist
> > after "git clean" or "git clean -d", as the case maybe, has been called.
> > This made it reasonable to replace
> > "test ! -[df] foo" with "test_path_is_missing foo".
>
> This is a good place to stop (but perhaps have a paragraph break
> before "In the tests control"). The "examples" you have below is
> like telling readers to go read the patch and verify the correctness
> of it themselves, which is not adding much value.
>
> Other than that, looking very good.
>
> Thanks.
Thank you very much, I have submitted an updated patch.
>
> > t/t7300-clean.sh | 370 +++++++++++++++++++++++------------------------
> > 1 file changed, 185 insertions(+), 185 deletions(-)
> >
> > diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> > index 0aae0dee670..5c97eb0dfe9 100755
> > --- a/t/t7300-clean.sh
> > +++ b/t/t7300-clean.sh
> > @@ -29,15 +29,15 @@ test_expect_success 'git clean with skip-worktree .gitignore' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so &&
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so &&
> > git update-index --no-skip-worktree .gitignore &&
> > git checkout .gitignore
> > '
> > @@ -47,15 +47,15 @@ test_expect_success 'git clean' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -64,15 +64,15 @@ test_expect_success 'git clean src/' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean src/ &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -81,15 +81,15 @@ test_expect_success 'git clean src/ src/' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean src/ src/ &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -98,16 +98,16 @@ test_expect_success 'git clean with prefix' '
> > mkdir -p build docs src/test &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
> > (cd src/ && git clean) &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f src/test/1.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file src/test/1.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -163,16 +163,16 @@ test_expect_success 'git clean -d with prefix and path' '
> > mkdir -p build docs src/feature &&
> > touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
> > (cd src/ && git clean -d feature/) &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test -f src/part3.c &&
> > - test ! -f src/feature/file.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_file src/part3.c &&
> > + test_path_is_missing src/feature/file.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -182,16 +182,16 @@ test_expect_success SYMLINKS 'git clean symbolic link' '
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > ln -s docs/manual.txt src/part4.c &&
> > git clean &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test ! -f src/part4.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_missing src/part4.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -199,13 +199,13 @@ test_expect_success 'git clean with wildcard' '
> >
> > touch a.clean b.clean other.c &&
> > git clean "*.clean" &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.clean &&
> > - test ! -f b.clean &&
> > - test -f other.c
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.clean &&
> > + test_path_is_missing b.clean &&
> > + test_path_is_file other.c
> >
> > '
> >
> > @@ -214,15 +214,15 @@ test_expect_success 'git clean -n' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -n &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_file src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -231,15 +231,15 @@ test_expect_success 'git clean -d' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -d &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test ! -d docs &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_missing docs &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -248,16 +248,16 @@ test_expect_success 'git clean -d src/ examples/' '
> > mkdir -p build docs examples &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
> > git clean -d src/ examples/ &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test ! -f src/part3.c &&
> > - test ! -f examples/1.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_missing examples/1.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -266,15 +266,15 @@ test_expect_success 'git clean -x' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -x &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test ! -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_missing obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -283,15 +283,15 @@ test_expect_success 'git clean -d -x' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -d -x &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test ! -d docs &&
> > - test ! -f obj.o &&
> > - test ! -d build
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_missing docs &&
> > + test_path_is_missing obj.o &&
> > + test_path_is_missing build
> >
> > '
> >
> > @@ -300,15 +300,15 @@ test_expect_success 'git clean -d -x with ignored tracked directory' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -d -x -e src &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test -f src/part3.c &&
> > - test ! -d docs &&
> > - test ! -f obj.o &&
> > - test ! -d build
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_file src/part3.c &&
> > + test_path_is_missing docs &&
> > + test_path_is_missing obj.o &&
> > + test_path_is_missing build
> >
> > '
> >
> > @@ -317,15 +317,15 @@ test_expect_success 'git clean -X' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -X &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test ! -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_file src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_missing obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -334,15 +334,15 @@ test_expect_success 'git clean -d -X' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -d -X &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test ! -f obj.o &&
> > - test ! -d build
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_file src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_missing obj.o &&
> > + test_path_is_missing build
> >
> > '
> >
> > @@ -351,15 +351,15 @@ test_expect_success 'git clean -d -X with ignored tracked directory' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -d -X -e src &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test ! -f obj.o &&
> > - test ! -d build
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_missing obj.o &&
> > + test_path_is_missing build
> >
> > '
> >
> > @@ -382,29 +382,29 @@ test_expect_success 'clean.requireForce and -n' '
> > mkdir -p build docs &&
> > touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > git clean -n &&
> > - test -f Makefile &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test -f a.out &&
> > - test -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file Makefile &&
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_file a.out &&
> > + test_path_is_file src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > test_expect_success 'clean.requireForce and -f' '
> >
> > git clean -f &&
> > - test -f README &&
> > - test -f src/part1.c &&
> > - test -f src/part2.c &&
> > - test ! -f a.out &&
> > - test ! -f src/part3.c &&
> > - test -f docs/manual.txt &&
> > - test -f obj.o &&
> > - test -f build/lib.so
> > + test_path_is_file README &&
> > + test_path_is_file src/part1.c &&
> > + test_path_is_file src/part2.c &&
> > + test_path_is_missing a.out &&
> > + test_path_is_missing src/part3.c &&
> > + test_path_is_file docs/manual.txt &&
> > + test_path_is_file obj.o &&
> > + test_path_is_file build/lib.so
> >
> > '
> >
> > @@ -453,11 +453,11 @@ test_expect_success 'nested git work tree' '
> > test_commit deeply.nested deeper.world
> > ) &&
> > git clean -f -d &&
> > - test -f foo/.git/index &&
> > - test -f foo/hello.world &&
> > - test -f baz/boo/.git/index &&
> > - test -f baz/boo/deeper.world &&
> > - ! test -d bar
> > + test_path_is_file foo/.git/index &&
> > + test_path_is_file foo/hello.world &&
> > + test_path_is_file baz/boo/.git/index &&
> > + test_path_is_file baz/boo/deeper.world &&
> > + test_path_is_missing bar
> > '
> >
> > test_expect_success 'should clean things that almost look like git but are not' '
> > @@ -624,9 +624,9 @@ test_expect_success 'force removal of nested git work tree' '
> > test_commit deeply.nested deeper.world
> > ) &&
> > git clean -f -f -d &&
> > - ! test -d foo &&
> > - ! test -d bar &&
> > - ! test -d baz
> > + test_path_is_missing foo &&
> > + test_path_is_missing bar &&
> > + test_path_is_missing baz
> > '
> >
> > test_expect_success 'git clean -e' '
> > @@ -638,10 +638,10 @@ test_expect_success 'git clean -e' '
> > touch known 1 2 3 &&
> > git add known &&
> > git clean -f -e 1 -e 2 &&
> > - test -e 1 &&
> > - test -e 2 &&
> > - ! (test -e 3) &&
> > - test -e known
> > + test_path_exists 1 &&
> > + test_path_exists 2 &&
> > + test_path_is_missing 3 &&
> > + test_path_exists known
> > )
> > '
> >
> > @@ -649,7 +649,7 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
> > mkdir foo &&
> > chmod a= foo &&
> > git clean -dfx foo &&
> > - ! test -d foo
> > + test_path_is_missing foo
> > '
> >
> > test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
> >
> > base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-10-09 18:24 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-07 19:19 [PATCH] t7300-clean.sh: use test_path_* helper functions Samuel Adekunle Abraham via GitGitGadget
2024-10-07 23:01 ` Usman Akinyemi
2024-10-08 1:48 ` Junio C Hamano
2024-10-08 5:12 ` Samuel Abraham
2024-10-08 8:58 ` Samuel Abraham
2024-10-08 18:13 ` Junio C Hamano
2024-10-09 3:35 ` Samuel Abraham
2024-10-09 7:20 ` Patrick Steinhardt
2024-10-09 15:41 ` Samuel Abraham
2024-10-09 17:31 ` Junio C Hamano
2024-10-08 12:22 ` [PATCH v2] t7300-clean.sh: use test_path_* helper functions for error logging Samuel Adekunle Abraham via GitGitGadget
2024-10-09 17:02 ` [PATCH v3] " Samuel Adekunle Abraham via GitGitGadget
2024-10-09 17:47 ` Junio C Hamano
2024-10-09 18:24 ` Samuel Abraham
2024-10-09 18:22 ` [PATCH v4] " Samuel Adekunle Abraham via GitGitGadget
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).