]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add option --parsable
authorRuediger Meier <ruediger.meier@ga-group.nl>
Sat, 5 Mar 2016 14:40:57 +0000 (15:40 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Sat, 5 Mar 2016 21:19:24 +0000 (22:19 +0100)
This is to force the one-line results also for non-parallel case.
We are using it for travis auto-build and on other build farms.

Moreover you can set this (and any other) option globally by env
which is the only way to pass it to make distcheck.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
.travis-functions.sh
tests/functions.sh
tests/run.sh

index 3315a915938c650ea8ec9bcd79c7daa3e64ffaae..3c1855951d1be551c682f70fb0a719c4d102dab2 100755 (executable)
@@ -15,6 +15,7 @@ fi
 # travis docs say we get 1.5 CPUs
 MAKE="make -j2"
 DUMP_CONFIG_LOG="short"
+export TS_OPT_parsable="yes"
 
 function xconfigure
 {
index c367f011e1955d630fd78e936fe068a80d264984..9e5d24325ceea66f653cadb1399ae687588fbda0 100644 (file)
@@ -48,7 +48,7 @@ function ts_cd {
 function ts_report {
        local desc=
 
-       if [ "$TS_PARALLEL" != "yes" ]; then
+       if [ "$TS_PARSABLE" != "yes" ]; then
                if [ $TS_NSUBTESTS -ne 0 ] && [ -z "$TS_SUBNAME" ]; then
                        desc=$(printf "%11s...")
                fi
@@ -169,7 +169,14 @@ function ts_has_option {
        fi
 
        # or just check the global command line options
-       if [[ $ALL =~ ([$' \t\n']|^)--$NAME([$'= \t\n']|$) ]]; then echo yes; fi
+       if [[ $ALL =~ ([$' \t\n']|^)--$NAME([$'= \t\n']|$) ]]; then
+               echo yes
+               return
+       fi
+
+       # or the _global_ env, e.g TS_OPT_parsable="yes"
+       eval local env_opt=\$TS_OPT_${v_name}
+       if [ "$env_opt" = "yes" ]; then echo "yes"; fi
 }
 
 function ts_option_argument {
@@ -259,6 +266,8 @@ function ts_init_env {
        TS_PARALLEL=$(ts_has_option "parallel" "$*")
        TS_KNOWN_FAIL=$(ts_has_option "known-fail" "$*")
        TS_SKIP_LOOPDEVS=$(ts_has_option "skip-loopdevs" "$*")
+       TS_PARSABLE=$(ts_has_option "parsable" "$*")
+       [ "$TS_PARSABLE" = "yes" ] || TS_PARSABLE="$TS_PARALLEL"
 
        tmp=$( ts_has_option "memcheck" "$*")
        if [ "$tmp" == "yes" -a -f /usr/bin/valgrind ]; then
@@ -309,7 +318,7 @@ function ts_init_subtest {
        ts_init_core_subtest_env
        TS_NSUBTESTS=$(( $TS_NSUBTESTS + 1 ))
 
-       if [ "$TS_PARALLEL" != "yes" ]; then
+       if [ "$TS_PARSABLE" != "yes" ]; then
                [ $TS_NSUBTESTS -eq 1 ] && echo
                printf "%16s: %-27s ..." "" "$TS_SUBNAME"
        fi
@@ -321,7 +330,7 @@ function ts_init {
        local is_fake=$( ts_has_option "fake" "$*")
        local is_force=$( ts_has_option "force" "$*")
 
-       if [ "$TS_PARALLEL" != "yes" ]; then
+       if [ "$TS_PARSABLE" != "yes" ]; then
                printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC"
        fi
 
index 03cd9f5c248fe4ce07632723cd9ef9d9aa201723..aad3acb0ddb927d281d3c437b25f36d656187cdb 100755 (executable)
@@ -43,20 +43,14 @@ function find_test_scripts()
 
 while [ -n "$1" ]; do
        case "$1" in
-       --force)
-               OPTS="$OPTS --force"
-               ;;
-       --fake)
-               OPTS="$OPTS --fake"
-               ;;
-       --memcheck)
-               OPTS="$OPTS --memcheck"
-               ;;
-       --verbose)
-               OPTS="$OPTS --verbose"
-               ;;
-       --skip-loopdevs)
-               OPTS="$OPTS --skip-loopdevs"
+       --force |\
+       --fake |\
+       --memcheck |\
+       --verbose  |\
+       --skip-loopdevs |\
+       --parsable)
+               # these options are simply forwarded to the test scripts
+               OPTS="$OPTS $1"
                ;;
        --nonroot)
                if [ $(id -ru) -eq 0 ]; then