Browse Source

Update TFKit to v0.0.17

Alois Mahdal 5 years ago
parent
commit
47316ab8b7

+ 4
- 1
utils/tfkit/include/common.sh View File

1
+#!/bin/bash
2
+#shellcheck disable=SC2034,SC1117
3
+
1
 #
4
 #
2
 # Variables to hold exit status semantic
5
 # Variables to hold exit status semantic
3
 #
6
 #
123
     for msg in "$@";
126
     for msg in "$@";
124
     do
127
     do
125
         $TF_COLOR && echo -ne "$TF_COLOR_LBLACK" >&2
128
         $TF_COLOR && echo -ne "$TF_COLOR_LBLACK" >&2
126
-        echo "$pfx$msg$sfx" >&2;
129
+        echo "$msg" >&2;
127
         $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
130
         $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
128
     done
131
     done
129
 }
132
 }

+ 4
- 2
utils/tfkit/include/harness.sh View File

1
 #!/bin/bash
1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2
 # tfkit - Shellfu's movable test framework
3
 # tfkit - Shellfu's movable test framework
3
 # See LICENSE file for copyright and license details.
4
 # See LICENSE file for copyright and license details.
4
 
5
 
6
+#shellcheck disable=SC2153
5
 . "$TF_DIR/include/common.sh"
7
 . "$TF_DIR/include/common.sh"
6
 
8
 
7
 
9
 
104
         tmpdir=$(mktemp -d)
106
         tmpdir=$(mktemp -d)
105
         stamp=$(date "+relics-$tname-%Y%m%d-%H%M%S")
107
         stamp=$(date "+relics-$tname-%Y%m%d-%H%M%S")
106
         cp -r "$TF_SUITE/$tname/"* "$tmpdir"
108
         cp -r "$TF_SUITE/$tname/"* "$tmpdir"
107
-        pushd "$tmpdir" >/dev/null
109
+        pushd "$tmpdir" >/dev/null || tf_exit_panic "could not chdir to: $tmpdir"
108
             TF_DEBUG=$TF_DEBUG TF_VERBOSE=$TF_VERBOSE \
110
             TF_DEBUG=$TF_DEBUG TF_VERBOSE=$TF_VERBOSE \
109
             TF_DIR="$tf_dir" TF_TEST="$tname" \
111
             TF_DIR="$tf_dir" TF_TEST="$tname" \
110
             TF_FILTER_SUBTEST=$TF_FILTER_SUBTEST \
112
             TF_FILTER_SUBTEST=$TF_FILTER_SUBTEST \
112
             tes=$?
114
             tes=$?
113
             __tf_collect_if_needed $tes
115
             __tf_collect_if_needed $tes
114
             test $tes -gt $es && es=$tes
116
             test $tes -gt $es && es=$tes
115
-        popd >/dev/null
117
+        popd >/dev/null || tf_exit_panic "could not chdir from: $tmpdir to $OLDPWD"
116
         rm -rf "$tmpdir"
118
         rm -rf "$tmpdir"
117
         if test $tes -eq 0;
119
         if test $tes -eq 0;
118
         then
120
         then

+ 1
- 0
utils/tfkit/include/subtest.sh View File

1
 #!/bin/bash
1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2
 
3
 
3
 . "$TF_DIR/include/common.sh"
4
 . "$TF_DIR/include/common.sh"
4
 
5
 

+ 17
- 16
utils/tfkit/include/tools.sh View File

1
 #!/bin/bash
1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2
 
3
 
3
 . "$TF_DIR/include/common.sh"
4
 . "$TF_DIR/include/common.sh"
4
 
5
 
10
     # Run a simple test for a unix filter
11
     # Run a simple test for a unix filter
11
     #
12
     #
12
     #     tf_testflt -n foo [-i foo.stdin] \
13
     #     tf_testflt -n foo [-i foo.stdin] \
13
-    #                [-O foo.stdout] [-E foo.stderr] [-S 3] \
14
+    #                [-O foo.out] [-E foo.err] [-S 3] \
14
     #                cmd arg...
15
     #                cmd arg...
15
     #
16
     #
16
-    # Will drop *result/NAME.stdout* and *result/NAME.stderr* (intentionally
17
+    # Will drop *result/NAME.out* and *result/NAME.err* (intentionally
17
     # not cleaning up).
18
     # not cleaning up).
18
     #
19
     #
19
 
20
 
44
         -S) o_es="$2";          shift 2 || { arg_err=true; break; } ;;
45
         -S) o_es="$2";          shift 2 || { arg_err=true; break; } ;;
45
         --)                     shift; break ;;
46
         --)                     shift; break ;;
46
         "")                            break ;;
47
         "")                            break ;;
47
-        -*) tf_warn "wrong testcli arg: $1"; return $TF_ES_BAILOUT ;;
48
+        -*) tf_warn "wrong testcli arg: $1"; return "$TF_ES_BAILOUT" ;;
48
         *)                             break ;;
49
         *)                             break ;;
49
     esac done
50
     esac done
50
-    $arg_err && { tf_warn "error parsing arguments: $orig_args"; return $TF_ES_BAILOUT; }
51
+    $arg_err && { tf_warn "error parsing arguments: $orig_args"; return "$TF_ES_BAILOUT"; }
51
     tf_debug "t_in='$t_in'"
52
     tf_debug "t_in='$t_in'"
52
     tf_debug "t_name='$t_name'"
53
     tf_debug "t_name='$t_name'"
53
     tf_debug "o_out='$o_out'"
54
     tf_debug "o_out='$o_out'"
55
     tf_debug "o_es='$o_es'"
56
     tf_debug "o_es='$o_es'"
56
     tf_debug "test command: $*"
