Skip to content

Dependencies#

The dependencies mechanism allows you to specify which tests must complete before another test runs. Dependencies can be simple, parameterized, or generative. This provides flexible control over test execution and artifact linking.

Basic behavior#

By default, a dependency ensures: - The dependency’s status is checked; if it failed, the dependent test also fails. - The dependency’s artifacts are linked into the dependent test’s run directory.

A simple example:

- test: run_test_for_all_build
  run: echo run test
  dependencies:
    - build::simple_build

This configuration runs run_test_for_all_build once, links artifacts from build::simple_build, and checks its success.

Extended syntax#

Dependencies can be written in an extended form:

- test: run_test_for_all_build
  run: echo run test
  dependencies:
    - id: build::simple_build
      status: true
      artifacts: true
  • id – test identifier (suite::test).
  • status – whether the dependent test should fail if the dependency failed. Default: true.
  • artifacts – whether dependency artifacts are linked into the test run directory. Default: true.
  • parameters – restricts the dependency to specific parameter values (see below).
  • generate – marks a dependency as generative, expanding one test into many based on dependency variants.

The following configurations are equivalent:

dependencies:
  - build::simple_build

dependencies:
  - id: build::simple_build

dependencies:
  - id: build::simple_build
    status: true
    artifacts: true

Note

Dependencies on tests in the current suite are only allowed if suite parallelism is disabled. Instead, consider disabling parallelism using suite.strategy.parallel or placing tests in different test suites.

Parameterized dependencies#

If a dependency has parameters, it may run multiple times with different parameter sets. By default, the dependent test checks all dependency variants.

Examples:

# All variants
dependencies:
  - build::build_with_params

# Specific variant
dependencies:
  - id: build::build_with_params
    parameters:
      FOO: 1
      BAR: 0

# Subset of variants
dependencies:
  - id: build::build_with_params
    parameters:
      FOO: 1

Generative dependencies#

A generative dependency expands one test specification into multiple tests – one for each variant of the dependency. This is useful when the same test should be executed for all parameterized variants of a dependency.

Example:

dependencies:
  - generate: build::build_with_params

This will expand the test into as many runs as there are variants of build_with_params. Generative dependencies also support parameter filtering.

Currently dependency handling mechanism implemented via fixtures.

For example, the configuration:

max_num_workers: 4
tests:
  - suite: build
    tests:
      - test: build_with_params
        run: echo make build $BRUTE_VALUE
        parameters:
          FOO:
            brute_list: ["0", "1"]
          B: 2
          A: 1

  - suite: test
    tests:
      - test: run_test_for_all_build
        run: echo run test
        parameters:
        dependencies:
        - id: build::build_with_params

will result in the following test output:

collected 2 items
tmp/tests/build.py::build_with_params[A=1-B=2-FOO=0] PASSED
tmp/tests/build.py::build_with_params[A=1-B=2-FOO=1] PASSED

...

collected 1 item
tmp/tests/test.py::run_test_for_all_build[test_result=[Indirect(test_id='build::build_with_params', params=[{'A': '1', 'B': '2', 'FOO': '0'}, {'A': '1', 'B': '2', 'FOO': '1'}])]] PASSED

test_result in this case is a fixture responsible for verifying the test status and linking its artifacts. It is parameterized by the dependencies specified by the user.

If the test itself had its own parameter FOO, for example:

  - test: run_test_for_all_build
    run: echo run test
    parameters:
      FOO:
        brute_list: ["0", "1"]

then the output would be:

collected 2 items

tmp/tests/test.py::run_test_for_all_build[FOO=0-test_result=[Indirect(test_id='build::build_with_params', params=[{'A': '1', 'B': '2', 'FOO': '0'}, {'A': '1', 'B': '2', 'FOO': '1'}])]] PASSED
tmp/tests/test.py::run_test_for_all_build[FOO=1-test_result=[Indirect(test_id='build::build_with_params', params=[{'A': '1', 'B': '2', 'FOO': '0'}, {'A': '1', 'B': '2', 'FOO': '1'}])]] PASSED

The test’s FOO parameter values are recorded separately, while the dependencies for each variant are included in the Indirect parameter, which parameterizes the test_result fixture responsible for dependency handling.

Combining Dependencies#

The mechanisms described above for handling dependencies can be combined.

If multiple dependencies are specified for a test, they are all passed to the test_result fixture for processing.

For example:

tests:
  - suite: build
    tests:
      - test: simple_build
        run: echo make build $BRUTE_VALUE
      - test: build_with_params
        run: echo make build $BRUTE_VALUE
        parameters:
          FOO:
            brute_list: ["0", "1"]

  - suite: test
    tests:
      - test: run_test_for_all_build
        run: echo run test
        parameters:
        dependencies:
        - build::build_with_params
        - build::simple_build

In this case, fixture parameterization is performed so that the fixture receives a list of dependencies:

tmp/tests/test.py::run_test_for_all_build[test_result=[Indirect(test_id='build::build_with_params', params=[{'A': '1', 'B': '2', 'FOO': '0'}, {'A': '1', 'B': '2', 'FOO': '1'}]), Indirect(test_id='build::simple_build', params=[{}])]] PASSED

When using generative dependencies, each dependency specification will be passed to test_result separately. Thus, the following configuration:

    dependencies:
    - generate: build::build_with_params
    - generate: build::simple_build

will result in this execution:

collected 3 items
tmp/tests/test.py::run_test_for_all_build_0[test_result=[Indirect(test_id='build::build_with_params', params=[{'FOO': '0'}])]] PASSED
tmp/tests/test.py::run_test_for_all_build_1[test_result=[Indirect(test_id='build::build_with_params', params=[{'FOO': '1'}])]] PASSED
tmp/tests/test.py::run_test_for_all_build_2[test_result=[Indirect(test_id='build::simple_build', params=[{}])]] PASSED

Known issues#

A generative dependency on another generative dependency is not supported.#

This configuration will not work:

max_num_workers: 4
tests:
  - suite: build
    strategy:
      parallel: false
    tests:
      - test: build0
        run: echo make build $BRUTE_VALUE
        parameters:
          FOO:
            brute_list: ["0", "1"]
      - test: build1
        run: echo make build $BRUTE_VALUE
        dependencies:
        - generate: build::build0

  - suite: test
    tests:
      - test: run_test_for_all_build
        run: echo run test
        dependencies:
        - id: build::build1