forked from o3project/odenos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-unittests.sh
executable file
·82 lines (71 loc) · 2.5 KB
/
run-unittests.sh
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
#!/bin/bash
# Copyright 2015 NEC Corporation. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
PROJECT_DIR=`readlink -f $0`
PROJECT_DIR=`dirname ${PROJECT_DIR}`
TEST_SRC_DIR=${PROJECT_DIR}/src/test
MAIN_SRC_DIR=${PROJECT_DIR}/src/main/python
RUBY_TEST_SCRIPT=${PROJECT_DIR}/src/test/ruby/test_helper.rb
export PYTHONPATH=${MAIN_SRC_DIR}
run_javaut()
{
pushd $PROJECT_DIR > /dev/null
echo -e '=========================== Java Unit Test ==========================='
mvn test -Dapp.log=/dev/null 2>/dev/null
popd > /dev/null
}
run_pyut()
{
pushd $PROJECT_DIR > /dev/null
echo -e '\n\n\n========================== Python Unit Test =========================='
(cd ${TEST_SRC_DIR}; coverage run -m unittest discover -s python.org; coverage report --include=${MAIN_SRC_DIR}/* --omit=${MAIN_SRC_DIR}/*/__init__.py)
popd > /dev/null
}
run_rubyut()
{
pushd $PROJECT_DIR > /dev/null
echo -e '\n\n\n========================== Ruby Unit Test ============================'
ruby ${RUBY_TEST_SCRIPT}
popd > /dev/null
}
show_help()
{
echo >&2 "usage : $0 [-jpr]"
echo >&2 " -j unittest for java"
echo >&2 " -p unittest and coverage for python"
echo >&2 " -r unittest and coverage for ruby"
}
# check log output directory
if [ ! -e ${PROJECT_DIR}/var/log ]; then
mkdir -p ${PROJECT_DIR}/var/log
fi
# check command args
if [ $# -lt 1 ]; then
run_javaut
run_pyut
run_rubyut
fi
while getopts 'jprh' OPTION
do
case $OPTION in
"j")
run_javaut ;;
"p")
run_pyut ;;
"r")
run_rubyut ;;
"h")
show_help ;;
esac
done