DDS
DDS CI Scripts Python API

DDS CI Scripts Python API

Types from pytest

These types are defined by pytest, but are used extensively within the testing scripts.

class _pytest.fixtures.FixtureRequest
class _pytest.tmpdir.TempPathFactory

Test Fixtures

The following test fixtures are defined:

Module: dds_ci

Module: dds_ci.dds

class dds_ci.dds.DDSWrapper(path: pathlib.Path, *, repo_dir: Optional[Union[os.PathLike, str]] = None, pkg_db_path: Optional[Union[os.PathLike, str]] = None, default_cwd: Optional[Union[os.PathLike, str]] = None)

Wraps a ‘dds’ executable with some convenience APIs that invoke various ‘dds’ subcommands.

build(*, root: pathlib.Path, toolchain: Optional[pathlib.Path] = None, build_root: Optional[pathlib.Path] = None, jobs: Optional[int] = None, tweaks_dir: Optional[pathlib.Path] = None, more_args: Optional[dds_ci.proc.CommandLine] = None, timeout: Optional[int] = None)None

Run ‘dds build’ with the given arguments.

Parameters
  • toolchain – The toolchain to use for the build.

  • root – The root project directory.

  • build_root – The root directory where the output will be written.

  • jobs – The number of jobs to use. Default is CPU-count + 2

property cache_dir_arg

The arguments for –repo-dir

catalog_json_import(path: pathlib.Path)None

Run ‘catalog import’ to import the given JSON. Only applicable to older ‘dds’

clean(*, build_dir: Optional[pathlib.Path] = None, repo: bool = True, pkg_db: bool = True)None

Clean out prior executable output, including repos, pkg_db, and the build results at ‘build_dir’, if given.

compile_file(paths: Iterable[Union[os.PathLike, str]], *, toolchain: Optional[Union[os.PathLike, str]] = None, project_dir: Union[os.PathLike, str], out: Optional[Union[os.PathLike, str]] = None)None

Run ‘dds compile-file’ for the given paths.

property pkg_db_path_arg

The arguments for –catalog

run(args: dds_ci.proc.CommandLine, *, cwd: Optional[Union[os.PathLike, str]] = None, timeout: Optional[int] = None)None

Execute the ‘dds’ executable with the given arguments

class dds_ci.dds.NewDDSWrapper(path: pathlib.Path, *, repo_dir: Optional[Union[os.PathLike, str]] = None, pkg_db_path: Optional[Union[os.PathLike, str]] = None, default_cwd: Optional[Union[os.PathLike, str]] = None)

Wraps the new ‘dds’ executable with some convenience APIs

property cache_dir_arg

The arguments for –repo-dir

property pkg_db_path_arg

The arguments for –catalog

Module: dds_ci.proc

class dds_ci.proc.CommandLine(*args, **kwds)
class dds_ci.proc.ProcessResult(*args, **kwds)

Module: dds_ci.testing

class dds_ci.testing.LibraryJSON(**kwargs)
class dds_ci.testing.PackageJSON(**kwargs)
class dds_ci.testing.Project(dirpath: pathlib.Path, dds: dds_ci.dds.DDSWrapper)

Utilities to access a project being used as a test.

build(*, toolchain: Optional[Union[os.PathLike, str]] = None, timeout: Optional[int] = None, tweaks_dir: Optional[pathlib.Path] = None)None

Execute ‘dds build’ on the project

property library_json

Get/set the content of the library.json file for the project.

property package_json

Get/set the content of the package.json file for the project.

property project_dir_arg

Argument for –project

write(path: Union[os.PathLike, str], content: str)pathlib.Path

Write the given content to path. If path is relative, it will be resolved relative to the root directory of this project.

class dds_ci.testing.ProjectOpener(dds: dds_ci.dds.DDSWrapper, request: _pytest.fixtures.FixtureRequest, worker: str, tmp_path_factory: _pytest.tmpdir.TempPathFactory)

A test fixture that opens project directories for testing

open(dirpath: Union[os.PathLike, str])dds_ci.testing.fixtures.Project

Open a new project testing fixture from the given project directory.

Parameters

dirpath – The directory that contains the project to use.

Clones the given directory and then opens a project within that clone. The clone directory will be destroyed when the test fixture is torn down.

property test_dir

The directory that contains the test that requested this opener

property test_name

The name of the test that requested this opener

class dds_ci.testing.RepoServer(dds_exe: pathlib.Path, info: dds_ci.testing.http.ServerInfo, repo_name: str)

A fixture handle to a dds HTTP repository, including a path and URL.

import_json_data(data: Any)None

Import some packages into the repo for the given JSON data. Uses mkrepo.py

import_json_file(fpath: pathlib.Path)None

Import some package into the repo for the given JSON file. Uses mkrepo.py

Module: dds_ci.testing.http

class dds_ci.testing.http.DirectoryServingHTTPRequestHandler(*args: Any, **kwargs: Any)

A simple HTTP request handler that simply serves files from a directory given to the constructor.

translate_path(path: str)str

