Files
tar/util/run-gnu-test.sh
T
Kevin Burke e077e08aa5 Fix GNU test suite reporting real pass/fail results
The GNU tar test suite's version.at (test 1) creates a .badversion
file when `tar --version` doesn't match the expected GNU tar output.
This causes AT_XFAIL_IF to mark every subsequent test as "expected
failure", hiding real results — all tests appear as XFAIL instead of
actual PASS or FAIL.

Fix this by:
- Generating the testsuite script first via `make -C tests testsuite`
- Patching it to redirect the .badversion write to /dev/null
- Removing any stale .badversion before running
- Touching src/tar after copy to prevent make from relinking it

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 10:05:46 -07:00

58 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# Use GNU version for make, nproc, readlink on *BSD
MAKE=$(command -v gmake || command -v make)
NPROC=$(command -v gnproc || command -v nproc)
READLINK=$(command -v greadlink || command -v readlink)
ME="${0}"
ME_dir="$(dirname -- "$("${READLINK:-readlink}" -fm -- "${ME}")")"
REPO_main_dir="$(dirname -- "${ME_dir}")"
path_UUTILS=${path_UUTILS:-${REPO_main_dir}}
path_GNU="${path_GNU:-${path_UUTILS}/../gnu}"
# Determine profile
if [[ -d "${path_UUTILS}/target/release" ]]; then
UU_BUILD_DIR="${path_UUTILS}/target/release"
elif [[ -d "${path_UUTILS}/target/debug" ]]; then
UU_BUILD_DIR="${path_UUTILS}/target/debug"
else
echo "Could not find build directory in ${path_UUTILS}/target"
exit 1
fi
echo "Using uutils tar from: ${UU_BUILD_DIR}"
cd "${path_GNU}"
export RUST_BACKTRACE=1
# The GNU tar testsuite usually looks for 'tar' in the path or uses the one in src/
# We force it to use ours by putting it first in PATH.
export PATH="${UU_BUILD_DIR}:$PATH"
export TAR="${UU_BUILD_DIR}/tar"
echo "Running GNU tar tests..."
# Run with timeout and make check
# We use $* to pass any additional user arguments (e.g. TESTSUITEFLAGS="1-5")
cp "${TAR}" src/tar
touch src/tar
# Generate the testsuite script (without running it)
"${MAKE}" -C tests testsuite
# Test 1 (version.at) checks `tar --version` against the expected GNU tar
# version string. When it doesn't match, it creates a .badversion file which
# causes AT_XFAIL_IF to mark *every* subsequent test as "expected failure",
# hiding real pass/fail results. Patch the generated testsuite script to
# prevent this.
sed 's|cat >$XFAILFILE|cat >/dev/null|' tests/testsuite > tests/testsuite.tmp
mv tests/testsuite.tmp tests/testsuite
chmod +x tests/testsuite
rm -f tests/.badversion
timeout -sKILL 4h "${MAKE}" -j "$("${NPROC}")" check "$@"