Skip to content

Commit 092cbff

Browse files
mcasquerpsss
andauthoredMar 11, 2025··
Deduplicate the discover step documentation (#3311)
Currently, the documentation about discover is duplicated in someway between the specification and the plugin section. Adds the missing information into the plugin section as it will be the primary source. Signed-off-by: mcasquer <mcasquer@redhat.com> Co-authored-by: Petr Šplíchal <psplicha@redhat.com>
1 parent aae1fef commit 092cbff

File tree

5 files changed

+117
-178
lines changed

5 files changed

+117
-178
lines changed
 

‎spec/plans/discover.fmf

+3-143
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,6 @@ description: |
5757
within the same discover config, use
5858
:ref:`multiple-configs` instead.
5959

60-
url
61-
Git repository, used directly as a git clone argument.
62-
63-
ref
64-
Branch, tag or commit specifying the desired git
65-
revision. Defaults to the remote repository's default
66-
branch.
67-
68-
keep-git-metadata
69-
By default the ``.git`` directory is removed to save
70-
disk space. Set to ``true`` to sync the git metadata
71-
to guest as well. Implicit if ``dist-git-source`` is
72-
used.
73-
7460
Use the :ref:`/spec/plans/discover/dist-git-source`
7561
options to download rpm sources for dist-git repositories.
7662

@@ -105,108 +91,10 @@ description: |
10591
summary: Discover available tests using the fmf format
10692
description: |
10793
Use the `Flexible Metadata Format`_ to explore all
108-
available tests in given repository. The following
109-
parameters are supported:
110-
111-
url
112-
Git repository containing the metadata tree.
113-
Current git repository used by default.
114-
ref
115-
Branch, tag or commit specifying the desired git
116-
revision. Defaults to the remote repository's default
117-
branch if url given or to the current ``HEAD`` if url
118-
not provided.
119-
120-
Additionally, one can set ``ref`` dynamically. This is
121-
possible using a special file in tmt format stored in
122-
the *default* branch of a tests repository. This special
123-
file should contain rules assigning attribute ``ref``
124-
in an `adjust` block, for example depending on a test
125-
run context.
126-
127-
Dynamic ``ref`` assignment is enabled whenever a test
128-
plan reference has the format ``ref: @FILEPATH``.
129-
path
130-
Path to the metadata tree root. Must be relative to
131-
the git repository root if url provided, absolute
132-
local filesystem path otherwise. By default ``.`` is
133-
used.
134-
135-
See also the `fmf identifier`_ documentation for details.
136-
Use the following keys to limit the test discovery by test
137-
name, an advanced filter or link:
138-
139-
test
140-
List of test names or regular expressions used to
141-
select tests by name. Duplicate test names are allowed
142-
to enable repetitive test execution, preserving the
143-
listed test order.
144-
link
145-
Select tests using the :ref:`/spec/core/link` keys.
146-
Values must be in the form of ``RELATION:TARGET``,
147-
tests containing at least one of them are selected.
148-
Regular expressions are supported for both relation
149-
and target. Relation part can be omitted to match all
150-
relations.
151-
filter
152-
Apply advanced filter based on test metadata
153-
attributes. See ``pydoc fmf.filter`` for more info.
154-
exclude
155-
Exclude tests which match a regular expression.
156-
prune
157-
Copy only immediate directories of executed tests and
158-
their required files.
159-
160-
.. versionadded:: 1.29
161-
162-
It is also possible to limit tests only to those that have
163-
changed in git since a given revision. This can be
164-
particularly useful when testing changes to tests
165-
themselves (e.g. in a pull request CI). Related config
166-
options (all optional) are:
167-
168-
modified-only
169-
Set to ``true`` if you want to filter modified tests
170-
only. The test is modified if its name starts with
171-
the name of any directory modified since modified-ref.
172-
modified-url
173-
An additional remote repository to be used as the
174-
reference for comparison. Will be fetched as a
175-
``reference`` remote in the test dir.
176-
modified-ref
177-
The ref to compare against. Defaults to the local
178-
repository's default branch. Note that you need to
179-
specify ``reference/<branch>`` to compare to a branch
180-
from the repository specified in ``modified-url``.
94+
available tests in given repository.
18195

182-
Use the :ref:`/spec/plans/discover/dist-git-source`
183-
options to download rpm sources for dist-git repositories.
184-
In addition to the common dist-git-source features, the
185-
``fmf`` plugin also supports the following options:
186-
187-
dist-git-init
188-
Set to ``true`` to initialize fmf root inside
189-
extracted sources at ``dist-git-extract`` location or
190-
top directory. To be used when the sources contain fmf
191-
files (for example tests) but do not have an
192-
associated fmf root.
193-
194-
dist-git-remove-fmf-root
195-
Set to ``true`` to remove any fmf root present in the
196-
sources. ``dist-git-init`` can be used to create it
197-
later at desired location.
198-
199-
dist-git-merge
200-
Set to ``true`` to combine fmf root from the sources
201-
and fmf root from the plan. It allows to have plans
202-
and tests defined in the DistGit repo which use tests
203-
and other resources from the downloaded sources. Any
204-
plans in extracted sources will not be processed.
205-
206-
dist-git-extract
207-
Path specifying what should be copied from the
208-
sources. Defaults to top fmf root or top directory
209-
``/``.
96+
See the `fmf identifier`_ and the :ref:`/plugins/discover/fmf`
97+
plugin documentation for more details.
21098

21199
.. _fmf identifier: https://fmf.readthedocs.io/en/latest/concept.html#identifiers
212100
.. _Flexible Metadata Format: https://fmf.readthedocs.io/
@@ -262,34 +150,6 @@ description: |
262150
order ``60``. All created files and directories by this command
263151
are directly in ``TMT_SOURCE_DIR``.
264152

265-
.. versionadded:: 1.32
266-
267-
dist-git-source
268-
Download and (optionally) extract the sources.
269-
270-
dist-git-type
271-
Use the provided DistGit handler instead of the auto
272-
detection. Useful when running from forked
273-
repositories.
274-
275-
dist-git-download-only
276-
When ``true`` sources are just downloaded.
277-
No ``rpmbuild -bp``, nor installation of require
278-
or buildddeps happens.
279-
280-
.. versionadded:: 1.29
281-
282-
dist-git-require
283-
List of packages to install before ``rpmbuild -bp`` is attempted
284-
on the sources. The rpm-build package itself is installed automatically.
285-
286-
.. versionadded:: 1.32
287-
288-
dist-git-install-builddeps
289-
When set to ``true`` build requirements are installed.
290-
291-
.. versionadded:: 1.32
292-
293153
The :ref:`/spec/plans/discover/fmf` plugin supports
294154
additional dist-git options, see its documentation for
295155
details.

‎tmt/steps/discover/__init__.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ class DiscoverStepData(tmt.steps.WhereableStepData, tmt.steps.StepData):
4848
default=None,
4949
option='--dist-git-type',
5050
choices=tmt.utils.get_distgit_handler_names,
51-
help='Use the provided DistGit handler instead of the auto detection.',
51+
help="""
52+
Use the provided DistGit handler instead of the auto detection.
53+
Useful when running from forked repositories.
54+
""",
5255
)
5356

