diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2025-06-19 09:58:48 +0200 |
|---|---|---|
| committer | Sharlatan Hellseher <sharlatanus@gmail.com> | 2025-09-25 09:35:34 +0100 |
| commit | 9a40c5145d6b4db3cb28b6814ca6bf0a560fa41a (patch) | |
| tree | 54a03dd40160dac323f9c5983eaf47bb1c0885d0 | |
| parent | 74a1e9d5437371d7eba0da8ead27e289ad966cba (diff) | |
build-system/pyproject: Add stestr, unittest and custom options.
* guix/build-system/pyproject.scm (check): Add stestr, unittest and
custom test-backends.
Change-Id: I2d44b3b8dd928ab844b4479fb073afff845e13ee
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
| -rw-r--r-- | guix/build/pyproject-build-system.scm | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/guix/build/pyproject-build-system.scm b/guix/build/pyproject-build-system.scm index 1b66dce99c3..1fa610faa98 100644 --- a/guix/build/pyproject-build-system.scm +++ b/guix/build/pyproject-build-system.scm @@ -150,18 +150,26 @@ builder.build_wheel(sys.argv[3], config_settings=config_settings)" (let* ((pytest (which "pytest")) (nosetests (which "nosetests")) (nose2 (which "nose2")) + (stestr (which "stestr")) (have-setup-py (file-exists? "setup.py")) + ;; unittest default pattern + ;; See https://docs.python.org/3/library/unittest.html\ + ;; #cmdoption-unittest-discover-p + (tests-found (find-files "." "test.*\\.py$")) (use-test-backend (or test-backend ;; Prefer pytest (if pytest 'pytest #f) + (if stestr 'stestr #f) (if nosetests 'nose #f) (if nose2 'nose2 #f) - ;; But fall back to setup.py, which should work for most - ;; packages. XXX: would be nice not to depend on setup.py here? - ;; fails more often than not to find any tests at all. Maybe - ;; we can run `python -m unittest`? - (if have-setup-py 'setup.py #f)))) + ;; Fall back to setup.py. The command is deprecated, but is + ;; a superset of unittest, so should work for most packages. + ;; Keep it until setuptools removes `setup.py test'. + ;; See https://setuptools.pypa.io/en/latest/deprecated/\ + ;; commands.html#test-build-package-and-run-a-unittest-suite + (if have-setup-py 'setup.py #f) + (if tests-found 'unittest #f)))) (format #t "Using ~a~%" use-test-backend) (match use-test-backend ('pytest @@ -175,7 +183,11 @@ builder.build_wheel(sys.argv[3], config_settings=config_settings)" (if (null? test-flags) '("test" "-v") test-flags))) - ('python + ('stestr + (apply invoke stestr "run" test-flags)) + ('unittest + (apply invoke "python" "-m" "unittest" test-flags)) + ('custom (apply invoke "python" test-flags)) ;; The developer should explicitly disable tests in this case. (else (raise (condition (&test-system-not-found)))))) |
