Browse Source

Add support for showing test/suite version

Not very useful alone, but already good to read version of a test suite
or test, given that path is passed as well.
Alois Mahdal 6 years ago
parent
commit
948a4060b4
3 changed files with 15 additions and 4 deletions
  1. 5
    1
      src/libexec/jattool-runtest
  2. 6
    1
      src/libexec/jattool-sfind
  3. 4
    2
      src/libexec/jattool-tfind

+ 5
- 1
src/libexec/jattool-runtest View File

@@ -28,7 +28,9 @@ runtest() {
28 28
     #
29 29
     # Wrap in boilerplate and run test code in $1
30 30
     #
31
-    JAT__TEST_ID=$TestId jattool qrun "./test"
31
+    JAT__TEST_ID=$TestId \
32
+    JAT__TEST_VERSION=$TestVersion \
33
+        jattool qrun "./test"
32 34
 }
33 35
 
34 36
 JATS__PATH=${JATS__PATH:-/usr/share/jat/suite}
@@ -55,6 +57,7 @@ main() {
55 57
     local TestHome
56 58
     local TestTmp
57 59
     local TestId
60
+    local TestVersion
58 61
     local Timeout
59 62
     local keeptmp=false
60 63
     local es=0
@@ -83,6 +86,7 @@ main() {
83 86
     esac
84 87
     test -f "$TestHome/test" \
85 88
      || die "test body not found: $TestHome/test"
89
+    TestVersion=$(jattool tfind -f version "$TestHome")
86 90
     TestTmp=$(mktemp -dt jattool-runtest.XXXXXXXX)
87 91
     debug -v TestHome TestId TestTmp
88 92
     cp -ar "$TestHome"/* "$TestTmp" \

+ 6
- 1
src/libexec/jattool-sfind View File

@@ -10,7 +10,8 @@ usage() {
10 10
         -- \
11 11
             "Discover test in suite located at PATH"                         \
12 12
         -o                                                                   \
13
-            "-f FMT     Print test name in format FMT. 'id' or 'path'."    \
13
+            "-f FMT     Print test name in format FMT. 'id', 'version' or"   \
14
+            "           'path'."                                             \
14 15
         --                                                                   \
15 16
             "Test body should consist of asserts and/or phases documented"   \
16 17
             "in jat.sh Shellfu module; use \`sfdoc jat\` to access its"    \
@@ -39,6 +40,7 @@ sprop() {
39 40
         sut_url)        dvalue="https://example.org/anonsut" ;;
40 41
         url)            dvalue="https://$(sprop domain)/$(sprop ns)" ;;
41 42
         format)         : ;;
43
+        version)        dvalue="0.0.0+0._jats_no_version_" ;;
42 44
         *)              warn "unknown property: $pname"; return 2 ;;
43 45
     esac
44 46
     pvalue=$(cat "$fpath" 2>/dev/null)
@@ -79,6 +81,9 @@ discover() {
79 81
                 path)
80 82
                     echo "$SuiteDir"
81 83
                     ;;
84
+                version)
85
+                    sprop version
86
+                    ;;
82 87
             esac
83 88
         done
84 89
 }

+ 4
- 2
src/libexec/jattool-tfind View File

@@ -10,7 +10,8 @@ usage() {
10 10
         -- \
11 11
             "Discover all JATS tests under directory PATH."                  \
12 12
         -o                                                                   \
13
-            "-f FMT     Print test name in format FMT. 'id' or 'path'."
13
+            "-f FMT     Print test name in format FMT. 'id', 'version' or"   \
14
+            "           'path'."
14 15
 }
15 16
 
16 17
 discover() {
@@ -32,6 +33,7 @@ discover() {
32 33
             case $Fmt in
33 34
                 path) echo "$s_dir/$t_rpath" ;;
34 35
                 id) echo "$s_id$t_rpath"   ;;
36
+                version) jattool sfind -f version "$s_dir" ;;
35 37
             esac
36 38
         done
37 39
 }
@@ -60,7 +62,7 @@ main() {
60 62
     esac done
61 63
     FindDirs=("$@")
62 64
     case $Fmt in
63
-        id|path) : ;;
65
+        id|version|path) : ;;
64 66
         *) usage -w "unknown FMT: $Fmt" ;;
65 67
     esac
66 68
     debug -v FindDirs Fmt