Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c298bb7cf6
Fetching contributors…

Cannot retrieve contributors at this time

executable file 79 lines (67 sloc) 1.856 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#!/bin/bash

# Rather than modify this script, consider creating a wrapper script with
# better defaults for your project. See run-xray-tests.sh

#Default parameter values
#####################################################################
BASEURL=http://localhost:8889/xray/
CREDENTIALS=
DIR=test
MODULES=
TESTS=
#####################################################################


START=$(date +%s)
CRED=$(tput setaf 1)
CGREEN=$(tput setaf 2)
CYELLOW=$(tput setaf 3)
CDEFAULT=$(tput sgr0)
STATUS=0

function usage() {
      echo '
usage: test-runner.sh [options...]
Options:
-c <user:password> Credential for HTTP authentication.
-d <path> Look for tests in this directory.
-h This message.
-m <regex> Test modules that match this pattern.
-t <regex> Test functions that match this pattern.
-u <URL> HTTP server location where index.xqy can be found.
'
      exit 1
}

while getopts 'c:d:hm:t:u:' OPTION
do
  case $OPTION in
    c) CREDENTIAL="$OPTARG";;
    d) DIR="$OPTARG";;
    h) usage;;
    m) MODULES="$OPTARG";;
    t) TESTS="$OPTARG";;
    u) BASEURL="$OPTARG";;
    *) usage;;
  esac
done

URL="$BASEURL?format=text&modules=$MODULES&tests=$TESTS&dir=$DIR"
CURL="curl --silent"
if [ -n "$CREDENTIAL" ]; then
    CURL="$CURL --anyauth --user $CREDENTIAL"
fi
RESPONSE=$($CURL "$URL")

if [ "$RESPONSE" = "" ]; then
  echo "Error: No response from $URL"
  STATUS=1
fi

while read -r LINE; do
  case $LINE in
    Module*) echo -ne $CDEFAULT;;
    *PASSED) echo -ne $CGREEN;;
    *IGNORED) echo -ne $CYELLOW;;
    *FAILED) STATUS=1; echo -ne $CRED;;
    Finished*) echo -ne $CDEFAULT;;
  esac
  echo $LINE
done <<< "$RESPONSE"

DIFF=$(( $(date +%s) - $START ))
echo -ne $CDEFAULT
#echo -e "Time: $DIFF seconds"

exit $STATUS

# end
Something went wrong with that request. Please try again.