]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
doc: pytest: Framework for documenting tests and document test_000_version
authorTom Rini <trini@konsulko.com>
Wed, 7 May 2025 22:08:18 +0000 (16:08 -0600)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 11 May 2025 10:52:56 +0000 (12:52 +0200)
In order to easily document pytests, we need to include the autodoc
extension. We also need to make sure that for building the docs, CI
includes pytest and that we have PYTHONPATH configured such that it will
find all of the tests and related files. Finally, we need to have our
comments in the test file by in proper pydoc format in order to be
included in the output.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
.azure-pipelines.yml
.gitlab-ci.yml
Makefile
doc/conf.py
doc/develop/pytest/index.rst
doc/develop/pytest/test_000_version.rst [new file with mode: 0644]
test/py/tests/test_000_version.py

index 5e1938b05262d05bc5e50e7ea6d8f0092b72330c..9c136513bb9e52d1327e17bc7ab46f303fb080e3 100644 (file)
@@ -92,7 +92,7 @@ stages:
           set -e
           python3 -m venv /tmp/venvhtml
           . /tmp/venvhtml/bin/activate
-          pip install -r doc/sphinx/requirements.txt
+          pip install -r doc/sphinx/requirements.txt pytest
           make htmldocs KDOC_WERROR=1
           make infodocs
 
index 6f11331514b8d3271db61ec06f2b9a9ed4e0e960..7aadd5d8b7355ab79451faa4ef9ec307059250c3 100644 (file)
@@ -164,7 +164,7 @@ docs:
   script:
     - python3 -m venv /tmp/venvhtml
     - . /tmp/venvhtml/bin/activate
-    - pip install -r doc/sphinx/requirements.txt
+    - pip install -r doc/sphinx/requirements.txt pytest
     - make htmldocs KDOC_WERROR=1
     - make infodocs
 
index 15c7e633b8749ccd9f26bd0370d6da678b4522fc..bd136a48982aa5caba9eddaead83bf251f1bb2fd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2448,7 +2448,8 @@ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
               linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
 PHONY += $(DOC_TARGETS)
 $(DOC_TARGETS): scripts_basic FORCE
-       $(Q)$(MAKE) $(build)=doc $@
+       $(Q)PYTHONPATH=$(srctree)/test/py/tests:$(srctree)/test/py \
+       $(MAKE) $(build)=doc $@
 
 PHONY += checkstack ubootrelease ubootversion
 
index 3cb9b2bb65e59c7081409a7c386c67c29a709223..84d028feda83d49eb2cc18460d04498997b778df 100644 (file)
@@ -48,7 +48,7 @@ extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
               'kfigure', 'sphinx.ext.ifconfig', # 'automarkup',
               'maintainers_include', 'sphinx.ext.autosectionlabel',
               'kernel_abi', 'kernel_feat', 'sphinx-prompt',
-              'sphinx_reredirects' ]
+              'sphinx_reredirects', 'sphinx.ext.autodoc' ]
 
 #
 # cdomain is badly broken in Sphinx 3+.  Leaving it out generates *most*
index 435d84fc619f5112d38132685e9afffcaad2d6ab..ca45e157d3beb44e70e26090cea3d89ee176bab2 100644 (file)
@@ -10,3 +10,11 @@ General
    :maxdepth: 1
 
    usage
+
+Individual tests
+----------------
+
+.. toctree::
+   :maxdepth: 1
+
+   test_000_version
diff --git a/doc/develop/pytest/test_000_version.rst b/doc/develop/pytest/test_000_version.rst
new file mode 100644 (file)
index 0000000..09e9a36
--- /dev/null
@@ -0,0 +1,8 @@
+test_000_version
+================
+
+.. automodule:: test_000_version
+   :synopsis:
+   :member-order: bysource
+   :members:
+   :undoc-members:
index b95ceae23465b8595aff82663dbfb1941fe758c6..63d392e956e05ef739e7aa13a0e65b028bd8a378 100644 (file)
@@ -2,10 +2,12 @@
 # Copyright (c) 2015 Stephen Warren
 # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 
-# pytest runs tests the order of their module path, which is related to the
-# filename containing the test. This file is named such that it is sorted
-# first, simply as a very basic sanity check of the functionality of the U-Boot
-# command prompt.
+"""
+pytest runs tests the order of their module path, which is related to the
+filename containing the test. This file is named such that it is sorted
+first, simply as a very basic sanity check of the functionality of the U-Boot
+command prompt.
+"""
 
 def test_version(ubman):
     """Test that the "version" command prints the U-Boot version."""