Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion util/run-gnu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# `run-gnu-test.bash [TEST]`
# run GNU test (or all tests if TEST is missing/null)

# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE MAKEFLAGS; (utils) shellcheck greadlink
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE MAKEFLAGS; (utils) shellcheck greadlink ginstall

# ref: [How the GNU coreutils are tested](https://www.pixelbeat.org/docs/coreutils-testing.html) @@ <https://archive.is/p2ITW>
# * note: to run a single test => `make check TESTS=PATH/TO/TEST/SCRIPT SUBDIRS=. VERBOSE=yes`
Expand Down Expand Up @@ -35,6 +35,39 @@ export MAKEFLAGS

cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"

# --- Self-heal: make the shared GNU harness point at THIS checkout ----------
# ${path_GNU} is shared between sibling uutils checkouts; whichever one last ran
# build-gnu.sh leaves its own target dir patched into the Makefile/local.mk
# PATH, so the harness can silently run a stale/other build. Re-point the PATH
# (and re-create the multicall hardlinks) here so that running this script is
# enough to test the current tree - no full rebuild just because another
# checkout stole the PATH.
: "${PROFILE:=debug}"
if [ -n "${CARGO_TARGET_DIR}" ]; then
UU_BUILD_DIR="${CARGO_TARGET_DIR}/${PROFILE}"
else
UU_BUILD_DIR="${path_UUTILS}/target/${PROFILE}"
fi
if [ ! -x "${UU_BUILD_DIR}/coreutils" ]; then
echo "error: no coreutils binary at '${UU_BUILD_DIR}'." >&2
echo " run 'bash util/build-gnu.sh' first (PROFILE=${PROFILE})." >&2
exit 1
fi
echo "Re-pointing GNU harness at '${UU_BUILD_DIR}'"
for binary in $("${UU_BUILD_DIR}/coreutils" --list); do
tgt="${UU_BUILD_DIR}/${binary}"
[ "${tgt}" -ef "${UU_BUILD_DIR}/coreutils" ] || ln -f "${UU_BUILD_DIR}/coreutils" "${tgt}"
done
# The GNU tests invoke `ginstall` rather than `install`.
[ -e "${UU_BUILD_DIR}/ginstall" ] || [ ! -e "${UU_BUILD_DIR}/install" ] || ln -f "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall"
uu_path_sed="s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/"
for f in Makefile tests/local.mk; do
if [ -f "${f}" ]; then sed -i "${uu_path_sed}" "${f}"; fi
done
# Keep Makefile newer than Makefile.in so make won't regenerate it and undo the patch.
if [ -f Makefile ]; then touch Makefile; fi
# ---------------------------------------------------------------------------

export RUST_BACKTRACE=1

# Determine if we have SELinux tests
Expand Down
Loading