Refactor test -f to utilize the corresponding helper functions from test-lib-functions.sh. These functions perform identical operations while enhancing debugging capabilities in case of test failures. In the context of this file, 'test ! -f' is meant to check if the file has been correctly cleaned, thus its usage is replaced with 'test_path_is_missing' instead of '! test_path_is_file'. Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@xxxxxxxxx> --- t/t7301-clean-interactive.sh | 490 +++++++++++++++++------------------ 1 file changed, 245 insertions(+), 245 deletions(-) diff --git a/t/t7301-clean-interactive.sh b/t/t7301-clean-interactive.sh index d82a3210a1..4afe53c66a 100755 --- a/t/t7301-clean-interactive.sh +++ b/t/t7301-clean-interactive.sh @@ -25,18 +25,18 @@ test_expect_success 'git clean -i (c: clean hotkey)' ' touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo c | git clean -i && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test ! -f src/part3.h && - test ! -f src/part4.c && - test ! -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_missing src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -46,18 +46,18 @@ test_expect_success 'git clean -i (cl: clean prefix)' ' touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo cl | git clean -i && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test ! -f src/part3.h && - test ! -f src/part4.c && - test ! -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_missing src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -67,18 +67,18 @@ test_expect_success 'git clean -i (quit)' ' touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo quit | git clean -i && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test -f docs/manual.txt && - test -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -88,18 +88,18 @@ test_expect_success 'git clean -i (Ctrl+D)' ' touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo "\04" | git clean -i && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test -f docs/manual.txt && - test -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -110,18 +110,18 @@ test_expect_success 'git clean -id (filter all)' ' docs/manual.txt obj.o build/lib.so && test_write_lines f "*" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test -f docs/manual.txt && - test -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -132,18 +132,18 @@ test_expect_success 'git clean -id (filter patterns)' ' docs/manual.txt obj.o build/lib.so && test_write_lines f "part3.* *.out" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test ! -f docs/manual.txt && - test -f src/part3.c && - test -f src/part3.h && - test ! -f src/part4.c && - test ! -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_file src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_missing src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -154,18 +154,18 @@ test_expect_success 'git clean -id (filter patterns 2)' ' docs/manual.txt obj.o build/lib.so && test_write_lines f "* !*.out" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -176,18 +176,18 @@ test_expect_success 'git clean -id (select - all)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "*" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test ! -f docs/manual.txt && - test ! -f src/part3.c && - test ! -f src/part3.h && - test ! -f src/part4.c && - test ! -f src/part4.h && - 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 docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_missing src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -198,18 +198,18 @@ test_expect_success 'git clean -id (select - none)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test -f docs/manual.txt && - test -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -220,18 +220,18 @@ test_expect_success 'git clean -id (select - number)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s 3 "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -242,18 +242,18 @@ test_expect_success 'git clean -id (select - number 2)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "2 3" 5 "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test ! -f docs/manual.txt && - test ! -f src/part3.c && - test -f src/part3.h && - test ! -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_file src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -264,18 +264,18 @@ test_expect_success 'git clean -id (select - number 3)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "3,4 5" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test ! -f src/part3.h && - test ! -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -285,11 +285,11 @@ test_expect_success 'git clean -id (select - filenames)' ' touch a.out foo.txt bar.txt baz.txt && test_write_lines s "a.out fo ba bar" "" c | git clean -id && - test -f Makefile && - test ! -f a.out && - test ! -f foo.txt && - test ! -f bar.txt && - test -f baz.txt && + test_path_is_file Makefile && + test_path_is_missing a.out && + test_path_is_missing foo.txt && + test_path_is_missing bar.txt && + test_path_is_file baz.txt && rm baz.txt ' @@ -301,18 +301,18 @@ test_expect_success 'git clean -id (select - range)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "1,3-4" 2 "" c | git clean -id && - 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/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_missing docs/manual.txt && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -323,18 +323,18 @@ test_expect_success 'git clean -id (select - range 2)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "4- 1" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test -f src/part3.c && - test ! -f src/part3.h && - test ! -f src/part4.c && - test ! -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_missing src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -345,18 +345,18 @@ test_expect_success 'git clean -id (inverse select)' ' docs/manual.txt obj.o build/lib.so && test_write_lines s "*" "-5- 1 -2" "" c | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test ! -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -367,18 +367,18 @@ test_expect_success 'git clean -id (ask)' ' docs/manual.txt obj.o build/lib.so && test_write_lines a Y y no yes bad "" | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test ! -f docs/manual.txt && - test -f src/part3.c && - test ! -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -389,18 +389,18 @@ test_expect_success 'git clean -id (ask - Ctrl+D)' ' docs/manual.txt obj.o build/lib.so && test_write_lines a Y no yes "\04" | git clean -id && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_file src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -412,18 +412,18 @@ test_expect_success 'git clean -id with prefix and path (filter)' ' (cd build/ && test_write_lines f docs "*.h" "" c | git clean -id ..) && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test -f docs/manual.txt && - test ! -f src/part3.c && - test -f src/part3.h && - test ! -f src/part4.c && - test -f src/part4.h && - 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_file docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_file src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -435,18 +435,18 @@ test_expect_success 'git clean -id with prefix and path (select by name)' ' (cd build/ && test_write_lines s ../docs/ ../src/part3.c ../src/part4.c "" c | git clean -id ..) && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test -f a.out && - test ! -f docs/manual.txt && - test ! -f src/part3.c && - test -f src/part3.h && - test ! -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_missing src/part3.c && + test_path_is_file src/part3.h && + test_path_is_missing src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' @@ -458,18 +458,18 @@ test_expect_success 'git clean -id with prefix and path (ask)' ' (cd build/ && test_write_lines a Y y no yes bad "" | git clean -id ..) && - test -f Makefile && - test -f README && - test -f src/part1.c && - test -f src/part2.c && - test ! -f a.out && - test ! -f docs/manual.txt && - test -f src/part3.c && - test ! -f src/part3.h && - test -f src/part4.c && - test -f src/part4.h && - 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 docs/manual.txt && + test_path_is_file src/part3.c && + test_path_is_missing src/part3.h && + test_path_is_file src/part4.c && + test_path_is_file src/part4.h && + test_path_is_file obj.o && + test_path_is_file build/lib.so ' -- 2.34.1