From 43b4a4d3c720a4e65fe9de884cd73e0b1b94fbef Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 4 Mar 2019 17:10:04 +0100 Subject: tests: add --use-system-commands This change allows to use commands from $PATH rather than from $top_builddir. There two basic use cases: * check differences between installed and git version run.sh --use-system-command --show-diff * check system binaries by upstream tests (for example tests from src.rpm package) Signed-off-by: Karel Zak --- tests/functions.sh | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index 2fb0ddb5f..ab607c4ce 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -75,9 +75,19 @@ function ts_report { } function ts_check_test_command { - if [ ! -x "$1" ]; then - ts_skip "${1##*/} not found" - fi + case "$1" in + */*) + # paths + if [ ! -x "$1" ]; then + ts_skip "${1##*/} not found" + fi + ;; + *) + # just command names (e.g. --use-system-commands) + local cmd=$1 + type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd" + ;; + esac } function ts_check_prog { @@ -254,8 +264,20 @@ function ts_init_env { top_srcdir=$(ts_abspath $top_srcdir) top_builddir=$(ts_abspath $top_builddir) - # some ul commands search other ul commands in $PATH - export PATH="$top_builddir:$PATH" + # We use helpser always from build tree + ts_helpersdir="${top_builddir}/" + + TS_USE_SYSTEM_COMMANDS=$(ts_has_option "use-system-commands" "$*") + if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then + # Don't define anything, just follow current PATH + ts_commandsdir="" + else + # The default is to use commands from build tree + ts_commandsdir="${top_builddir}/" + + # some ul commands search other ul commands in $PATH + export PATH="$ts_commandsdir:$PATH" + fi TS_SCRIPT="$mydir/$(basename $0)" TS_SUBDIR=$(dirname $TS_SCRIPT) @@ -319,6 +341,8 @@ function ts_init_env { if [ "$TS_VERBOSE" == "yes" ]; then echo echo " script: $TS_SCRIPT" + echo " commands: $ts_commandsdir" + echo " helpers: $ts_helpersdir" echo " sub dir: $TS_SUBDIR" echo " top dir: $TS_TOPDIR" echo " self: $TS_SELF" -- cgit v1.2.3-55-g7522