Browse Source

Update TFKit to v0.0.17

Alois Mahdal 4 years ago
parent
commit
47316ab8b7

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

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

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

@@ -1,7 +1,9 @@
1 1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2 3
 # tfkit - Shellfu's movable test framework
3 4
 # See LICENSE file for copyright and license details.
4 5
 
6
+#shellcheck disable=SC2153
5 7
 . "$TF_DIR/include/common.sh"
6 8
 
7 9
 
@@ -104,7 +106,7 @@ tf_run_tests() {
104 106
         tmpdir=$(mktemp -d)
105 107
         stamp=$(date "+relics-$tname-%Y%m%d-%H%M%S")
106 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 110
             TF_DEBUG=$TF_DEBUG TF_VERBOSE=$TF_VERBOSE \
109 111
             TF_DIR="$tf_dir" TF_TEST="$tname" \
110 112
             TF_FILTER_SUBTEST=$TF_FILTER_SUBTEST \
@@ -112,7 +114,7 @@ tf_run_tests() {
112 114
             tes=$?
113 115
             __tf_collect_if_needed $tes
114 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 118
         rm -rf "$tmpdir"
117 119
         if test $tes -eq 0;
118 120
         then

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

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

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

@@ -1,4 +1,5 @@
1 1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2 3
 
3 4
 . "$TF_DIR/include/common.sh"
4 5
 
@@ -10,10 +11,10 @@ tf_testflt() {
10 11
     # Run a simple test for a unix filter
11 12
     #
12 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 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 18
     # not cleaning up).
18 19
     #
19 20
 
@@ -44,10 +45,10 @@ tf_testflt() {
44 45
         -S) o_es="$2";          shift 2 || { arg_err=true; break; } ;;
45 46
         --)                     shift; break ;;
46 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 49
         *)                             break ;;
49 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 52
     tf_debug "t_in='$t_in'"
52 53
     tf_debug "t_name='$t_name'"
53 54
     tf_debug "o_out='$o_out'"
@@ -55,22 +56,22 @@ tf_testflt() {
55 56
     tf_debug "o_es='$o_es'"
56 57
     tf_debug "test command: $*"
57 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 66
     # prepare
66 67
     #
67 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 71
     tf_debug "r_out='$r_out'"
71 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 76
     # run
76 77
     #
@@ -79,8 +80,8 @@ tf_testflt() {
79 80
 
80 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 84
     $diff -u "$o_err" "$r_err" || t_es=$TF_ES_FAIL
84 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,8 +1,9 @@
1 1
 #!/bin/bash
2
+#shellcheck disable=SC1090
2 3
 # tfkit - Shellfu's movable test framework
3 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 8
 die() {
8 9
     echo "$@" && exit 9
@@ -75,8 +76,8 @@ main() {
75 76
         -c|--collect)           TF_COLLECT=always;          shift ;;
76 77
         -C|--no-collect)        TF_COLLECT=never;           shift ;;
77 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 81
         -s|--filter-subtest)    TF_FILTER_SUBTEST="$2";     shift 2 || usage ;;
81 82
         -t|--filter-test)       TF_FILTER_TEST="$2";        shift 2 || usage ;;
82 83
         -v|--verbose)           TF_VERBOSE=true;            shift ;;