Skip to content

Commit bffe872

Browse files
committed
GNU test: use tarball instead of git clone
1 parent 7aa5409 commit bffe872

1 file changed

Lines changed: 13 additions & 42 deletions

File tree

‎tests/run-upstream-testsuite.sh‎

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
scriptpath=$(dirname "$(readlink -f "$0")")
3232
rev=$(git rev-parse HEAD)
33+
gnu_version="3.12"
34+
gnu_tarball_blake2b=5b4593b39da71578d7f975603abe9359be215b9ac76548a6ab0d6e3838bb103c7ffcddf7fa01abcd5c6289db9a2f16b43aa3d5e846a9aa4b8db866763c2660de
3335

3436
# Report an infrastructure error: the test suite could not be run at all
3537
die() {
@@ -53,50 +55,23 @@ tempdir=$(mktemp -d)
5355
trap 'rm -rf "$tempdir"' EXIT
5456
cd "$tempdir" || die "Cannot enter temporary directory $tempdir"
5557

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"
58+
# Check out the upstream test suite
59+
echo "Fetching upstream test suite"
60+
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"
61+
echo ${gnu_tarball_blake2b} gnu-diffutils.tar.xz \
62+
| b2sum --check || die "Failed to verify checksum of tarball of GNU diffutils"
63+
mkdir -p diffutils
64+
tar xJf gnu-diffutils.tar.xz --strip-components=1 -C diffutils || die "Failed to extract test suite"
65+
66+
cd diffutils || die "Test suite src is broken"
7467

7568
# Ensure that calling `diff` invokes the built `diffutils` binary instead of
7669
# 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"
70+
cd src || die "Missing the directory holding the diff and cmp symlinks"
7971
ln -s "$binary" diff
8072
ln -s "$binary" cmp
8173
cd ../tests || die "Cannot enter the upstream tests directory"
8274

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-
10075
if [[ -n "$TESTS" ]]
10176
then
10277
tests="$TESTS"
@@ -111,15 +86,13 @@ echo "Running $total tests"
11186
export LC_ALL=C
11287
export KEEP=yes
11388
timestamp=$(date -Iseconds)
114-
urlroot="$gitserver/cgit/diffutils.git/tree/tests/"
11589
passed=0
11690
failed=0
11791
skipped=0
11892
normal="$(tput sgr0)"
11993
for test in $tests
12094
do
12195
result="FAIL"
122-
url="$urlroot$test?id=$upstreamrev"
12396
# Run only the tests that invoke `diff` or `cmp`,
12497
# because other binaries aren't implemented yet
12598
if ! grep -E -s -q "(diff3|sdiff)" "$test"
@@ -130,7 +103,7 @@ do
130103
result="SKIP"
131104
else
132105
json+="{\"test\":\"$test\",\"result\":\"$result\","
133-
json+="\"url\":\"$url\","
106+
json+="\"gnu_version\":\"$gnu_version\","
134107
json+="\"stdout\":\"$(base64 -w0 < stdout.txt)\","
135108
json+="\"stderr\":\"$(base64 -w0 < stderr.txt)\","
136109
json+="\"files\":{"
@@ -156,7 +129,6 @@ do
156129
if [[ $result = "SKIP" ]]
157130
then
158131
(( skipped++ ))
159-
json+="{\"test\":\"$test\",\"url\":\"$url\",\"result\":\"$result\"},"
160132
color=3 # yellow
161133
fi
162134
printf " %-40s $(tput setaf $color)$result$(tput sgr0)\n" "$test"
@@ -171,7 +143,6 @@ echo ""
171143
json="\"tests\":[${json%,}]"
172144
metadata="\"timestamp\":\"$timestamp\","
173145
metadata+="\"revision\":\"$rev\","
174-
metadata+="\"upstream-revision\":\"$upstreamrev\","
175146
if [[ -n "$GITHUB_ACTIONS" ]]
176147
then
177148
metadata+="\"branch\":\"$GITHUB_REF\","

0 commit comments

Comments
 (0)