[RFC,v5,3/5] tst_test.sh: Filter out commented out lines from warnings
diff mbox series

Message ID 20180525215725.7218-4-pvorel@suse.cz
State Superseded
Delegated to: Cyril Hrubis
Headers show
Series
  • tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFS + cleanup
Related show

Commit Message

Petr Vorel May 25, 2018, 9:57 p.m. UTC
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index de5d65039..098ff7bd2 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -244,13 +244,21 @@  _tst_rescmp()
 	fi
 }
 
+_tst_get_used_var()
+{
+	local _tst_pattern="$1"
+
+	grep $_tst_pattern "$TST_TEST_PATH" | grep -v '^[[:space:]]*#' | \
+		sed "s/.*${_tst_pattern}//;"' s/[="} \t\/:`].*//'
+}
+
 tst_run()
 {
 	local _tst_i
 	local _tst_name
 
 	if [ -n "$TST_TEST_PATH" ]; then
-		for _tst_i in $(grep TST_ "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
+		for _tst_i in $(_tst_get_used_var "TST_"); do
 			case "$_tst_i" in
 			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
 			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
@@ -261,7 +269,7 @@  tst_run()
 			esac
 		done
 
-		for _tst_i in $(grep _tst_ "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do
+		for _tst_i in $(_tst_get_used_var "_tst_"); do
 			tst_res TWARN "Private variable or function _tst_$_tst_i used!"
 		done
 	fi