-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntest
executable file
·158 lines (133 loc) · 3.93 KB
/
runtest
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
usage() {
cat << END
Usage:
$ runtest [<options>] [<cases>]
[Options]
-c <config file>: specify the config file name. The file is under config/.
The default value is default.cfg
-t <tag>: run test cases with this tag
--verbose: verbose output
--no-stop: don't stop if any case fails
[Cases]
If this parameter is not specified, find all cases under current directory
and run them.
Or it may be specifiled as:
[<path>]<filename>[:<class>[.<function>]]
For example:
- A file name: object_io_test.py
- A full path: ecstest/testcases/dataplan/object_io_test.py
- A path/file with a test class/function:
object_io_test.py:TestObjectPostGetDelete
object_io_test.py:TestObjectPostGetDelete.test_1_byte_size
ecstest/testcases/dataplane/object_io_test.py:TestObjectPostGetDelete
ecstest/testcases/dataplane/object_io_test.py:TestObjectPostGetDelete.test_1_byte_size
- A path/file with wildcard: object_io_*
Examples:
./runtest
This command runs all cases
./runtest object_io_test.py
This command runs a single case object_io_test.py.
./runtest ecstest/testcases/dataplane/object_io_test.py
Full path is optional.
./runtest object_io_test.py:TestObjectPostGetDelete
./runtest object_io_test.py:TestObjectPostGetDelete.test_1_byte_size
Or run a single class/function. Full path is optional.
./runtest dataplane
./runtest ecstest/testcases/dataplane
Or run all cases under a directory
./runtest -c fakes3.cfg
Change config information (account, endpoint, etc.) on the fly
./runtest -t objectio
Specify tags on the fly
./runtest --verbose
Print debug level log messages
./runtest object_io_*
Wildcard is supported.
./runtest -c awss3.cfg -t objectio --verbose dataplane
Compose parameters
END
}
CONFIG_FILE=default.cfg
NOSECMD="nosetests --with-timer --with-xunit --nocapture"
OPTS=`getopt -o c:t:h --long config,tags,verbose,no-stop,help -- "$@"`
while true; do
case "$1" in
-c|--config)
CONFIG_FILE=$2
shift 2;;
-t|--tag)
TAGS=$2
shift 2;;
--verbose)
export ECSTEST_VERBOSE_OUTPUT=1
shift;;
--no-stop)
export ECSTEST_NO_STOP=1
shift;;
--)
shift
break;;
-h|--help)
usage
exit 0;;
*)
break;;
esac
done
echo "==============================================="
echo "Config file : $CONFIG_FILE"
echo "Tags : $TAGS"
echo "Verbose : $ECSTEST_VERBOSE_OUTPUT"
echo "Case/dir : $1"
echo "==============================================="
if [ -f $CONFIG_FILE ]; then
source $CONFIG_FILE
elif [ -f config/$CONFIG_FILE ]; then
source config/$CONFIG_FILE
else
echo "Cannot find config file: $CONFIG_FILE"
exit 1
fi
if [ "$ECSTEST_NO_STOP" != "1" ]; then
NOSECMD="$NOSECMD -x"
fi
if [ "$ECSTEST_VERBOSE_OUTPUT" = "1" ];then
NOSECMD="$NOSECMD -v"
fi
if [ -n "$TAGS" ]; then
NOSECMD="$NOSECMD -a tags=$TAGS"
fi
env | grep ^ECSTEST_
echo "NOSECMD=$NOSECMD"
echo "==============================================="
if [ -z "$1" ]; then
# Run all cases under current dir
echo "Run all cases..."
$NOSECMD
elif [ -f "$1" ] || [ -d "$1" ]; then
# Run a dir/file
echo "Run case(s): $1 ..."
$NOSECMD $1
else
fn=${1/:*/}
if [ -f $fn ]; then
echo "Run case: $1 ..."
$NOSECMD $1
else
cf=${1#*:}
if [ "$cf" = "$1" ]; then
cf=
fi
echo "Searching $fn ..."
for f in `find . -name $fn ! -name '*.pyc' ! -path './.git/*'`; do
if [ -z "$cf" ]; then
c=$f
else
c=$f:$cf
fi
echo "Run case: $c ..."
$NOSECMD $c
done
fi
fi