tmt.steps.discover package

Submodules

tmt.steps.discover.fmf module

class tmt.steps.discover.fmf.DiscoverFmf(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: DiscoverPlugin[DiscoverFmfStepData]

Discover available tests from fmf metadata.

By default all available tests from the current repository are used so the minimal configuration looks like this:

discover:
    how: fmf

Full config example:

discover:
    how: fmf
    url: https://github.com/teemtee/tmt
    ref: main
    path: /fmf/root
    test: /tests/basic
    filter: 'tier: 1'

If no ref is provided, the default branch from the origin is used.

For DistGit repo one can extract sources first and discover tests from it by using distgit-source: true later in Prepare step. It can be used together with ref, path and url, however ref is not possible without using url.

discover:
    how: fmf
    dist-git-source: true

Related config options (all optional):

  • dist-git-merge - set to true if you want to copy in extracted sources to the local repo

  • dist-git-init - set to true and fmf init will be called inside extracted sources (at dist-git-extract or top directory)

  • dist-git-extract - directory (glob supported) to copy from extracted sources (defaults to inner fmf root)

  • dist-git-remove-fmf-root - set to true to remove fmf root from extracted sources

Selecting tests containing specified link is possible using link key accepting RELATION:TARGET format of values. Regular expressions are supported for both relation and target part of the value. Relation can be omitted to target match any relation.

discover:
    how: fmf
    link: verifies:.*issue/850$

It is also possible to limit tests only to those that have changed in git since a given revision. This can be particularly useful when testing changes to tests themselves (e.g. in a pull request CI).

Related config options (all optional):

  • modified-only - set to true if you want to filter modified tests

  • modified-url - fetched as “reference” remote in the test dir

  • modified-ref - the ref to compare against

Example to compare local repo against upstream main branch:

discover:
    how: fmf
    modified-only: True
    modified-url: https://github.com/teemtee/tmt
    modified-ref: reference/main

Note that internally the modified tests are appended to the list specified via test, so those tests will also be selected even if not modified.

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
do_the_discovery(path: Path | None = None) None

Discover the tests

get_git_root(dir: Path) Path

Find git root of the path

go() None

Discover available tests

property is_in_standalone_mode: bool

Enable standalone mode when listing fmf ids

post_dist_git(created_content: list[tmt.utils.Path]) None

Discover tests after dist-git applied patches

tests(*, phase_name: str | None = None, enabled: bool | None = None) list[tmt.base.Test]

Return all discovered tests

class tmt.steps.discover.fmf.DiscoverFmfStepData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, dist_git_source: bool = False, dist_git_type: Optional[str] = None, dist_git_download_only: bool = False, dist_git_install_builddeps: bool = False, dist_git_require: list['tmt.base.DependencySimple'] = <factory>, url: Optional[str] = None, ref: Optional[str] = None, path: Optional[str] = None, test: list[str] = <factory>, link: list[str] = <factory>, filter: list[str] = <factory>, exclude: list[str] = <factory>, modified_only: bool = False, modified_url: Optional[str] = None, modified_ref: Optional[str] = None, dist_git_init: bool = False, dist_git_remove_fmf_root: bool = False, dist_git_merge: bool = False, dist_git_extract: Optional[str] = None, sync_repo: bool = False, fmf_id: bool = False, prune: bool = False, upgrade_path: Optional[str] = None, repository: Optional[str] = None, revision: Optional[str] = None)

Bases: DiscoverStepData

dist_git_extract: str | None = None
dist_git_init: bool = False
dist_git_merge: bool = False
dist_git_remove_fmf_root: bool = False
exclude: list[str]
filter: list[str]
fmf_id: bool = False
modified_only: bool = False
modified_ref: str | None = None
modified_url: str | None = None
path: str | None = None
post_normalization(raw_data: _RawStepData, logger: Logger) None

Called after normalization, useful for tweaking normalized data

prune: bool = False
ref: str | None = None
repository: str | None = None
revision: str | None = None
sync_repo: bool = False
test: list[str]
upgrade_path: str | None = None
url: str | None = None
tmt.steps.discover.fmf.normalize_ref(key_address: str, value: Any | None, logger: Logger) str | None

tmt.steps.discover.shell module

