Browse Source

Update TFKit to v0.0.16

Alois Mahdal 6 years ago
parent
commit
24a6f2f68d
4 changed files with 54 additions and 46 deletions
  1. 1
    1
      .gitignore
  2. 16
    6
      utils/tfkit/doc/README.md
  3. 13
    12
      utils/tfkit/include/harness.sh
  4. 24
    27
      utils/tfkit/runtests

+ 1
- 1
.gitignore View File

@@ -1,3 +1,3 @@
1 1
 .mkit/autoclean
2 2
 shellfu-*.tar.gz
3
-artifacts
3
+relics

+ 16
- 6
utils/tfkit/doc/README.md View File

@@ -1,12 +1,22 @@
1
-Tests
1
+TFKit
2 2
 =====
3 3
 
4
-Running tests is handled by tfkit/runtests:
5 4
 
6
-    $ tfkit/runtest [filter]
5
+Installation
6
+------------
7 7
 
8
-*filter* is a regular expression to be applied to sub-test name, running
9
-only the matching ones.  See below for details.
8
+The easiest way is to embed TFKit within your repo, ie. clone TFKit and
9
+install it using:
10
+
11
+    make install DESTDIR=/path/to/your/repo
12
+
13
+Now you can run your test suite using *runtests* binary:
14
+
15
+    $ cd /path/to/your/repo
16
+    $ utils/tfkit/runtest
17
+
18
+Note that the above probably won't return any useful results as you still
19
+don't have any tests.
10 20
 
11 21
 
12 22
 Writing tests
@@ -49,7 +59,7 @@ along with *TF_RUN*.
49 59
 
50 60
 Note that before running, the whole test directory is automatically
51 61
 copied to a temporary location (one per test), and should the test fail,
52
-copied back as a debugging artifact.  For this reason, *do not store
62
+copied back as a debugging relic.  For this reason, *do not store
53 63
 huge amounts of data here*.  If you really need huge data, consider
54 64
 obtaining it (and throwing it away) within runtime of *TF_RUN*.
55 65
 

+ 13
- 12
utils/tfkit/include/harness.sh View File

@@ -7,9 +7,9 @@
7 7
 
8 8
 __tf_collect_if_needed() {
9 9
     #
10
-    # Collect artifact if exit status suggests it
10
+    # Collect relic if exit status suggests it
11 11
     #
12
-    # Use test exit status $1 to help decide if artifacts are
12
+    # Use test exit status $1 to help decide if relics are
13 13
     # needed, and collect them if so.
14 14
     #
15 15
     # If TF_COLLECT is set to "always", collect regardless of
@@ -18,7 +18,7 @@ __tf_collect_if_needed() {
18 18
     # or 1 (pass or bailout); in that case do nothing.
19 19
     #
20 20
     local tes=$1    # test exit status
21
-    local will      # should we collect artifacts?
21
+    local will      # should we collect relics?
22 22
     case "$TF_COLLECT:$tes" in
23 23
         always:*)   will=true ;;
24 24
         never:*)    will=false ;;
@@ -28,8 +28,8 @@ __tf_collect_if_needed() {
28 28
         *)          tf_exit_bailout "bad value of TF_COLLECT: $TF_COLLECT" ;;
29 29
     esac
30 30
     $will || return 0
