-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.unittests
47 lines (36 loc) · 1.03 KB
/
.unittests
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
#! /bin/bash
# Execute the tests by running:
# >> bash .unittests
set -u
error_exit()
{
echo "error@unittests: $1"
exit 1
}
ensure_python_version()
{
python_exe=python
pip_exe=pip
major=$($python_exe --version 2>&1 | awk '{print $2}' | cut -d'.' -f1)
if [ "$major" != "" -a $major -lt 3 ]
then
# check that python3 is on the path
python3 --version > /dev/null || error_exit "'python' represent earlier python version( < 3.0) and python3 not existing"
python_exe=python3
pip_exe=pip3
fi
}
##
ensure_python_version
TOP_DIR=$($python_exe -c "import os; print (os.path.dirname(os.path.realpath('$0')))")
cd $TOP_DIR
if [ $# = 1 ]
then
# example of test name:
# test.unittests.common.test_fs
$python_exe -m unittest $1 -v
else
[ $# = 0 ] || error_exit "expect no argument for unittests"
$python_exe -m unittest discover -s test/unittests -v #test.unittests.common.test_fs
fi
test -d tmp && rm -rf tmp