build-system/pyproject: Add python test-backend.

* guix/build/pyproject-build-system(check): Add python test-backend.

This will help in cases where a simple `python -m module args` call has
to be made instead of fully replacing the 'check phase, e.g. unittest
or django. This is never enabled unless #:test-backend 'python is set,
so it doesn't break anything.

As an example, the following snippet...

(arguments
  (list #:phases #~(modify-phases %standard-phases
                     (replace 'check
                       (lambda* (#:key tests? #:allow-other-keys)
                         (when tests?
                           (invoke "python" "-m" "unittest"
                                   "diff_match_patch.tests")))))))

...can be transformed like this:

(arguments
  '(#:test-backend 'python
    #:test-flags (list "-m" "unittest" "diff_match_patch.tests")))

Change-Id: I4919a3e01d64864e3c328609fbcce7df5b3dfe51
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2024-04-20 16:11:00 +02:00 committed by Sharlatan Hellseher
parent 7b65bc85cd
commit e927a071cd
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -175,6 +175,8 @@ builder.build_wheel(sys.argv[3], config_settings=config_settings)"
(if (null? test-flags) (if (null? test-flags)
'("test" "-v") '("test" "-v")
test-flags))) test-flags)))
('python
(apply invoke "python" test-flags))
;; The developer should explicitly disable tests in this case. ;; The developer should explicitly disable tests in this case.
(else (raise (condition (&test-system-not-found)))))) (else (raise (condition (&test-system-not-found))))))
(format #t "test suite not run~%"))) (format #t "test suite not run~%")))