1 |
Add a convenience --install option to distutils_enable_tests to call |
2 |
distutils_install_for_testing. |
3 |
|
4 |
Signed-off-by: Michał Górny <mgorny@g.o> |
5 |
--- |
6 |
eclass/distutils-r1.eclass | 74 +++++++++++++++++++++++++++++--------- |
7 |
1 file changed, 58 insertions(+), 16 deletions(-) |
8 |
|
9 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
10 |
index 9e862a949275..24fcf13b74d7 100644 |
11 |
--- a/eclass/distutils-r1.eclass |
12 |
+++ b/eclass/distutils-r1.eclass |
13 |
@@ -378,7 +378,7 @@ distutils_enable_sphinx() { |
14 |
} |
15 |
|
16 |
# @FUNCTION: distutils_enable_tests |
17 |
-# @USAGE: <test-runner> |
18 |
+# @USAGE: [--install] <test-runner> |
19 |
# @DESCRIPTION: |
20 |
# Set up IUSE, RESTRICT, BDEPEND and python_test() for running tests |
21 |
# with the specified test runner. Also copies the current value |
22 |
@@ -389,6 +389,10 @@ distutils_enable_sphinx() { |
23 |
# - setup.py: setup.py test (no deps included) |
24 |
# - unittest: for built-in Python unittest module |
25 |
# |
26 |
+# Additionally ,if --install is passed as the first parameter, |
27 |
+# 'distutils_install_for_testing --via-root' is called before running |
28 |
+# the test suite. |
29 |
+# |
30 |
# This function is meant as a helper for common use cases, and it only |
31 |
# takes care of basic setup. You still need to list additional test |
32 |
# dependencies manually. If you have uncommon use case, you should |
33 |
@@ -398,33 +402,71 @@ distutils_enable_sphinx() { |
34 |
# declared. Take care not to overwrite the variables set by it. |
35 |
distutils_enable_tests() { |
36 |
debug-print-function ${FUNCNAME} "${@}" |
37 |
- [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner" |
38 |
|
39 |
+ local do_install= |
40 |
+ case ${1} in |
41 |
+ --install) |
42 |
+ do_install=1 |
43 |
+ shift |
44 |
+ ;; |
45 |
+ esac |
46 |
+ |
47 |
+ [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner" |
48 |
local test_pkg |
49 |
case ${1} in |
50 |
nose) |
51 |
test_pkg=">=dev-python/nose-1.3.7-r4" |
52 |
- python_test() { |
53 |
- nosetests -v || die "Tests fail with ${EPYTHON}" |
54 |
- } |
55 |
+ if [[ ${do_install} ]]; then |
56 |
+ python_test() { |
57 |
+ distutils_install_for_testing --via-root |
58 |
+ nosetests -v || die "Tests fail with ${EPYTHON}" |
59 |
+ } |
60 |
+ else |
61 |
+ python_test() { |
62 |
+ nosetests -v || die "Tests fail with ${EPYTHON}" |
63 |
+ } |
64 |
+ fi |
65 |
;; |
66 |
pytest) |
67 |
test_pkg=">=dev-python/pytest-4.5.0" |
68 |
- python_test() { |
69 |
- pytest -vv || die "Tests fail with ${EPYTHON}" |
70 |
- } |
71 |
+ if [[ ${do_install} ]]; then |
72 |
+ python_test() { |
73 |
+ distutils_install_for_testing --via-root |
74 |
+ pytest -vv || die "Tests fail with ${EPYTHON}" |
75 |
+ } |
76 |
+ else |
77 |
+ python_test() { |
78 |
+ pytest -vv || die "Tests fail with ${EPYTHON}" |
79 |
+ } |
80 |
+ fi |
81 |
;; |
82 |
setup.py) |
83 |
- python_test() { |
84 |
- nonfatal esetup.py test --verbose || |
85 |
- die "Tests fail with ${EPYTHON}" |
86 |
- } |
87 |
+ if [[ ${do_install} ]]; then |
88 |
+ python_test() { |
89 |
+ distutils_install_for_testing --via-root |
90 |
+ nonfatal esetup.py test --verbose || |
91 |
+ die "Tests fail with ${EPYTHON}" |
92 |
+ } |
93 |
+ else |
94 |
+ python_test() { |
95 |
+ nonfatal esetup.py test --verbose || |
96 |
+ die "Tests fail with ${EPYTHON}" |
97 |
+ } |
98 |
+ fi |
99 |
;; |
100 |
unittest) |
101 |
- python_test() { |
102 |
- "${EPYTHON}" -m unittest discover -v || |
103 |
- die "Tests fail with ${EPYTHON}" |
104 |
- } |
105 |
+ if [[ ${do_install} ]]; then |
106 |
+ python_test() { |
107 |
+ distutils_install_for_testing --via-root |
108 |
+ "${EPYTHON}" -m unittest discover -v || |
109 |
+ die "Tests fail with ${EPYTHON}" |
110 |
+ } |
111 |
+ else |
112 |
+ python_test() { |
113 |
+ "${EPYTHON}" -m unittest discover -v || |
114 |
+ die "Tests fail with ${EPYTHON}" |
115 |
+ } |
116 |
+ fi |
117 |
;; |
118 |
*) |
119 |
die "${FUNCNAME}: unsupported argument: ${1}" |
120 |
-- |
121 |
2.29.2 |