5457
dist_git_download_only: bool = field(
@@ -71,7 +74,10 @@ class DiscoverStepData(tmt.steps.WhereableStepData, tmt.steps.StepData):
7174
option="--dist-git-require",
7275
metavar='PACKAGE',
7376
multiple=True,
74-
help='Additional required package to be present before sources are prepared.',
77+
help="""
78+
Additional required package to be present before sources are prepared.
79+
The ``rpm-build`` package itself is installed automatically.
80+
""",
7581
# *simple* requirements only
7682
normalize=lambda key_address, value, logger: tmt.base.assert_simple_dependencies(
7783
tmt.base.normalize_require(key_address, value, logger),

‎tmt/steps/discover/fmf.py

+83-29
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,43 @@ class DiscoverFmfStepData(tmt.steps.discover.DiscoverStepData):
4444
default=cast(Optional[str], None),
4545
option=('-u', '--url'),
4646
metavar='REPOSITORY',
47-
help='URL of the git repository with fmf metadata.',
47+
help="""
48+
Git repository containing the metadata tree.
49+
Current git repository used by default.
50+
""",
4851
)
52+
4953
ref: Optional[str] = field(
5054
default=cast(Optional[str], None),
5155
option=('-r', '--ref'),
5256
metavar='REVISION',
53-
help='Branch, tag or commit specifying the git revision.',
57+
help="""
58+
Branch, tag or commit specifying the desired git
59+
revision. Defaults to the remote repository's default
60+
branch if ``url`` was set or to the current ``HEAD``
61+
of the current repository.
62+
63+
Additionally, one can set ``ref`` dynamically.
64+
This is possible using a special file in tmt format
65+
stored in the *default* branch of a tests repository.
66+
This special file should contain rules assigning attribute ``ref``
67+
in an *adjust* block, for example depending on a test run context.
68+
69+
Dynamic ``ref`` assignment is enabled whenever a test plan
70+
reference has the format ``ref: @FILEPATH``.
71+
""",
5472
normalize=normalize_ref,
5573
)
74+
5675
path: Optional[str] = field(
5776
default=cast(Optional[str], None),
5877
option=('-p', '--path'),
5978
metavar='ROOT',
60-
help='Path to the metadata tree root.',
79+
help="""
80+
Path to the metadata tree root. Must be relative to
81+
the git repository root if ``url`` was provided, absolute
82+
local filesystem path otherwise. By default ``.`` is used.
83+
""",
6184
)
6285

6386
# Selecting tests
@@ -66,25 +89,39 @@ class DiscoverFmfStepData(tmt.steps.discover.DiscoverStepData):
6689
option=('-t', '--test'),
6790
metavar='NAMES',
6891
multiple=True,
69-
help='Select tests by name.',
92+
help="""
93+
List of test names or regular expressions used to
94+
select tests by name. Duplicate test names are allowed
95+
to enable repetitive test execution, preserving the
96+
listed test order.
97+
""",
7098
normalize=tmt.utils.normalize_string_list,
7199
)
100+
72101
link: list[str] = field(
73102
default_factory=list,
74103
option='--link',
75104
metavar="RELATION:TARGET",
76105
multiple=True,
77106
help="""
78-
Filter by linked objects (regular expressions are supported for both relation and
79-
target).
107+
Select tests using the :ref:`/spec/core/link` keys.
108+
Values must be in the form of ``RELATION:TARGET``,
109+
tests containing at least one of them are selected.
110+
Regular expressions are supported for both relation
111+
and target. Relation part can be omitted to match all
112+
relations.
80113
""",
81114
)
115+
82116
filter: list[str] = field(
83117
default_factory=list,
84118
option=('-F', '--filter'),
85119
metavar='FILTERS',
86120
multiple=True,
87-
help='Include only tests matching the filter.',
121+
help="""
122+
Apply advanced filter based on test metadata attributes.
123+
See ``pydoc fmf.filter`` for more info.
124+
""",
88125
normalize=tmt.utils.normalize_string_list,
89126
)
90127
exclude: list[str] = field(
@@ -101,21 +138,32 @@ class DiscoverFmfStepData(tmt.steps.discover.DiscoverStepData):
101138
default=False,
102139
option=('-m', '--modified-only'),
103140
is_flag=True,
104-
help='If set, select only tests modified since reference revision.',
141+
help="""
142+
Set to ``true`` if you want to filter modified tests
143+
only. The test is modified if its name starts with
144+
the name of any directory modified since ``modified-ref``.
145+
""",
105146
)
147+
106148
modified_url: Optional[str] = field(
107149
default=cast(Optional[str], None),
108150
option='--modified-url',
109151
metavar='REPOSITORY',
110-
help='URL of the reference git repository with fmf metadata.',
152+
help="""
153+
An additional remote repository to be used as the
154+
reference for comparison. Will be fetched as a
155+
reference remote in the test dir.
156+
""",
111157
)
158+
112159
modified_ref: Optional[str] = field(
113160
default=cast(Optional[str], None),
114161
option='--modified-ref',
115162
metavar='REVISION',
116163
help="""
117-
Branch, tag or commit specifying the reference git revision (if not provided, the
118-
default branch is used).
164+
The branch, tag or commit specifying the reference git revision (if not provided, the
165+
default branch is used). Note that you need to specify ``reference/<branch>`` to
166+
compare to a branch from the repository specified in ``modified-url``.
119167
""",
120168
)
121169

