From ea618c5e257a6aabded76e63567ec0e7b99ac6c4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Mon, 24 Aug 2026 16:21:18 -1000 Subject: Renumber the test scripts into themed ranges t000x the ground the suite stands on: git version, html validity, the cache t01xx page content, one script per page t02xx features that cut across pages: filters, submodule links, dates, limits t03xx defence, the security regressions and the $HOME promise t04xx the helper tools under tools/ --- tests/t0001-git-version.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 tests/t0001-git-version.sh (limited to 'tests/t0001-git-version.sh') diff --git a/tests/t0001-git-version.sh b/tests/t0001-git-version.sh new file mode 100755 index 0000000..2117764 --- /dev/null +++ b/tests/t0001-git-version.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +# Checks that the Git version cgit says it is built for is the one it is +# actually built against. The top-level Makefile names a version, the tree +# under vendor/git records its own, and the submodule is pinned to a tag, so +# all three have to agree or cgit is being built on something other than what +# it claims. Set CGIT_TEST_NO_GIT_VERSION to YesPlease when Git comes from +# elsewhere and the comparison has nothing to say. + +if [ "${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 + +test_expect_success 'extract Git version from Makefile' ' + sed -n -e "/^GIT_VERSION[ ]*=/ { + s/^GIT_VERSION[ ]*=[ ]*// + p + }" ../../Makefile >makefile_version +' + +# Git's GIT-VERSION-GEN script applies "s/-/./g" to the version string on its +# way into the GIT-VERSION-FILE, so the same has to be done to the version in +# the Makefile before the two can be compared. +test_expect_success 'test Git version matches Makefile' ' + ( cat ../../vendor/git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) | + sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version && + sed -e "s/-/./g" makefile_version >makefile_git_version && + 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 ../../vendor/git/.git + then + echo "vendor/git/ is not a Git repository" >&2 + else + ( + cd ../.. && + submodule_oid=$(git ls-files --stage -- vendor/git | + sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\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 +' + +test_done -- cgit v2.8.0