class tmt.steps.discover.shell.DiscoverShell(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: DiscoverPlugin[DiscoverShellData]

Use provided list of shell script tests.

List of test cases to be executed can be defined manually directly in the plan as a list of dictionaries containing test name, actual test script and optionally a path to the test. Example config:

discover:
    how: shell
    tests:
      - name: /help/main
        test: tmt --help
      - name: /help/test
        test: tmt test --help
      - name: /help/smoke
        test: ./smoke.sh
        path: /tests/shell

For DistGit repo one can download sources and use code from them in the tests. Sources are extracted into $TMT_SOURCE_DIR, patches are applied by default. See options to install build dependencies or to just download sources without applying patches. To apply patches the prepare step has to be enabled.

discover:
    how: shell
    dist-git-source: true
    tests:
      - name: /upstream
        test: cd $TMT_SOURCE_DIR/*/tests && make test

To clone a remote repository and use it as a source specify url. It accepts also ref to checkout provided reference. Dynamic reference feature is supported as well.

discover:
    how: shell
    url: https://github.com/teemtee/tmt.git
    ref: "1.18.0"
    tests:
      - name: first test
        test: ./script-from-the-repo.sh

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
fetch_remote_repository(url: str | None, ref: str | None, testdir: Path, keep_git_metadata: bool = False) None

Fetch remote git repo from given url to testdir

go() None

Discover available tests

show(keys: list[str] | None = None) None

Show config details

tests(*, phase_name: str | None = None, enabled: bool | None = None) list[tmt.base.Test]

Return discovered tests

Each DiscoverPlugin has to implement this method. Should return a list of Test() objects.

class tmt.steps.discover.shell.DiscoverShellData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, dist_git_source: bool = False, dist_git_type: Optional[str] = None, dist_git_download_only: bool = False, dist_git_install_builddeps: bool = False, dist_git_require: list['tmt.base.DependencySimple'] = <factory>, tests: list[tmt.steps.discover.shell.TestDescription] = <factory>, url: Optional[str] = None, ref: Optional[str] = None, keep_git_metadata: Optional[bool] = False)

Bases: DiscoverStepData

keep_git_metadata: bool | None = False
ref: str | None = None
tests: list[tmt.steps.discover.shell.TestDescription]
to_spec() _RawStepData

Convert to a form suitable for saving in a specification file

url: str | None = None
class tmt.steps.discover.shell.TestDescription(name: str, test: ~tmt.utils.ShellScript = <tmt.utils.ShellScript object>, summary: str | None = None, description: str | None = None, enabled: bool = True, order: int = 50, link: ~tmt.base.Links | None = None, id: str | None = None, tag: list[str] = <factory>, tier: str | None = None, adjust: list[tmt.base._RawAdjustRule] | None = None, contact: list[str] = <factory>, component: list[str] = <factory>, path: str | None = None, framework: str | None = None, manual: bool = False, tty: bool = False, require: list[typing.Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]] = <factory>, recommend: list[typing.Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]] = <factory>, environment: ~tmt.utils.Environment = <factory>, duration: str = '1h', result: str = 'respect')

Bases: SpecBasedContainer[dict[str, Any], dict[str, Any]], NormalizeKeysMixin, SerializableContainer

Keys necessary to describe a shell-based test.

Provides basic functionality for tansition between “raw” step data representation, which consists of keys and values given by fmf tree and CLI options, and this container representation for internal use.

adjust: list[tmt.base._RawAdjustRule] | None = None
component: list[str]
contact: list[str]
description: str | None = None
duration: str = '1h'
enabled: bool = True
environment: Environment
framework: str | None = None
classmethod from_spec(raw_data: dict[str, Any], logger: Logger) T

Convert from a specification file or from a CLI option

id: str | None = None
manual: bool = False
name: str
order: int = 50
path: str | None = None
recommend: list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]]
require: list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]]
result: str = 'respect'
summary: str | None = None
tag: list[str]
test: ShellScript = <tmt.utils.ShellScript object>
tier: str | None = None
to_spec() dict[str, Any]

Convert to a form suitable for saving in a specification file

tty: bool = False

Module contents

class tmt.steps.discover.Discover(*, plan: Plan, data: _RawStepData | list[tmt.steps._RawStepData], logger: Logger)

Bases: Step

Gather information about test cases to be executed.

Store supported attributes, check for sanity

cli_invocation: 'tmt.cli.CliInvocation' | None = None
cli_invocations: list['tmt.cli.CliInvocation'] = []
go(force: bool = False) None

Discover all tests

load() None

Load step data from the workdir

save() None

Save step data to the workdir

summary() None

Give a concise summary of the discovery

tests(*, phase_name: str | None = None, enabled: bool | None = None) list[tmt.base.Test]
wake() None

Wake up the step (process workdir and command line)

class tmt.steps.discover.DiscoverPlugin(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: GuestlessPlugin[DiscoverStepDataT]

Common parent of discover plugins

Store plugin name, data and parent step

classmethod base_command(usage: str, method_class: type[click.core.Command] | None = None) Command

Create base click command (common for all discover plugins)

cli_invocation: 'tmt.cli.CliInvocation' | None = None
download_distgit_source(distgit_dir: Path, target_dir: Path, handler_name: str | None = None) None

Download sources to the target_dir

distgit_dir is path to the DistGit repository

log_import_plan_details() None

Log details about the imported plan

post_dist_git(created_content: list[tmt.utils.Path]) None

Discover tests after dist-git applied patches

tests(*, phase_name: str | None = None, enabled: bool | None = None) list[tmt.base.Test]

Return discovered tests

Each DiscoverPlugin has to implement this method. Should return a list of Test() objects.

class tmt.steps.discover.DiscoverStepData(name: str, how: str, order: int = 50, summary: Optional[str] = None, where: list[str] = <factory>, dist_git_source: bool = False, dist_git_type: Optional[str] = None, dist_git_download_only: bool = False, dist_git_install_builddeps: bool = False, dist_git_require: list['tmt.base.DependencySimple'] = <factory>)

Bases: WhereableStepData, StepData

dist_git_download_only: bool = False
dist_git_install_builddeps: bool = False
dist_git_require: list[tmt.base.DependencySimple]
dist_git_source: bool = False
dist_git_type: str | None = None