forked from nipunn1313/mypy-protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_test.sh
executable file
·58 lines (50 loc) · 1.92 KB
/
run_test.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
#!/bin/bash -ex
PY_VERSION=`python -c 'import sys; print(sys.version.split()[0])'`
VENV=venv_$PY_VERSION
MYPY_VENV=venv_mypy
RED="\033[0;31m"
NC='\033[0m'
(
# Create virtualenv + Install requirements for mypy-protobuf
if [[ -z $SKIP_CLEAN ]] || [[ ! -e $VENV ]]; then
python -m virtualenv $VENV
fi
source $VENV/bin/activate
python -m pip install python/ -r requirements.txt
# Generate protos
protoc --version
protoc --mypy_out=generated --proto_path=proto/ `find proto/ -name "*.proto"`
protoc --python_out=generated --proto_path=proto/ `find proto/testproto -name "*.proto"`
)
(
# Run mypy (always under python3)
# Create virtualenv
if [[ -z $SKIP_CLEAN ]] || [[ ! -e $MYPY_VENV ]]; then
python3 --version
python3 -m pip --version
python3 -m virtualenv $MYPY_VENV
fi
source $MYPY_VENV/bin/activate
if [[ -z $SKIP_CLEAN ]] || [[ ! -e $MYPY_VENV ]]; then
python3 -m pip install setuptools
python3 -m pip install git+https://github.com/python/[email protected]
fi
# Run mypy
for PY in 2.7 3.5; do
mypy --custom-typeshed-dir=$CUSTOM_TYPESHED_DIR --python-version=$PY python/mypy_protobuf.py test/ generated/
if ! diff <(mypy --custom-typeshed-dir=$CUSTOM_TYPESHED_DIR --python-version=$PY python/mypy_protobuf.py test_negative/ generated/) test_negative/output.expected.$PY; then
echo -e "${RED}test_negative/output.expected.$PY didnt match. Copying over for you. Now rerun${NC}"
for PY in 2.7 3.5; do
mypy --custom-typeshed-dir=$CUSTOM_TYPESHED_DIR --python-version=$PY python/mypy_protobuf.py test_negative/ generated/ > test_negative/output.expected.$PY || true
done
exit 1
fi
done
)
(
# Run unit tests. These tests generate .expected files
source $VENV/bin/activate
python --version
py.test --version
py.test --ignore=test/proto
)