@@ -125,7 +173,10 @@ class DiscoverFmfStepData(tmt.steps.discover.DiscoverStepData):
125173
option='--dist-git-init',
126174
is_flag=True,
127175
help="""
128-
Initialize fmf root inside extracted sources (at dist-git-extract or top directory).
176+
Set to ``true`` to initialize fmf root inside extracted sources at
177+
``dist-git-extract`` location or top directory. To be used when the
178+
sources contain fmf files (for example tests) but do not have an
179+
associated fmf root.
129180
""",
130181
)
131182
dist_git_remove_fmf_root: bool = field(
@@ -141,7 +192,12 @@ class DiscoverFmfStepData(tmt.steps.discover.DiscoverStepData):
141192
default=False,
142193
option='--dist-git-merge',
143194
is_flag=True,
144-
help='Merge copied sources and plan fmf root.',
195+
help="""
196+
Set to ``true`` to combine fmf root from the sources and fmf root from the plan.
197+
It allows to have plans and tests defined in the DistGit repo which use tests
198+
and other resources from the downloaded sources. Any plans in extracted sources
199+
will not be processed.
200+
""",
145201
)
146202
dist_git_extract: Optional[str] = field(
147203
default=cast(Optional[str], None),
@@ -234,6 +290,19 @@ class DiscoverFmf(tmt.steps.discover.DiscoverPlugin[DiscoverFmfStepData]):
234290
235291
If no ``ref`` is provided, the default branch from the origin is used.
236292
293+
The following keys are used to limit the test discovery:
294+
295+
``test`` - list of test names or regular expressions used to select tests
296+
297+
``link`` - select tests using the link keys
298+
299+
``filter`` - apply advanced filter based on test metadata attributes
300+
301+
``exclude`` - exclude tests which match a regular expression
302+
303+
``prune`` - copy only immediate directories of executed tests and their required files
304+
305+
237306
For DistGit repo one can download sources and use code from them in
238307
the tests. Sources are extracted into ``$TMT_SOURCE_DIR`` path,
239308
patches are applied by default. See options to install build
@@ -250,17 +319,6 @@ class DiscoverFmf(tmt.steps.discover.DiscoverPlugin[DiscoverFmfStepData]):
250319
how: fmf
251320
dist-git-source: true
252321
253-
Related config options (all optional):
254-
255-
* ``dist-git-merge`` - set to ``true`` if you want to copy in extracted
256-
sources to the local repo
257-
* ``dist-git-init`` - set to ``true`` and ``fmf init`` will be called inside
258-
extracted sources (at ``dist-git-extract`` or top directory)
259-
* ``dist-git-extract`` - directory (glob supported) to copy from
260-
extracted sources (defaults to inner fmf root)
261-
* ``dist-git-remove-fmf-root`` - set to ``true`` to remove fmf root from
262-
extracted sources
263-
264322
Selecting tests containing specified link is possible using ``link``
265323
key accepting ``RELATION:TARGET`` format of values. Regular
266324
expressions are supported for both relation and target part of the
@@ -276,11 +334,7 @@ class DiscoverFmf(tmt.steps.discover.DiscoverPlugin[DiscoverFmfStepData]):
276334
in git since a given revision. This can be particularly useful when
277335
testing changes to tests themselves (e.g. in a pull request CI).
278336
279-
Related config options (all optional):
280-
281-
* ``modified-only`` - set to ``true`` if you want to filter modified tests
282-
* ``modified-url`` - fetched as "reference" remote in the test dir
283-
* ``modified-ref`` - the ref to compare against
337+
Related keys: ``modified-only``, ``modified-url``, ``modified-ref``
284338
285339
Example to compare local repo against upstream ``main`` branch:
286340

‎tmt/steps/discover/shell.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,21 @@ class DiscoverShellData(tmt.steps.discover.DiscoverStepData):
194194
option="--ref",
195195
metavar='REVISION',
196196
default=None,
197-
help="Branch, tag or commit specifying the git revision.",
197+
help="""
198+
Branch, tag or commit specifying the desired git revision.
199+
Defaults to the remote repository's default branch.
200+
""",
198201
)
199202

