Commit 491835da authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

updated test for camitk-config

parent 12b83293
Loading
Loading
Loading
Loading
+55 −80
Original line number Diff line number Diff line
@@ -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 ----------------------
checkcommand() {
# usage: checkcommand name 
checkcommand() {
    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,44 +170,16 @@ 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,39 +191,10 @@ 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"
           ;;
        *)
    if [ ! ${releaseDate[$1]+validCamiTKVersion} ]; then
      echo "unknown version"
           ;;
      esac
    else
        echo ${releaseDate[$1]}
    fi
}

@@ -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