Skip to contentSkip to conversation

t1420: use test helpers for lost-found checks

PATCH In review Pushkar Singh 1 participant 2 messages Jan 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t1420: use test helpers for lost-found checks

The lost-found test used raw test -f and ls | wc -l checks. Replace them with test_path_is_file and test_line_count to provide clearer failure diagnostics and keep the test consistent with the rest of the test suite.

---
 t/t1420-lost-found.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
t/t1420-lost-found.sh +4 -3
index 2fb2f44f02..da1e48d35e 100755
@@ -28,9 +28,10 @@ test_expect_success 'lost and found something' '
 	test_tick &&
 	git reset --hard HEAD^ &&
 	git fsck --lost-found &&
-	test 2 = $(ls .git/lost-found/*/* | wc -l) &&
-	test -f .git/lost-found/commit/$(cat lost-commit) &&
-	test -f .git/lost-found/other/$(cat lost-other)
+	ls .git/lost-found/*/* >actual &&
+	test_line_count = 2 actual &&
+	test_path_is_file .git/lost-found/commit/$(cat lost-commit) &&
+	test_path_is_file .git/lost-found/other/$(cat lost-other)
 '
 
 test_done
Signature · 1 line
2.43.0
#1 lore raw

I noticed that this test is already being worked on and reviewed in another thread. I’ll drop this patch to avoid duplication.

Thanks,
Pushkar

Quoted 32 lines · Pushkar Singh

The lost-found test used raw test -f and ls | wc -l checks. Replace them with test_path_is_file and test_line_count to provide clearer failure diagnostics and keep the test consistent with the rest of the test suite.

---
 t/t1420-lost-found.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
t/t1420-lost-found.sh +4 -4
index 2fb2f44f02..da1e48d35e 100755
@@ -28,9 +28,10 @@ test_expect_success 'lost and found something' '
        test_tick &&
        git reset --hard HEAD^ &&
        git fsck --lost-found &&
-       test 2 = $(ls .git/lost-found/*/* | wc -l) &&
-       test -f .git/lost-found/commit/$(cat lost-commit) &&
-       test -f .git/lost-found/other/$(cat lost-other)
+       ls .git/lost-found/*/* >actual &&
+       test_line_count = 2 actual &&
+       test_path_is_file .git/lost-found/commit/$(cat lost-commit) &&
+       test_path_is_file .git/lost-found/other/$(cat lost-other)
 '
 
 test_done
--

2.43.0