diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Tidy the test comments and shell portability
Diffstat (limited to 'tests/t0001-validate-git-versions.sh')
| -rwxr-xr-x | tests/t0001-validate-git-versions.sh | 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 16 insertions, 8 deletions
diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh index 65c3c6a..2117764 100755 --- a/tests/t0001-validate-git-versions.sh +++ b/tests/t0001-validate-git-versions.sh @@ -1,5 +1,12 @@ #!/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 @@ -15,10 +22,9 @@ test_expect_success 'extract Git version from Makefile' ' }" ../../Makefile >makefile_version ' -# Note that Git's GIT-VERSION-GEN script applies "s/-/./g" to the version -# string to produce the internal version in the GIT-VERSION-FILE, so we -# must apply the same transformation to the version in the Makefile before -# comparing them. +# 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 && @@ -26,6 +32,8 @@ 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 ../../vendor/git/.git then @@ -33,12 +41,12 @@ test_expect_success 'test submodule version matches Makefile' ' else ( cd ../.. && - sm_oid=$(git ls-files --stage -- vendor/git | + 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]*" $sm_oid - ) | sed -e "s/^v//" -e "s/-/./" >sm_version && - test_cmp sm_version makefile_version + git describe --match "v[0-9]*" $submodule_oid + ) | sed -e "s/^v//" -e "s/-/./" >submodule_version && + test_cmp submodule_version makefile_version fi ' |
