-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtest_code.sh
executable file
·41 lines (31 loc) · 1.14 KB
/
test_code.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
#!/usr/bin/env bash
module="safeopt"
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
# While $SOURCE is a symlink, resolve it
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
# If $SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo "$DIR"
}
# Change to script root
cd $(get_script_dir)
GREEN='\033[0;32m'
NC='\033[0m'
# Run style tests
echo -e "${GREEN}Running style tests.${NC}"
flake8 $module --exclude test*.py,__init__.py --ignore=E402,E731,E741,W503 --show-source
# Ignore import errors for __init__ and tests
flake8 $module --filename=__init__.py,test*.py --ignore=F,E402,W503 --show-source
echo -e "${GREEN}Testing docstring conventions.${NC}"
# Test docstring conventions
pydocstyle $module --convention=numpy
# Run unit tests
echo -e "${GREEN}Running unit tests.${NC}"
pytest --doctest-modules --cov --cov-fail-under=50 $module
# Export html
coverage html