3030
3131scriptpath=$( dirname " $( readlink -f " $0 " ) " )
3232rev=$( git rev-parse HEAD)
33+ gnu_version=" 3.12"
3334
3435# Report an infrastructure error: the test suite could not be run at all
3536die () {
@@ -53,50 +54,23 @@ tempdir=$(mktemp -d)
5354trap ' rm -rf "$tempdir"' EXIT
5455cd " $tempdir " || die " Cannot enter temporary directory $tempdir "
5556
56- # Check out the upstream test suite. git.savannah.gnu.org is regularly
57- # unavailable or slow, so retry a few times before giving up.
58- gitserver=" https://git.savannah.gnu.org"
59- testsuite=" $gitserver /git/diffutils.git"
60- attempts=3
61- for (( attempt = 1 ; attempt <= attempts; attempt++ ))
62- do
63- echo " Fetching upstream test suite from $testsuite (attempt $attempt /$attempts )"
64- rm -rf diffutils
65- git clone -n --depth=1 --filter=tree:0 " $testsuite " && break
66- (( attempt < attempts )) && sleep $(( attempt * 10 ))
67- done
68- [[ -d diffutils ]] || die " Failed to fetch the upstream test suite from $testsuite "
69- cd diffutils || die " Failed to fetch the upstream test suite from $testsuite "
70- git sparse-checkout set --no-cone tests & > /dev/null || die " Cannot sparse-checkout the upstream tests"
71- git checkout & > /dev/null || die " Cannot check out the upstream tests"
72- upstreamrev=$( git rev-parse HEAD)
73- [[ -d tests ]] || die " The upstream checkout contains no tests directory"
57+ # Check out the upstream test suite
58+ echo " Fetching upstream test suite"
59+ curl -fsSL --retry 5 https://ftpmirror.gnu.org/diffutils/diffutils-${gnu-version} .tar.xz -o gnu-diffutils.tar.xz || die " Failed to fetch test suite"
60+ echo 5b4593b39da71578d7f975603abe9359be215b9ac76548a6ab0d6e3838bb103c7ffcddf7fa01abcd5c6289db9a2f16b43aa3d5e846a9aa4b8db866763c2660de gnu-diffutils.tar.xz \
61+ | b2sum --check || die " Failed to verify checksum of tarball of GNU diffutils"
62+ mkdir -p diffutils
63+ tar xJf gnu-diffutils.tar.xz --strip-components=1 -C diffutils || die " Failed to extract test suite"
64+
65+ cd diffutils || die " Test suite src is broken"
7466
7567# Ensure that calling `diff` invokes the built `diffutils` binary instead of
7668# the upstream `diff` binary that is most likely installed on the system
77- mkdir src
78- cd src || die " Cannot create the directory holding the diff and cmp symlinks"
69+ cd src || die " Missing the directory holding the diff and cmp symlinks"
7970ln -s " $binary " diff
8071ln -s " $binary " cmp
8172cd ../tests || die " Cannot enter the upstream tests directory"
8273
83- # Fetch tests/init.sh from the gnulib repository (needed since
84- # https://git.savannah.gnu.org/cgit/diffutils.git/commit/tests?id=1d2456f539)
85- # The savannah gitweb interface is often rate-limited or unavailable, so fall
86- # back to the official gnulib mirror on GitHub
87- initsh_urls=(
88- " $gitserver /gitweb/?p=gnulib.git;a=blob_plain;f=tests/init.sh;hb=HEAD"
89- " https://raw.githubusercontent.com/coreutils/gnulib/master/tests/init.sh"
90- )
91- for url in " ${initsh_urls[@]} "
92- do
93- echo " Fetching tests/init.sh from $url "
94- curl -sSL --fail --retry 3 --retry-delay 5 --retry-all-errors \
95- --connect-timeout 30 --max-time 300 " $url " -o init.sh && [[ -s init.sh ]] && break
96- rm -f init.sh
97- done
98- [[ -s init.sh ]] || die " Failed to fetch tests/init.sh from the gnulib repository"
99-
10074if [[ -n " $TESTS " ]]
10175then
10276 tests=" $TESTS "
@@ -111,15 +85,13 @@ echo "Running $total tests"
11185export LC_ALL=C
11286export KEEP=yes
11387timestamp=$( date -Iseconds)
114- urlroot=" $gitserver /cgit/diffutils.git/tree/tests/"
11588passed=0
11689failed=0
11790skipped=0
11891normal=" $( tput sgr0) "
11992for test in $tests
12093do
12194 result=" FAIL"
122- url=" $urlroot$test ?id=$upstreamrev "
12395 # Run only the tests that invoke `diff` or `cmp`,
12496 # because other binaries aren't implemented yet
12597 if ! grep -E -s -q " (diff3|sdiff)" " $test "
130102 result=" SKIP"
131103 else
132104 json+=" {\" test\" :\" $test \" ,\" result\" :\" $result \" ,"
133- json+=" \" url\" :\" $url \" ,"
134105 json+=" \" stdout\" :\" $( base64 -w0 < stdout.txt) \" ,"
135106 json+=" \" stderr\" :\" $( base64 -w0 < stderr.txt) \" ,"
136107 json+=" \" files\" :{"
156127 if [[ $result = " SKIP" ]]
157128 then
158129 (( skipped++ ))
159- json+=" {\" test\" :\" $test \" ,\" url\" :\" $url \" ,\" result\" :\" $result \" },"
160130 color=3 # yellow
161131 fi
162132 printf " %-40s $( tput setaf $color ) $result $( tput sgr0) \n" " $test "
@@ -171,7 +141,6 @@ echo ""
171141json=" \" tests\" :[${json% ,} ]"
172142metadata=" \" timestamp\" :\" $timestamp \" ,"
173143metadata+=" \" revision\" :\" $rev \" ,"
174- metadata+=" \" upstream-revision\" :\" $upstreamrev \" ,"
175144if [[ -n " $GITHUB_ACTIONS " ]]
176145then
177146 metadata+=" \" branch\" :\" $GITHUB_REF \" ,"
0 commit comments