From 50edccde231070980449197980de96e7d5567a82 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 08:39:24 -1000 Subject: Show the Git version checks as skipped, not passed CGIT_TEST_NO_GIT_VERSION ended t0001 before the test library started, so it wrote no counts and printed nothing. Without vendor/git/.git the submodule check passed with a note on stderr, which is the case for a tree from get-git or git archive, so the pin was checked nowhere. --- tests/t0001-git-version.sh | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/t0001-git-version.sh b/tests/t0001-git-version.sh index 76b24db..552b2c6 100755 --- a/tests/t0001-git-version.sh +++ b/tests/t0001-git-version.sh @@ -5,20 +5,22 @@ # the same version. Set CGIT_TEST_NO_GIT_VERSION to YesPlease when Git comes # from elsewhere. -if test "$CGIT_TEST_NO_GIT_VERSION" = "YesPlease" -then - exit 0 -fi - test_description='Check Git version is correct' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh +if test "$CGIT_TEST_NO_GIT_VERSION" = "YesPlease" +then + skip_all='Skipping the Git version checks: CGIT_TEST_NO_GIT_VERSION is set' + test_done +fi + test_expect_success 'extract Git version from Makefile' ' sed -n -e "/^GIT_VERSION[[:space:]]*=/ { s/^GIT_VERSION[[:space:]]*=[[:space:]]*// p - }" "$TEST_OUTPUT_DIRECTORY/../Makefile" >makefile_version + }" "$TEST_OUTPUT_DIRECTORY/../Makefile" >makefile_version && + test -s makefile_version ' # Git's GIT-VERSION-GEN script applies "s/-/./g" to the version string on its @@ -32,22 +34,18 @@ test_expect_success 'test Git version matches Makefile' ' test_cmp git_version makefile_git_version ' -# A tree unpacked from a tarball has no submodule pin to describe, so there is -# nothing to compare against and the test says so rather than failing. -test_expect_success 'test submodule version matches Makefile' ' - if ! test -e "$TEST_OUTPUT_DIRECTORY/../vendor/git/.git" - then - echo "vendor/git/ is not a Git repository" >&2 - else - ( - cd "$TEST_OUTPUT_DIRECTORY/.." && - submodule_oid=$(git ls-files --stage -- vendor/git | - sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9][[:space:]].*$/\\1/") && - cd vendor/git && - git describe --match "v[0-9]*" $submodule_oid - ) | sed -e "s/^v//" -e "s/-/./" >submodule_version && - test_cmp submodule_version makefile_version - fi +# A tree unpacked from a tarball has no history to describe the submodule pin +# with, so the check is skipped there rather than passed. +test_lazy_prereq SUBMODULE 'test -e "$TEST_OUTPUT_DIRECTORY/../vendor/git/.git"' + +test_expect_success SUBMODULE 'test submodule version matches Makefile' ' + git -C "$TEST_OUTPUT_DIRECTORY/.." ls-files --stage -- vendor/git >gitlink && + submodule_oid=$(sed -n "s/^160000 \\([0-9a-f]*\\) .*/\\1/p" gitlink) && + test -n "$submodule_oid" && + git -C "$TEST_OUTPUT_DIRECTORY/../vendor/git" \ + describe --match "v[0-9]*" "$submodule_oid" >submodule_tag && + sed -e "s/^v//" -e "s/-/./" submodule_tag >submodule_version && + test_cmp makefile_version submodule_version ' test_done -- cgit 2.12.1