Translate a /-separated PATH to the local filename syntax.

Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.)

class dds_ci.testing.http.RepoServer(dds_exe: pathlib.Path, info: dds_ci.testing.http.ServerInfo, repo_name: str)

A fixture handle to a dds HTTP repository, including a path and URL.

import_json_data(data: Any)None

Import some packages into the repo for the given JSON data. Uses mkrepo.py

import_json_file(fpath: pathlib.Path)None

Import some package into the repo for the given JSON file. Uses mkrepo.py

class dds_ci.testing.http.ServerInfo(base_url, root)

Information about an HTTP server fixture

property base_url

Alias for field number 0

property root

Alias for field number 1

dds_ci.testing.http.http_repo(http_repo_factory: Callable[str, dds_ci.testing.http.RepoServer], request: _pytest.fixtures.FixtureRequest)dds_ci.testing.http.RepoServer

Fixture that creates a new empty dds repository and an HTTP server to serve it.

dds_ci.testing.http.http_repo_factory(dds_exe: pathlib.Path, repo_factory: Callable[str, pathlib.Path], http_server_factory: Callable[pathlib.Path, dds_ci.testing.http.ServerInfo]) → Callable[str, dds_ci.testing.http.RepoServer]

Fixture factory that creates new repositories with an HTTP server for them.

dds_ci.testing.http.http_server_factory(request: _pytest.fixtures.FixtureRequest) → Callable[pathlib.Path, dds_ci.testing.http.ServerInfo]

Spawn an HTTP server that serves the content of a directory.

dds_ci.testing.http.run_http_server(dirpath: pathlib.Path, port: int) → Iterator[dds_ci.testing.http.ServerInfo]

Context manager that spawns an HTTP server that serves thegiven directory on the given TCP port.

Module: dds_ci.testing.fixtures

Test fixtures used by DDS in pytest

class dds_ci.testing.fixtures.LibraryJSON(**kwargs)
class dds_ci.testing.fixtures.PackageJSON(**kwargs)
class dds_ci.testing.fixtures.Project(dirpath: pathlib.Path, dds: dds_ci.dds.DDSWrapper)

Utilities to access a project being used as a test.

build(*, toolchain: Optional[Union[os.PathLike, str]] = None, timeout: Optional[int] = None, tweaks_dir: Optional[pathlib.Path] = None)None

Execute ‘dds build’ on the project

property library_json

Get/set the content of the library.json file for the project.

property package_json

Get/set the content of the package.json file for the project.

property project_dir_arg

Argument for –project

write(path: Union[os.PathLike, str], content: str)pathlib.Path

Write the given content to path. If path is relative, it will be resolved relative to the root directory of this project.

class dds_ci.testing.fixtures.ProjectOpener(dds: dds_ci.dds.DDSWrapper, request: _pytest.fixtures.FixtureRequest, worker: str, tmp_path_factory: _pytest.tmpdir.TempPathFactory)

A test fixture that opens project directories for testing

open(dirpath: Union[os.PathLike, str])dds_ci.testing.fixtures.Project

Open a new project testing fixture from the given project directory.

Parameters

dirpath – The directory that contains the project to use.

Clones the given directory and then opens a project within that clone. The clone directory will be destroyed when the test fixture is torn down.

property test_dir

The directory that contains the test that requested this opener

property test_name

The name of the test that requested this opener

dds_ci.testing.fixtures.dds(dds_exe: pathlib.Path)dds_ci.dds.NewDDSWrapper

A DDSWrapper around the dds executable under test

dds_ci.testing.fixtures.dds_exe(pytestconfig: _pytest.config.Config)pathlib.Path

A pathlib.Path pointing to the DDS executable under test

dds_ci.testing.fixtures.project_opener(request: _pytest.fixtures.FixtureRequest, worker_id: str, dds: dds_ci.dds.DDSWrapper, tmp_path_factory: _pytest.tmpdir.TempPathFactory)dds_ci.testing.fixtures.ProjectOpener

A fixture factory that can open directories as Project objects for building and testing. Duplicates the project directory into a temporary location so that the original test directory remains unchanged.

dds_ci.testing.fixtures.test_parent_dir(request: _pytest.fixtures.FixtureRequest)pathlib.Path

pathlib.Path fixture pointing to the parent directory of the file containing the test that is requesting the current fixture

dds_ci.testing.fixtures.tmp_project(request: _pytest.fixtures.FixtureRequest, worker_id: str, project_opener: dds_ci.testing.fixtures.ProjectOpener, tmp_path_factory: _pytest.tmpdir.TempPathFactory)dds_ci.testing.fixtures.Project

A fixture that generates an empty temporary project directory that will be thrown away when the test completes.

Module: dds_ci.testing.error

Test utilities for error checking

dds_ci.testing.error.expect_error_marker(expect: str) → Iterator[None]

A context-manager function that should wrap a scope that causes an error from dds.

Parameters

expect – The error message ID string that is expected to appear.

The wrapped scope should raise subprocess.CalledProcessError.

After handling the exception, asserts that the subprocess wrote an error marker containing the string given in expect.