Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] python-utils-r1.eclass: Handle deselect/ignore in epytest
Date: Wed, 11 Aug 2021 07:49:56
Message-Id: 20210811074943.227213-1-mgorny@gentoo.org
1 It is a de-facto standard to use deselect=() and/or ignore=() arrays
2 to pass arguments to epytest. Let's make the function take them
3 automatically without requiring unsafe hacks such as:
4
5 epytest ${deselect[@]/#/--deselect }
6
7 Signed-off-by: Michał Górny <mgorny@g.o>
8 ---
9 eclass/python-utils-r1.eclass | 11 +++++++++++
10 1 file changed, 11 insertions(+)
11
12 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
13 index b104b6694ac3..04b82d4f7a78 100644
14 --- a/eclass/python-utils-r1.eclass
15 +++ b/eclass/python-utils-r1.eclass
16 @@ -1250,6 +1250,10 @@ build_sphinx() {
17 # Run pytest, passing the standard set of pytest options, followed
18 # by user-specified options.
19 #
20 +# If 'deselect' array is present in the calling scope, all its elements
21 +# are added as --deselect arguments to pytest. If 'ignore' array
22 +# is present, its elements are added as --ignore arguments.
23 +#
24 # This command dies on failure and respects nonfatal.
25 epytest() {
26 debug-print-function ${FUNCNAME} "${@}"
27 @@ -1268,6 +1272,13 @@ epytest() {
28 # for end users, as it tends to fail on new warnings from deps
29 -Wdefault
30 )
31 + local x
32 + for x in "${deselect[@]}"; do
33 + args+=( --deselect "${x}" )
34 + done
35 + for x in "${ignore[@]}"; do
36 + args+=( --ignore "${x}" )
37 + done
38 set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}"
39
40 echo "${@}" >&2
41 --
42 2.32.0

Replies