github.com/metacurrency/holochain@v0.1.0-alpha-26.0.20200915073418-5c83169c9b5b/bin/test.examples (about)

     1  #!/usr/bin/env bash
     2  # run the tests of example apps using hcdev
     3  
     4  BRANCH=develop
     5  EXAMPLES=("HoloWorld" "fractal-wiki" "clutter" "cointoss") # "holodex" "dpki" "holochat"
     6  
     7  for i in "$@"
     8  do
     9      case $i in
    10          -b=*|--branch=*)
    11              BRANCH="${i#*=}"
    12              shift #past argument=value
    13              ;;
    14          -e=*|--example=*)
    15              EXAMPLES=( ${i#*=} )
    16              shift #past argument=value
    17              ;;
    18          *)
    19              # unknown option
    20              ;;
    21      esac
    22  done
    23  
    24  cd /tmp
    25  testDir="holochain.test.examples"
    26  rm -rf $testDir
    27  mkdir $testDir
    28  cd $testDir
    29  
    30  declare -a RESULTS
    31  
    32  i=0
    33  for app in "${EXAMPLES[@]}"
    34  do
    35      echo "hcdev init -fromBranch=$BRANCH -cloneExample $app $app"
    36      hcdev init -fromBranch=$BRANCH -cloneExample $app $app
    37      cd $app
    38      hcdev test
    39      r=$?
    40      RESULTS[$i]="$r"
    41      i=$i+1
    42      printf "RESULT for $app: $r\n"
    43  done
    44  
    45  rm -rf /tmp/$testDir
    46  
    47  RED='\033[0;31m'
    48  GREEN='\033[0;32m'
    49  NC='\033[0m' # No Color
    50  
    51  exitValue=0
    52  i=0
    53  printf "\n\n===================================================\nTest results:\n"
    54  for app in "${EXAMPLES[@]}"
    55  do
    56      result=${RESULTS[$i]}
    57      i=$i+1
    58      if [ $result != 0 ]; then
    59          color="${RED}"
    60          exitValue=1
    61      else
    62          color="${GREEN}"
    63      fi
    64      printf "$app $color exit code: $result${NC}\n"
    65  
    66  done
    67  
    68  exit $exitValue