[PATCH 2/2] t7412: modernize path checks to use test helper functions
- From
Yuvraj Singh Chauhan <ysinghcin@gmail.com>
- Date
- Mar 3, 2026, 17:57 UTC
- Message-ID
- <20260303175750.361563-2-ysinghcin@gmail.com>
- In-Reply-To
- <20260303175750.361563-1-ysinghcin@gmail.com>
Replace 11 raw 'test -f', 'test -d', and '! test -e' calls with the corresponding test library helpers:
- 'test -f' -> 'test_path_is_file' - 'test -d' -> 'test_path_is_dir' - '! test -e' -> 'test_path_is_missing'
These helpers emit a descriptive message on failure, making failing tests easier to diagnose than the silent pass/fail of the raw shell primitives.
Signed-off-by: Yuvraj Singh Chauhan <ysinghcin@gmail.com> --- t/t7412-submodule-absorbgitdirs.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/t/t7412-submodule-absorbgitdirs.sh b/t/t7412-submodule-absorbgitdirs.sh index 41ee035e3c..cdc7f59e12 100755 --- a/t/t7412-submodule-absorbgitdirs.sh +++ b/t/t7412-submodule-absorbgitdirs.sh @@ -34,8 +34,8 @@ test_expect_success 'absorb the git dir' ' git submodule absorbgitdirs 2>actual && test_cmp expect actual && git fsck && - test -f sub1/.git && - test -d .git/modules/sub1 && + test_path_is_file sub1/.git && + test_path_is_dir .git/modules/sub1 && git status >actual.1 && git -C sub1 rev-parse HEAD >actual.2 && test_cmp expect.1 actual.1 && @@ -47,9 +47,9 @@ test_expect_success 'absorbing does not fail for deinitialized submodules' ' git submodule deinit --all && git submodule absorbgitdirs 2>err && test_must_be_empty err && - test -d .git/modules/sub1 && - test -d sub1 && - ! test -e sub1/.git + test_path_is_dir .git/modules/sub1 && + test_path_is_dir sub1 && + test_path_is_missing sub1/.git ' test_expect_success 'setup nested submodule' ' @@ -72,8 +72,8 @@ test_expect_success 'absorb the git dir in a nested submodule' ' EOF git submodule absorbgitdirs 2>actual && test_cmp expect actual && - test -f sub1/nested/.git && - test -d .git/modules/sub1/modules/nested && + test_path_is_file sub1/nested/.git && + test_path_is_dir .git/modules/sub1/modules/nested && git status >actual.1 && git -C sub1/nested rev-parse HEAD >actual.2 && test_cmp expect.1 actual.1 && @@ -109,9 +109,9 @@ test_expect_success 'absorb the git dir in a nested submodule' ' EOF git submodule absorbgitdirs 2>actual && test_cmp expect actual && - test -f sub1/.git && - test -f sub1/nested/.git && - test -d .git/modules/sub1/modules/nested && + test_path_is_file sub1/.git && + test_path_is_file sub1/nested/.git && + test_path_is_dir .git/modules/sub1/modules/nested && git status >actual.1 && git -C sub1/nested rev-parse HEAD >actual.2 && test_cmp expect.1 actual.1 && @@ -155,7 +155,7 @@ test_expect_success 'absorbing the git dir fails for incomplete submodules' ' test_must_fail git submodule absorbgitdirs 2>actual && test_cmp expect actual && git -C sub2 fsck && - test -d sub2/.git && + test_path_is_dir sub2/.git && git status >actual && git -C sub2 rev-parse HEAD >actual.2 && test_cmp expect.1 actual.1 &&
-- 2.53.0.290.g4805bb9930