mirror of
https://github.com/uutils/coreutils
synced 2024-11-10 07:04:16 +00:00
run-gnu-test.sh: modify script to be compatible with BSD OS
- Use /usr/bin/env bash instead of /bin/sh to use OSTYPE - Define variables for GNU version of make, nproc, readlink and use them on BSD. Signed-off-by: Laurent Cheylus <foxy@free.fr>
This commit is contained in:
parent
aef204461c
commit
13665da85e
1 changed files with 22 additions and 8 deletions
|
@ -1,13 +1,27 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
# `run-gnu-test.bash [TEST]`
|
# `run-gnu-test.bash [TEST]`
|
||||||
# run GNU test (or all tests if TEST is missing/null)
|
# run GNU test (or all tests if TEST is missing/null)
|
||||||
|
|
||||||
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS ; (utils) shellcheck
|
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE ; (utils) shellcheck gnproc greadlink
|
||||||
|
|
||||||
# ref: [How the GNU coreutils are tested](https://www.pixelbeat.org/docs/coreutils-testing.html) @@ <https://archive.is/p2ITW>
|
# 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`
|
# * note: to run a single test => `make check TESTS=PATH/TO/TEST/SCRIPT SUBDIRS=. VERBOSE=yes`
|
||||||
|
|
||||||
ME_dir="$(dirname -- "$(readlink -fm -- "$0")")"
|
# Use GNU version for make, nproc, readlink on *BSD
|
||||||
|
case "$OSTYPE" in
|
||||||
|
*bsd*)
|
||||||
|
MAKE="gmake"
|
||||||
|
NPROC="gnproc"
|
||||||
|
READLINK="greadlink"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
MAKE="make"
|
||||||
|
NPROC="nproc"
|
||||||
|
READLINK="readlink"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
ME_dir="$(dirname -- "$("${READLINK}" -fm -- "$0")")"
|
||||||
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
||||||
|
|
||||||
echo "ME_dir='${ME_dir}'"
|
echo "ME_dir='${ME_dir}'"
|
||||||
|
@ -18,7 +32,7 @@ set -e
|
||||||
### * config (from environment with fallback defaults); note: GNU and GNULIB are expected to be sibling repo directories
|
### * config (from environment with fallback defaults); note: GNU and GNULIB are expected to be sibling repo directories
|
||||||
|
|
||||||
path_UUTILS=${path_UUTILS:-${REPO_main_dir}}
|
path_UUTILS=${path_UUTILS:-${REPO_main_dir}}
|
||||||
path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
|
path_GNU="$("${READLINK}" -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
|
||||||
|
|
||||||
echo "path_UUTILS='${path_UUTILS}'"
|
echo "path_UUTILS='${path_UUTILS}'"
|
||||||
echo "path_GNU='${path_GNU}'"
|
echo "path_GNU='${path_GNU}'"
|
||||||
|
@ -47,7 +61,7 @@ if test "$1" != "run-root"; then
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# trim it
|
# trim it
|
||||||
SPECIFIC_TESTS=$(echo $SPECIFIC_TESTS | xargs)
|
SPECIFIC_TESTS=$(echo "$SPECIFIC_TESTS" | xargs)
|
||||||
echo "Running specific tests: $SPECIFIC_TESTS"
|
echo "Running specific tests: $SPECIFIC_TESTS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -60,16 +74,16 @@ fi
|
||||||
if test "$1" != "run-root"; then
|
if test "$1" != "run-root"; then
|
||||||
# run the regular tests
|
# run the regular tests
|
||||||
if test $# -ge 1; then
|
if test $# -ge 1; then
|
||||||
timeout -sKILL 4h make -j "$(nproc)" check TESTS="$SPECIFIC_TESTS" SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
|
timeout -sKILL 4h "${MAKE}" -j "$("${NPROC}")" check TESTS="$SPECIFIC_TESTS" SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
|
||||||
else
|
else
|
||||||
timeout -sKILL 4h make -j "$(nproc)" check SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
|
timeout -sKILL 4h "${MAKE}" -j "$("${NPROC}")" check SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# in case we would like to run tests requiring root
|
# in case we would like to run tests requiring root
|
||||||
if test -z "$1" -o "$1" == "run-root"; then
|
if test -z "$1" -o "$1" == "run-root"; then
|
||||||
if test -n "$CI"; then
|
if test -n "$CI"; then
|
||||||
echo "Running check-root to run only root tests"
|
echo "Running check-root to run only root tests"
|
||||||
sudo make -j "$(nproc)" check-root SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" TEST_SUITE_LOG="tests/test-suite-root.log" || :
|
sudo "${MAKE}" -j "$("${NPROC}")" check-root SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" TEST_SUITE_LOG="tests/test-suite-root.log" || :
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue