This repository was archived by the owner on Nov 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruntests.sh
More file actions
executable file
·93 lines (77 loc) · 2.05 KB
/
runtests.sh
File metadata and controls
executable file
·93 lines (77 loc) · 2.05 KB
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
#!/bin/bash
# Help text
usage="
$(basename "$0") [-hcpn] [-v VERSION(S)]
Run pytest for empymod locally in an isolated venv before submitting to
GitHub/Travis-CI; by default for all supported python versions of empymod.
where:
-h : Show this help text.
-v : Python 3.x version, e.g. '-v 5' for Python 3.5. Default: '4 5 6'.
-c : Use channel 'conda-forge' instead of channel 'defaults'.
-p : Print output of conda.
"
# Set default values
CHAN=defaults
PYTHON3VERSION="4 5 6"
PRINT="/dev/null"
PCKGS="numpy scipy pytest pytest-cov"
NMXPR="numexpr matplotlib IPython"
STR2="** WITH numexpr/matplotlib/IPython "
PROPS="--mpl --flake8"
INST="pytest-flake8 pytest-mpl"
# Get Optional Input
while getopts "hv:cpn" opt; do
case $opt in
h) echo "$usage"
exit
;;
v) PYTHON3VERSION=$OPTARG
;;
c) CHAN=conda-forge
;;
p) PRINT="/dev/tty"
;;
n) NMXPR=""
STR2="** NO numexpr/matplotlib/IPython "
PROPS="--flake8"
INST="pytest-flake8"
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
# Loop over Python versions
for i in ${PYTHON3VERSION[@]}; do
# Print info
STR=" PYTHON 3."${i}" ** Channel "$CHAN" $STR2"
LENGTH=$(( ($(tput cols) - ${#STR}) / 2 - 2 ))
printf "\n "
printf '\e[1m\e[34m%*s' "${LENGTH}" '' | tr ' ' -
if [ $((${#STR}%2)) -ne 0 ];
then
printf "-"
fi
printf "${STR}"
printf '%*s\n' "${LENGTH}" '' | tr ' ' -
printf "\e[0m\n"
# Create venv, with channel CHAN
conda create -y -n test_3${i} -c $CHAN python=3.${i} $PCKGS $NMXPR &> $PRINT
# Activate venv
source activate test_3${i}
# Install flake8
pip install $INST &> $PRINT
# Install empymod
conda install -y -c prisae empymod &> $PRINT
# Run tests
pytest --cov=empyscripts $PROPS
# De-activate venv
source deactivate test_3${i}
# Remove venv
conda remove -y -n test_3${i} --all &> $PRINT
done