200203
keep_git_metadata: bool = field(
201204
option="--keep-git-metadata",
202205
is_flag=True,
203206
default=False,
204-
help="Keep the git metadata if a repo is synced to guest.",
207+
help="""
208+
By default the ``.git`` directory is removed to save disk space.
209+
Set to ``true`` to sync the git metadata to guest as well.
210+
Implicit if ``dist-git-source`` is used.
211+
""",
205212
)
206213

207214
def to_spec(self) -> tmt.steps._RawStepData:
@@ -225,8 +232,13 @@ class DiscoverShell(tmt.steps.discover.DiscoverPlugin[DiscoverShellData]):
225232
Use provided list of shell script tests.
226233
227234
List of test cases to be executed can be defined manually directly
228-
in the plan as a list of dictionaries containing test name, actual
229-
test script and optionally a path to the test. Example config:
235+
in the plan as a list of dictionaries containing test ``name`` and
236+
actual ``test`` script. It is also possible to define here any other
237+
test metadata such as the ``duration`` or a ``path`` to the test.
238+
The default duration for tests defined directly in the discover step
239+
is ``1h``.
240+
241+
Example config:
230242
231243
.. code-block:: yaml
232244

‎tmt/utils/rest.py

+7
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def visit_literal(self, node: docutils.nodes.literal) -> None:
201201

202202
depart_literal = _noop_departure
203203

204+
def visit_emphasis(self, node: docutils.nodes.literal) -> None:
205+
self.log_visit(str(node))
206+
207+
self._emit(click.style(node.astext(), fg='yellow'))
208+
209+
depart_emphasis = _noop_departure
210+
204211
def visit_literal_block(self, node: docutils.nodes.literal_block) -> None:
205212
self.log_visit(str(node))
206213

0 commit comments

Comments
 (0)
Please sign in to comment.