forked from django-money/django-money
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgen_tox.bash
executable file
·192 lines (141 loc) · 3.18 KB
/
gen_tox.bash
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bash
# ############################################################################
#
# Generator configuration for the "tox"
#
# ############################################################################
# <id>:<version>
PYTHON_DICT=( "py26:python2.6"
"py27:python2.7"
"py32:python3.2"
"py33:python3.3"
"pypy:pypy" )
# <id>:<version>
DJANGO_DICT=( "django14:1.4.x"
"django15:1.5.x"
"django16:1.6.x"
"djangolatest:latest" )
# <id>:<version>
PYMONEYED_DICT=( "pm04:0.4"
"pm05:0.5"
"pmlatest:latest" )
# condition[<id> <id> ...]: skip[<id> <id> ...]
TOX_SKIP_CONDITIONS=( "pm04: py32 py33"
"py33 py32: django14")
function test_conditions() {
for condition_item in "${TOX_SKIP_CONDITIONS[@]}"
do
for condition in ${condition_item%%:*}
do
for skip in ${condition_item##*:}
do
for var in "$@"
do
if [ "$condition" == "$var" ]
then
for vars in "$@"
do
if [ "$skip" == "$vars" ]
then
echo "Condition '$condition' skip '$skip'"
return
fi
done
fi
done
done
done
done
}
function get_tox() {
cat <<EOF
[tox]
envlist =
EOF
for python_item in "${PYTHON_DICT[@]}"
do
python_id="${python_item%%:*}"
python_ver="${python_item##*:}"
for django_item in "${DJANGO_DICT[@]}"
do
django_id="${django_item%%:*}"
django_ver="${django_item##*:}"
for pymoneyed_item in "${PYMONEYED_DICT[@]}"
do
pymoneyed_id="${pymoneyed_item%%:*}"
pymoneyed_ver="${pymoneyed_item##*:}"
if [ "$(test_conditions $python_id $django_id $pymoneyed_id)" ]
then
continue
fi
echo " $python_id-$django_id-$pymoneyed_id,"
done
done
done
}
function get_config() {
cat <<EOF
[testenv]
commands=
{envpython} runtests.py {posargs}
deps=
pytest-django>=2.3.0
south>=0.8.2
django-reversion
[django]
1.4.x = Django>=1.4,<1.5
1.5.x = Django>=1.5,<1.6
1.6.x = Django>=1.6,<1.7
latest = https://github.com/django/django/tarball/master
[pymoneyed]
0.4 = py-moneyed>=0.4,<0.5
0.5 = py-moneyed>=0.5,<0.6
latest = https://github.com/limist/py-moneyed/archive/master.zip
EOF
}
function gen_testenv() {
PYTHON_ID=$1
PYTHON_VER=$2
DJANGO_ID=$3
DJANGO_VER=$4
PYMONEYED_ID=$5
PYMONEYED_VER=$6
cat <<EOF
[testenv:$PYTHON_ID-$DJANGO_ID-$PYMONEYED_ID]
basepython=$PYTHON_VER
deps=
{[django]$DJANGO_VER}
{[pymoneyed]$PYMONEYED_VER}
{[testenv]deps}
EOF
}
get_tox
get_config
for python_item in "${PYTHON_DICT[@]}"
do
python_id="${python_item%%:*}"
python_ver="${python_item##*:}"
cat <<EOF
# ############################################################################
# Python $python_ver
# ############################################################################
EOF
for django_item in "${DJANGO_DICT[@]}"
do
django_id="${django_item%%:*}"
django_ver="${django_item##*:}"
cat <<EOF
###### django $django_ver
EOF
for pymoneyed_item in "${PYMONEYED_DICT[@]}"
do
pymoneyed_id="${pymoneyed_item%%:*}"
pymoneyed_ver="${pymoneyed_item##*:}"
if [ "$(test_conditions $python_id $django_id $pymoneyed_id)" ]
then
continue
fi
gen_testenv "$python_id" "$python_ver" "$django_id" "$django_ver" "$pymoneyed_id" "$pymoneyed_ver"
done
done
done