57
     tf_debug "test command: $*"
57
     test "$t_in" = "-" && t_in=/dev/stdin   # works better for check below
58
     test "$t_in" = "-" && t_in=/dev/stdin   # works better for check below
58
-    test -z "$t_name"  && { tf_warn "missing test name"             ; return $TF_ES_BAILOUT; }
59
-    test -z "$1"       && { tf_warn "missing test command"          ; return $TF_ES_BAILOUT; }
60
-    test -r "$t_in"    || { tf_warn "missing input file: $t_in"     ; return $TF_ES_BAILOUT; }
61
-    test -e "$o_out"   || { tf_warn "missing oracle stdout: $o_out" ; return $TF_ES_BAILOUT; }
62
-    test -e "$o_err"   || { tf_warn "missing oracle stderr: $o_err" ; return $TF_ES_BAILOUT; }
63
-    test "$o_es" -ge 0 || { tf_warn "invalid oracle status: $o_es"  ; return $TF_ES_BAILOUT; }
59
+    test -z "$t_name"  && { tf_warn "missing test name"             ; return "$TF_ES_BAILOUT"; }
60
+    test -z "$1"       && { tf_warn "missing test command"          ; return "$TF_ES_BAILOUT"; }
61
+    test -r "$t_in"    || { tf_warn "missing input file: $t_in"     ; return "$TF_ES_BAILOUT"; }
62
+    test -e "$o_out"   || { tf_warn "missing oracle stdout: $o_out" ; return "$TF_ES_BAILOUT"; }
63
+    test -e "$o_err"   || { tf_warn "missing oracle stderr: $o_err" ; return "$TF_ES_BAILOUT"; }
64
+    test "$o_es" -ge 0 || { tf_warn "invalid oracle status: $o_es"  ; return "$TF_ES_BAILOUT"; }
64
 
65
 
65
     # prepare
66
     # prepare
66
     #
67
     #
67
     mkdir -p result
68
     mkdir -p result
68
-    r_out="result/$t_name.stdout"
69
-    r_err="result/$t_name.stderr"
69
+    r_out="result/$t_name.out"
70
+    r_err="result/$t_name.err"
70
     tf_debug "r_out='$r_out'"
71
     tf_debug "r_out='$r_out'"
71
     tf_debug "r_err='$r_err'"
72
     tf_debug "r_err='$r_err'"
72
-    touch "$r_out" || { tf_warn "cannot create tmp file: $r_out" ; return $TF_ES_BAILOUT; }
73
-    touch "$r_err" || { tf_warn "cannot create tmp file: $r_err" ; return $TF_ES_PANIC; }
73
+    touch "$r_out" || { tf_warn "cannot create tmp file: $r_out" ; return "$TF_ES_BAILOUT"; }
74
+    touch "$r_err" || { tf_warn "cannot create tmp file: $r_err" ; return "$TF_ES_PANIC"; }
74
 
75
 
75
     # run
76
     # run
76
     #
77
     #
79
 
80
 
80
     # eval/report/exit
81
     # eval/report/exit
81
     #
82
     #
82
-    test $r_es = $o_es || { tf_warn "bad exit status: $r_es (need $o_es)" ; t_es=$TF_ES_FAIL; }
83
+    test "$r_es" = "$o_es" || { tf_warn "bad exit status: $r_es (need $o_es)" ; t_es=$TF_ES_FAIL; }
83
     $diff -u "$o_err" "$r_err" || t_es=$TF_ES_FAIL
84
     $diff -u "$o_err" "$r_err" || t_es=$TF_ES_FAIL
84
     $diff -u "$o_out" "$r_out" || t_es=$TF_ES_FAIL
85
     $diff -u "$o_out" "$r_out" || t_es=$TF_ES_FAIL
85
-    return $t_es
86
+    return "$t_es"
86
 }
87
 }

+ 4
- 3
utils/tfkit/runtests View File

1
 #!/bin/bash
1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2
 # tfkit - Shellfu's movable test framework
3
 # tfkit - Shellfu's movable test framework
3
 # See LICENSE file for copyright and license details.
4
 # See LICENSE file for copyright and license details.
4
 
5
 
5
-TF_VERSION="0.0.16"
6
+TF_VERSION="0.0.17"
6
 
7
 
7
 die() {
8
 die() {
8
     echo "$@" && exit 9
9
     echo "$@" && exit 9
75
         -c|--collect)           TF_COLLECT=always;          shift ;;
76
         -c|--collect)           TF_COLLECT=always;          shift ;;
76
         -C|--no-collect)        TF_COLLECT=never;           shift ;;
77
         -C|--no-collect)        TF_COLLECT=never;           shift ;;
77
         -d|--debug)             TF_DEBUG=true;              shift ;;
78
         -d|--debug)             TF_DEBUG=true;              shift ;;
78
-        -p|--prefix)            export PATH="$(readlink -f "$2")/bin:$PATH"
79
-                                                            shift 2 || usage ;;
79
+        -p|--prefix)            PATH="$(readlink -f "$2")/bin:$PATH"
80
+                                export PATH;                shift 2 || usage ;;
80
         -s|--filter-subtest)    TF_FILTER_SUBTEST="$2";     shift 2 || usage ;;
81
         -s|--filter-subtest)    TF_FILTER_SUBTEST="$2";     shift 2 || usage ;;
81
         -t|--filter-test)       TF_FILTER_TEST="$2";        shift 2 || usage ;;
82
         -t|--filter-test)       TF_FILTER_TEST="$2";        shift 2 || usage ;;
82
         -v|--verbose)           TF_VERBOSE=true;            shift ;;
83
         -v|--verbose)           TF_VERBOSE=true;            shift ;;