31
-    mkdir -p "$artifact_dir/$stamp"
32
-    cp -r "$tmpdir"/* "$artifact_dir/$stamp"
31
+    mkdir -p "$relic_dir/$stamp"
32
+    cp -r "$tmpdir"/* "$relic_dir/$stamp"
33 33
 }
34 34
 
35 35
 __tf_header() {
@@ -90,23 +90,24 @@ tf_run_tests() {
90 90
     local tmpdir=""     # test temporary dir
91 91
     local tname=""      # test name
92 92
     local tes=0         # test result
93
-    local stamp=""      # test stamp to use as artifact name
94
-    local tf_dir tf_suite   # to keep absolute paths for TF_RUN
95
-    local artifact_dir  # where to keep artifacts
96
-    artifact_dir="$(readlink -f "$TF_ARTIFACTS")"
93
+    local stamp=""      # test stamp to use as relic name
94
+    local tf_dir        # to keep absolute path for TF_RUN
95
+    local relic_dir     # where to keep relics
96
+    relic_dir="$(readlink -f "$TF_RELICS")"
97 97
     __tf_header
98 98
     tf_debug "TF_VERSION='$TF_VERSION'"
99 99
     tf_dir="$(readlink -f "$TF_DIR")"
100
-    tf_suite="$(readlink -f "$TF_SUITE")"
101 100
     es=0
102 101
     for tname in $(tf_enum_tests | grep -e "$TF_FILTER_TEST");
103 102
     do
104 103
         tf_think "... $tname"
105 104
         tmpdir=$(mktemp -d)
106
-        stamp=$(date "+artifacts-$tname-%Y%m%d-%H%M%S")
105
+        stamp=$(date "+relics-$tname-%Y%m%d-%H%M%S")
107 106
         cp -r "$TF_SUITE/$tname/"* "$tmpdir"
108 107
         pushd "$tmpdir" >/dev/null
109
-            TF_DIR="$tf_dir" TF_SUITE=$tf_suite TF_TEST="$tname" \
108
+            TF_DEBUG=$TF_DEBUG TF_VERBOSE=$TF_VERBOSE \
109
+            TF_DIR="$tf_dir" TF_TEST="$tname" \
110
+            TF_FILTER_SUBTEST=$TF_FILTER_SUBTEST \
110 111
                 ./TF_RUN
111 112
             tes=$?
112 113
             __tf_collect_if_needed $tes

+ 24
- 27
utils/tfkit/runtests View File

@@ -2,7 +2,7 @@
2 2
 # tfkit - Shellfu's movable test framework
3 3
 # See LICENSE file for copyright and license details.
4 4
 
5
-TF_VERSION="0.0.15"
5
+TF_VERSION="0.0.16"
6 6
 
7 7
 die() {
8 8
     echo "$@" && exit 9
@@ -18,15 +18,13 @@ version() {
18 18
     exit 0
19 19
 }
20 20
 
21
-LC_ALL=C
22
-
23 21
 #
24
-# Artifact directory path
22
+# Relic directory path
25 23
 #
26
-TF_ARTIFACTS="${TF_ARTIFACTS:-artifacts}"
24
+TF_RELICS="${TF_RELICS:-relics}"
27 25
 
28 26
 #
29
-# Artifact collection mode
27
+# Relic collection mode
30 28
 #
31 29
 # 'always' to always collect, 'never` to never collect and 'auto'
32 30
 # to collect only on failed tests.
@@ -68,28 +66,27 @@ TF_SUITE="${TF_SUITE:-tests}"
68 66
 #
69 67
 TF_VERBOSE=${TF_VERBOSE:-true}
70 68
 
71
-while true; do case "$1" in
72
-    -c|--collect)           TF_COLLECT=always;          shift ;;
73
-    -C|--no-collect)        TF_COLLECT=never;           shift ;;
74
-    -d|--debug)             TF_DEBUG=true;              shift ;;
75
-    -p|--prefix)            export PATH="$(readlink -f "$2")/bin:$PATH"
76
-                                                        shift 2 || usage ;;
77
-    -s|--filter-subtest)    TF_FILTER_SUBTEST="$2";     shift 2 || usage ;;
78
-    -t|--filter-test)       TF_FILTER_TEST="$2";        shift 2 || usage ;;
79
-    -v|--verbose)           TF_VERBOSE=true;            shift ;;
80
-    --version-semver)       echo "$TF_VERSION"; exit 0 ;;
81
-    --version)              version ;;
82
-    "") break ;;
83
-    *)  usage ;;
84
-esac done
85
-
86
-export LC_ALL
87
-export TF_DIR TF_SUITE TF_ARTIFACTS
88
-export TF_COLLECT TF_FILTER_SUBTEST TF_FILTER_TEST
89
-export TF_DEBUG TF_VERBOSE
90
-export TF_VERSION
91 69
 
92 70
 . "$TF_DIR/include/harness.sh" \
93 71
  || die "cannot import harness; is TF_DIR set properly?: $TF_DIR"
94 72
 
95
-time tf_run_tests
73
+main() {
74
+    while true; do case "$1" in
75
+        -c|--collect)           TF_COLLECT=always;          shift ;;
76
+        -C|--no-collect)        TF_COLLECT=never;           shift ;;
77
+        -d|--debug)             TF_DEBUG=true;              shift ;;
78
+        -p|--prefix)            export PATH="$(readlink -f "$2")/bin:$PATH"
79
+                                                            shift 2 || usage ;;
80
+        -s|--filter-subtest)    TF_FILTER_SUBTEST="$2";     shift 2 || usage ;;
81
+        -t|--filter-test)       TF_FILTER_TEST="$2";        shift 2 || usage ;;
82
+        -v|--verbose)           TF_VERBOSE=true;            shift ;;
83
+        --version-semver)       echo "$TF_VERSION"; exit 0 ;;
84
+        --version)              version ;;
85
+        "") break ;;
86
+        *)  usage ;;
87
+    esac done
88
+    export LC_ALL=C
89
+    time tf_run_tests
90
+}
91
+
92
+main "$@"