[med-svn] [Git][med-team/camitk][master] updated test for camitk-config

Emmanuel Promayon gitlab at salsa.debian.org
Mon Jul 23 15:29:57 BST 2018


Emmanuel Promayon pushed to branch master at Debian Med / camitk


Commits:
491835da by Emmanuel Promayon at 2018-07-23T15:43:44+02:00
updated test for camitk-config

- - - - -


1 changed file:

- debian/tests/config-test.sh


Changes:

=====================================
debian/tests/config-test.sh
=====================================
--- a/debian/tests/config-test.sh
+++ b/debian/tests/config-test.sh
@@ -4,7 +4,8 @@
 # This test entirely depends on the CamitK version (version string, number of extensions...)
 # (see the expectedConfigOutput)
 # 
-# For a CamiTK major or minor version update the expected number and release date
+# For a CamiTK major or minor version please update the expected number and release date
+# in function initTestData
 # 
 # echo $? get the last returned value of the script
 # a return value of 0 indicates success (by convention)
@@ -17,6 +18,42 @@ set -e
 # Uncomment next line to debug
 # set -x
 
+# ---------------------- initTestData ----------------------
+# values to check
+initTestData() {
+    # fill test data
+    extensionCount=(           [4.2]=41  [4.1]=41  [4.0]=31  )
+    componentExtensionCount=(  [4.2]=14  [4.1]=14  [4.0]=14  )
+    actionExtensionCount=(     [4.2]=27  [4.1]=27  [4.0]=27  )
+    fileExtensionCount=(       [4.2]=37  [4.1]=37  [4.0]=37  )
+    actionCount=(              [4.2]=105 [4.1]=105 [4.0]=105 )
+    
+    # fill release date
+    releaseDate=(              [4.2]="not yet released, current development version" \
+                               [4.1]="15 July 2018" \
+                               [4.0]="22 July 2016" \
+                               [3.5]="29 January 2016"
+                               [3.4]="31 October 2014" \
+                               [3.3]="4 March 2014" \
+                               [3.2]="26 June 2013" \
+                               [3.1]="1 March 2013" \
+                               [3.0]="7 July 2012" )
+    
+}
+
+# ---------------------- declareTestData ----------------------
+declareTestData() {
+    # declare all associative arrays (-g is to declare the arrays
+    # in the global scope)
+    declare -Ag extensionCount
+    declare -Ag componentExtensionCount
+    declare -Ag actionExtensionCount
+    declare -Ag fileExtensionCount
+    declare -Ag actionCount
+    declare -Ag releaseDate
+}
+
+# ---------------------- cleanup ----------------------
 # cleanup on exit
 cleanup() {
     # backup the current exit status
@@ -35,8 +72,8 @@ cleanup() {
 }
 
 # ---------------------- checkcommand ----------------------
+# usage: checkcommand name 
 checkcommand() {
-    # usage: checkcommand name 
     if [ "$inBuild" == "0" ] ; then
         # check if current build is on windows debug version
         if ! hash ${1} 2>/dev/null; then
@@ -111,7 +148,7 @@ init() {
 getconfig() {
     # initialize config output
     echo "===== Get CamiTK configuration ====="
-    $camitkConfig --config > ./config-output 2>&1
+    $camitkConfig --config 2>/dev/null > ./config-output
     camitkConfig=$(cat config-output | sed "s/QStandardPaths.*'.*'//")
 
     echo "===== config-output ====="
@@ -133,45 +170,17 @@ getExpectedValue() {
       echo $(pwd) | sed -e "s+^/c+C:+"
       ;;
     "Number of Component Extensions")
-      case "$shortVersion" in
-        "4.0" | "4.1" | "4.2")
-          echo "14" # 11 in sdk, imaging and modeling and 3 in tutorials
-          ;;
-        "3.3" | *)
-          echo "12" 
-          ;;
-      esac
+      echo ${componentExtensionCount[$shortVersion]}
       ;;       
     "Number of Action Extensions")
-      case "$shortVersion" in
-        "4.0" | "4.1" | "4.2")
-          echo "27" # 19 in sdk, imaging and modeling and 8 in tutorials
-          ;;
-        "3.3" | *)
-          echo "71"
-          ;;
-      esac
-      ;;
+      echo ${actionExtensionCount[$shortVersion]}
+      ;;       
     "Number of File Extensions Supported")
-      case "$shortVersion" in
-        "4.0" | "4.1" | "4.2")
-          echo "37" # 34 in sdk, imaging and modeling and 3 in tutorials
-          ;;
-        "3.3" | *)
-          echo "35"
-          ;;
-      esac
-      ;;
+      echo ${fileExtensionCount[$shortVersion]}
+      ;;       
     "Number of Actions")
-      case "$shortVersion" in
-        "4.0" | "4.1" | "4.2")
-          echo "105" # 92 in sdk, imaging and modeling and 14 in tutorials
-          ;;
-        "3.3" | *)
-          echo "81"
-          ;;
-      esac
-      ;;
+      echo ${actionCount[$shortVersion]}
+      ;;       
   esac
 }
 
@@ -182,40 +191,11 @@ getInstalledVersion() {
 
 # ------------------- getReleaseDate -------------------
 getReleaseDate() {
-  # get the release date of minor version 
-  if [[ $1 =~ .*dev.* ]]; then
-    echo "not yet released"
-  else
-    case "$1" in
-        "3.0")
-           echo "7 July 2012"
-           ;;
-        "3.1")
-           echo "1 March 2013"
-           ;;
-        "3.2")
-           echo "26 June 2013"
-           ;;
-        "3.3")
-           echo "4 March 2014"
-           ;;
-        "3.4")
-           echo "31 October 2014"
-           ;;
-        "3.5")
-           echo "29 January 2016"
-           ;;
-        "4.0")
-           echo "22 July 2016"
-           ;;
-        "4.1")
-           echo "15 July 2018"
-           ;;
-        *)
-           echo "unknown version"
-           ;;
-      esac
-  fi
+    if [ ! ${releaseDate[$1]+validCamiTKVersion} ]; then
+      echo "unknown version"
+    else
+        echo ${releaseDate[$1]}
+    fi
 }
 
 # ---------------------- extension count ----------------------
@@ -224,14 +204,7 @@ getExtensionCount() {
 }
 
 getExpectedExtensionCount() {
-  case "$1" in
-    "4.0" | "4.1" | "4.2")    
-      echo "41"  # 30 extensions in sdk, imaging and modeling and 11 extensions in tutorials
-      ;;
-    "3.3" | *)
-      echo "12" 
-      ;;    
-  esac
+  echo ${extensionCount[$1]}
 }
 
 # ---------------------- get config ----------------------
@@ -269,6 +242,8 @@ checkValue() {
 # if a problem occurs, call the clean method
 trap "cleanup" 0 INT QUIT ABRT PIPE TERM EXIT
 
+declareTestData
+initTestData
 init $*
 getconfig
 



View it on GitLab: https://salsa.debian.org/med-team/camitk/commit/491835da9950617d44d8db802355d88779925bf7

-- 
View it on GitLab: https://salsa.debian.org/med-team/camitk/commit/491835da9950617d44d8db802355d88779925bf7
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20180723/13f5f5f6/attachment-0001.html>


More information about the debian-med-commit mailing list