forked from robwhitby/xray
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-runner.sh
More file actions
executable file
·57 lines (47 loc) · 1.24 KB
/
test-runner.sh
File metadata and controls
executable file
·57 lines (47 loc) · 1.24 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
#!/bin/bash
#Sample test runner script, only tested on OSX
#Edit these default values
#####################################################################
BASEURL=http://localhost:8889/xray/
DIR=test
MODULES=
TESTS=
#####################################################################
START=$(date +%s)
CRED=$(tput setaf 1)
CGREEN=$(tput setaf 2)
CYELLOW=$(tput setaf 3)
CDEFAULT=$(tput sgr0)
STATUS=0
while getopts 'u:m:t:d:h' OPTION
do
case $OPTION in
u) BASEURL="$OPTARG";;
m) MODULES="$OPTARG";;
t) TESTS="$OPTARG";;
d) DIR="$OPTARG";;
*)
echo "usage: test-runner.sh [-u URL of index.xqy] [-m module name regex] [-t test name regex] [-d test directory]"
exit 1;;
esac
done
URL="$BASEURL?format=text&modules=$MODULES&tests=$TESTS&dir=$DIR"
RESPONSE=$(curl --silent "$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