In the very rare cases where our plugin actually breaks a test, adding
a flag is more convenient than replacing the phase.
* guix/build-system/pyproject.scm (pyproject-build): Add option
use-pytest-plugin?
* guix/build/pyproject-build-system.scm (check): Add and use option
use-pytest-plugin?
* gnu/packages/check.scm (python-coverage,
python-pytest-mypy)[arguments]{use-pytest-plugin}: Set to #f to fix
tests.
* gnu/packages/python-check.scm (python-pytest-flake8)[arguments]:
Likewise.
---
gnu/packages/check.scm | 6 +++++-
gnu/packages/python-check.scm | 1 +
guix/build-system/pyproject.scm | 2 ++
guix/build/pyproject-build-system.scm | 9 ++++++---
4 files changed, 14 insertions(+), 4 deletions(-)
@@ -2500,6 +2500,8 @@ (define-public python-coverage
"--deselect=tests/test_filereporter.py::FileReporterTest::test_zipfile"
;; XXX: Checking coverage for too much files, not only the target one.
"--deselect=tests/test_oddball.py::DoctestTest::test_doctest")
+ ;; This is one of the rare cases where our plugin causes a test to fail.
+ #:use-pytest-plugin? #f
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'patch-pyproject
@@ -2997,7 +2999,9 @@ (define-public python-pytest-mypy
(build-system pyproject-build-system)
(arguments
(list
- #:test-flags #~(list "--numprocesses" "auto")))
+ #:use-pytest-plugin? #f
+ #:test-flags #~(list "--numprocesses"
+ (number->string (parallel-job-count)))))
(native-inputs
(list python-pexpect
python-pytest-xdist
@@ -1704,6 +1704,7 @@ (define-public python-pytest-flake8
(base32
"1rhz7mxcg7x9dbabfcjai3zxikfgw7az07m4ddf92bg35ib3byw8"))))
(build-system pyproject-build-system)
+ (arguments (list #:use-pytest-plugin? #f))
(native-inputs
(list python-pytest
python-setuptools
@@ -93,6 +93,7 @@ (define private-keywords
(define* (pyproject-build name inputs
#:key source
(tests? #t)
+ (use-pytest-plugin? #t)
(configure-flags ''(@))
(backend-path #f)
(build-backend #f)
@@ -125,6 +126,7 @@ (define build
#:test-backend #$test-backend
#:test-flags #$test-flags
#:tests? #$tests?
+ #:use-pytest-plugin? #$use-pytest-plugin?
#:phases #$(if (pair? phases)
(sexp->gexp phases)
phases)
@@ -231,7 +231,8 @@ (define-syntax-rule (with-guix-pytest-plugin inputs exp ...)
"Evaluate EXP in a context where the Guix pytest plugin is added."
(call-with-guix-pytest-plugin inputs (lambda () exp ...)))
-(define* (check #:key inputs tests? test-backend test-flags #:allow-other-keys)
+(define* (check #:key inputs tests? test-backend test-flags use-pytest-plugin?
+ #:allow-other-keys)
"Run the test suite of a given Python package."
(if tests?
;; Unfortunately with PEP 517 there is no common method to specify test
@@ -254,8 +255,10 @@ (define* (check #:key inputs tests? test-backend test-flags #:allow-other-keys)
(format #t "Using ~a~%" use-test-backend)
(match use-test-backend
('pytest
- (with-guix-pytest-plugin inputs
- (apply invoke pytest "-vv" test-flags)))
+ (if use-pytest-plugin?
+ (with-guix-pytest-plugin inputs
+ (apply invoke pytest "-vv" test-flags))
+ (apply invoke pytest "-vv" test-flags)))
('nose
(apply invoke nosetests "-v" test-flags))
('nose2