1 |
Streamline the python-utils-r1.eclass tests to use a for loop instead |
2 |
of copying the same tests over and over again. While at it, group tests |
3 |
by purpose. |
4 |
|
5 |
Signed-off-by: Michał Górny <mgorny@g.o> |
6 |
--- |
7 |
eclass/tests/python-utils-r1.sh | 112 ++++++++------------------------ |
8 |
1 file changed, 28 insertions(+), 84 deletions(-) |
9 |
|
10 |
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh |
11 |
index e0fc0aab3c03..d971c524b373 100755 |
12 |
--- a/eclass/tests/python-utils-r1.sh |
13 |
+++ b/eclass/tests/python-utils-r1.sh |
14 |
@@ -64,6 +64,8 @@ tmpfile=$(mktemp) |
15 |
|
16 |
inherit python-utils-r1 |
17 |
|
18 |
+ebegin "Testing python2.7" |
19 |
+eindent |
20 |
test_var EPYTHON python2_7 python2.7 |
21 |
test_var PYTHON python2_7 /usr/bin/python2.7 |
22 |
if [[ -x /usr/bin/python2.7 ]]; then |
23 |
@@ -76,91 +78,29 @@ if [[ -x /usr/bin/python2.7 ]]; then |
24 |
fi |
25 |
test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7' |
26 |
test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 |
27 |
+eoutdent |
28 |
|
29 |
-test_var EPYTHON python3_6 python3.6 |
30 |
-test_var PYTHON python3_6 /usr/bin/python3.6 |
31 |
-if [[ -x /usr/bin/python3.6 ]]; then |
32 |
- abiflags=$(/usr/bin/python3.6 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
33 |
- test_var PYTHON_SITEDIR python3_6 "/usr/lib*/python3.6/site-packages" |
34 |
- test_var PYTHON_INCLUDEDIR python3_6 "/usr/include/python3.6${abiflags}" |
35 |
- test_var PYTHON_LIBPATH python3_6 "/usr/lib*/libpython3.6${abiflags}$(get_libname)" |
36 |
- test_var PYTHON_CONFIG python3_6 "/usr/bin/python3.6${abiflags}-config" |
37 |
- test_var PYTHON_CFLAGS python3_6 "*-I/usr/include/python3.6*" |
38 |
- test_var PYTHON_LIBS python3_6 "*-lpython3.6*" |
39 |
-fi |
40 |
-test_var PYTHON_PKG_DEP python3_6 '*dev-lang/python*:3.6' |
41 |
-test_var PYTHON_SCRIPTDIR python3_6 /usr/lib/python-exec/python3.6 |
42 |
- |
43 |
-test_var EPYTHON python3_7 python3.7 |
44 |
-test_var PYTHON python3_7 /usr/bin/python3.7 |
45 |
-if [[ -x /usr/bin/python3.7 ]]; then |
46 |
- abiflags=$(/usr/bin/python3.7 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
47 |
- test_var PYTHON_SITEDIR python3_7 "/usr/lib/python3.7/site-packages" |
48 |
- test_var PYTHON_INCLUDEDIR python3_7 "/usr/include/python3.7${abiflags}" |
49 |
- test_var PYTHON_LIBPATH python3_7 "/usr/lib*/libpython3.7${abiflags}$(get_libname)" |
50 |
- test_var PYTHON_CONFIG python3_7 "/usr/bin/python3.7${abiflags}-config" |
51 |
- test_var PYTHON_CFLAGS python3_7 "*-I/usr/include/python3.7*" |
52 |
- test_var PYTHON_LIBS python3_7 "*-lpython3.7*" |
53 |
-fi |
54 |
-test_var PYTHON_PKG_DEP python3_7 '*dev-lang/python*:3.7' |
55 |
-test_var PYTHON_SCRIPTDIR python3_7 /usr/lib/python-exec/python3.7 |
56 |
- |
57 |
-test_var EPYTHON python3_8 python3.8 |
58 |
-test_var PYTHON python3_8 /usr/bin/python3.8 |
59 |
-if [[ -x /usr/bin/python3.8 ]]; then |
60 |
- abiflags=$(/usr/bin/python3.8 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
61 |
- test_var PYTHON_SITEDIR python3_8 "/usr/lib/python3.8/site-packages" |
62 |
- test_var PYTHON_INCLUDEDIR python3_8 "/usr/include/python3.8${abiflags}" |
63 |
- test_var PYTHON_LIBPATH python3_8 "/usr/lib*/libpython3.8${abiflags}$(get_libname)" |
64 |
- test_var PYTHON_CONFIG python3_8 "/usr/bin/python3.8${abiflags}-config" |
65 |
- test_var PYTHON_CFLAGS python3_8 "*-I/usr/include/python3.8*" |
66 |
- test_var PYTHON_LIBS python3_8 "*-lpython3.8*" |
67 |
-fi |
68 |
-test_var PYTHON_PKG_DEP python3_8 '*dev-lang/python*:3.8' |
69 |
-test_var PYTHON_SCRIPTDIR python3_8 /usr/lib/python-exec/python3.8 |
70 |
- |
71 |
-test_var EPYTHON python3_9 python3.9 |
72 |
-test_var PYTHON python3_9 /usr/bin/python3.9 |
73 |
-if [[ -x /usr/bin/python3.9 ]]; then |
74 |
- abiflags=$(/usr/bin/python3.9 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
75 |
- test_var PYTHON_SITEDIR python3_9 "/usr/lib/python3.9/site-packages" |
76 |
- test_var PYTHON_INCLUDEDIR python3_9 "/usr/include/python3.9${abiflags}" |
77 |
- test_var PYTHON_LIBPATH python3_9 "/usr/lib*/libpython3.9${abiflags}$(get_libname)" |
78 |
- test_var PYTHON_CONFIG python3_9 "/usr/bin/python3.9${abiflags}-config" |
79 |
- test_var PYTHON_CFLAGS python3_9 "*-I/usr/include/python3.9*" |
80 |
- test_var PYTHON_LIBS python3_9 "*-lpython3.9*" |
81 |
-fi |
82 |
-test_var PYTHON_PKG_DEP python3_9 '*dev-lang/python*:3.9' |
83 |
-test_var PYTHON_SCRIPTDIR python3_9 /usr/lib/python-exec/python3.9 |
84 |
- |
85 |
-test_var EPYTHON python3_10 python3.10 |
86 |
-test_var PYTHON python3_10 /usr/bin/python3.10 |
87 |
-if [[ -x /usr/bin/python3.10 ]]; then |
88 |
- abiflags=$(/usr/bin/python3.10 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
89 |
- test_var PYTHON_SITEDIR python3_10 "/usr/lib/python3.10/site-packages" |
90 |
- test_var PYTHON_INCLUDEDIR python3_10 "/usr/include/python3.10${abiflags}" |
91 |
- test_var PYTHON_LIBPATH python3_10 "/usr/lib*/libpython3.10${abiflags}$(get_libname)" |
92 |
- test_var PYTHON_CONFIG python3_10 "/usr/bin/python3.10${abiflags}-config" |
93 |
- test_var PYTHON_CFLAGS python3_10 "*-I/usr/include/python3.10*" |
94 |
- test_var PYTHON_LIBS python3_10 "*-lpython3.10*" |
95 |
-fi |
96 |
-test_var PYTHON_PKG_DEP python3_10 '*dev-lang/python*:3.10' |
97 |
-test_var PYTHON_SCRIPTDIR python3_10 /usr/lib/python-exec/python3.10 |
98 |
- |
99 |
-test_var EPYTHON python3_11 python3.11 |
100 |
-test_var PYTHON python3_11 /usr/bin/python3.11 |
101 |
-if [[ -x /usr/bin/python3.11 ]]; then |
102 |
- abiflags=$(/usr/bin/python3.11 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
103 |
- test_var PYTHON_SITEDIR python3_11 "/usr/lib/python3.11/site-packages" |
104 |
- test_var PYTHON_INCLUDEDIR python3_11 "/usr/include/python3.11${abiflags}" |
105 |
- test_var PYTHON_LIBPATH python3_11 "/usr/lib*/libpython3.11${abiflags}$(get_libname)" |
106 |
- test_var PYTHON_CONFIG python3_11 "/usr/bin/python3.11${abiflags}-config" |
107 |
- test_var PYTHON_CFLAGS python3_11 "*-I/usr/include/python3.11*" |
108 |
- test_var PYTHON_LIBS python3_11 "*-lpython3.11*" |
109 |
-fi |
110 |
-test_var PYTHON_PKG_DEP python3_11 '*dev-lang/python*:3.11' |
111 |
-test_var PYTHON_SCRIPTDIR python3_11 /usr/lib/python-exec/python3.11 |
112 |
+for minor in 6 7 8 9 10 11; do |
113 |
+ ebegin "Testing python3.${minor}" |
114 |
+ eindent |
115 |
+ test_var EPYTHON "python3_${minor}" "python3.${minor}" |
116 |
+ test_var PYTHON "python3_${minor}" "/usr/bin/python3.${minor}" |
117 |
+ if [[ -x /usr/bin/python3.${minor} ]]; then |
118 |
+ abiflags=$(/usr/bin/python3.${minor} -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') |
119 |
+ test_var PYTHON_SITEDIR "python3_${minor}" "/usr/lib*/python3.${minor}/site-packages" |
120 |
+ test_var PYTHON_INCLUDEDIR "python3_${minor}" "/usr/include/python3.${minor}${abiflags}" |
121 |
+ test_var PYTHON_LIBPATH "python3_${minor}" "/usr/lib*/libpython3.${minor}${abiflags}$(get_libname)" |
122 |
+ test_var PYTHON_CONFIG "python3_${minor}" "/usr/bin/python3.${minor}${abiflags}-config" |
123 |
+ test_var PYTHON_CFLAGS "python3_${minor}" "*-I/usr/include/python3.${minor}*" |
124 |
+ test_var PYTHON_LIBS "python3_${minor}" "*-lpython3.${minor}*" |
125 |
+ fi |
126 |
+ test_var PYTHON_PKG_DEP "python3_${minor}" "*dev-lang/python*:3.${minor}" |
127 |
+ test_var PYTHON_SCRIPTDIR "python3_${minor}" "/usr/lib/python-exec/python3.${minor}" |
128 |
+ eoutdent |
129 |
+done |
130 |
|
131 |
+ebegin "Testing pypy3" |
132 |
+eindent |
133 |
test_var EPYTHON pypy3 pypy3 |
134 |
test_var PYTHON pypy3 /usr/bin/pypy3 |
135 |
if [[ -x /usr/bin/pypy3 ]]; then |
136 |
@@ -169,9 +109,10 @@ if [[ -x /usr/bin/pypy3 ]]; then |
137 |
fi |
138 |
test_var PYTHON_PKG_DEP pypy3 '*dev-python/pypy3*:0=' |
139 |
test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3 |
140 |
+eoutdent |
141 |
|
142 |
for EPREFIX in '' /foo; do |
143 |
- einfo "with EPREFIX=${EPREFIX@Q}" |
144 |
+ einfo "Testing python_fix_shebang with EPREFIX=${EPREFIX@Q}" |
145 |
eindent |
146 |
# generic shebangs |
147 |
test_fix_shebang '#!/usr/bin/python' python3.6 \ |
148 |
@@ -226,6 +167,8 @@ for EPREFIX in '' /foo; do |
149 |
done |
150 |
|
151 |
# check _python_impl_matches behavior |
152 |
+einfo "Testing python_impl_matches" |
153 |
+eindent |
154 |
test_is "_python_impl_matches python3_6 -3" 0 |
155 |
test_is "_python_impl_matches python3_7 -3" 0 |
156 |
test_is "_python_impl_matches pypy3 -3" 0 |
157 |
@@ -246,6 +189,7 @@ test_is "_python_impl_matches python3_9 3.10" 1 |
158 |
test_is "_python_impl_matches pypy3 3.8" 1 |
159 |
test_is "_python_impl_matches pypy3 3.9" 0 |
160 |
test_is "_python_impl_matches pypy3 3.10" 1 |
161 |
+eoutdent |
162 |
|
163 |
rm "${tmpfile}" |
164 |
|
165 |
-- |
166 |
2.35.1 |