dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
fe1ca8
From 9e92f2ff939a885b70d3a5d20e8c94f6e41e821b Mon Sep 17 00:00:00 2001
fe1ca8
From: Karel Zak <kzak@redhat.com>
fe1ca8
Date: Tue, 5 Mar 2019 11:06:41 +0100
fe1ca8
Subject: [PATCH 19/19] tests: add --noskip-commands
fe1ca8
fe1ca8
The default is SKIP missing commands on --use-system-commands, but
fe1ca8
with --noskip-commands the test will FAIL.
fe1ca8
fe1ca8
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
fe1ca8
Upstream: http://github.com/karelzak/util-linux/commit/7c90efa384cbb2ace873e2b90e8cc396a1719535
fe1ca8
Signed-off-by: Karel Zak <kzak@redhat.com>
fe1ca8
---
fe1ca8
 tests/functions.sh | 9 ++++++++-
fe1ca8
 tests/run.sh       | 2 ++
fe1ca8
 2 files changed, 10 insertions(+), 1 deletion(-)
fe1ca8
fe1ca8
diff --git a/tests/functions.sh b/tests/functions.sh
fe1ca8
index ab607c4ce..0605a1320 100644
fe1ca8
--- a/tests/functions.sh
fe1ca8
+++ b/tests/functions.sh
fe1ca8
@@ -85,7 +85,13 @@ function ts_check_test_command {
fe1ca8
 	*)
fe1ca8
 		# just command names (e.g. --use-system-commands)
fe1ca8
 		local cmd=$1
fe1ca8
-		type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd"
fe1ca8
+		type "$cmd" >/dev/null 2>&1
fe1ca8
+	        if [ $? -ne 0 ]; then
fe1ca8
+			if [ "$TS_NOSKIP_COMMANDS" = "yes" ]; then
fe1ca8
+				ts_failed "missing in PATH: $cmd"
fe1ca8
+			fi
fe1ca8
+			ts_skip "missing in PATH: $cmd"
fe1ca8
+		fi
fe1ca8
 		;;
fe1ca8
 	esac
fe1ca8
 }
fe1ca8
@@ -301,6 +307,7 @@ function ts_init_env {
fe1ca8
 
fe1ca8
 	ts_init_core_env
fe1ca8
 
fe1ca8
+	TS_NOSKIP_COMMANDS=$(ts_has_option "noskip-commands" "$*")
fe1ca8
 	TS_VERBOSE=$(ts_has_option "verbose" "$*")
fe1ca8
 	TS_SHOWDIFF=$(ts_has_option "show-diff" "$*")
fe1ca8
 	TS_PARALLEL=$(ts_has_option "parallel" "$*")
fe1ca8
diff --git a/tests/run.sh b/tests/run.sh
fe1ca8
index 28f8ee25a..e8328cc5d 100755
fe1ca8
--- a/tests/run.sh
fe1ca8
+++ b/tests/run.sh
fe1ca8
@@ -65,6 +65,7 @@ while [ -n "$1" ]; do
fe1ca8
 	--show-diff |\
fe1ca8
 	--verbose  |\
fe1ca8
 	--skip-loopdevs |\
fe1ca8
+	--noskip-commands |\
fe1ca8
 	--parsable)
fe1ca8
 		# these options are simply forwarded to the test scripts
fe1ca8
 		OPTS="$OPTS $1"
fe1ca8
@@ -113,6 +114,7 @@ while [ -n "$1" ]; do
fe1ca8
 		echo "  --show-diff           show diff from failed tests"
fe1ca8
 		echo "  --nonroot             ignore test suite if user is root"
fe1ca8
 		echo "  --use-system-commands use PATH rather than builddir"
fe1ca8
+		echo "  --noskip-commands     fail on missing commands"
fe1ca8
 		echo "  --srcdir=<path>       autotools top source directory"
fe1ca8
 		echo "  --builddir=<path>     autotools top build directory"
fe1ca8
 		echo "  --parallel=<num>      number of parallel test jobs, default: num cpus"
fe1ca8
-- 
fe1ca8
2.20.1
fe1ca8