depends_on#

depends_on(*arg: str | dict[str, Any] | DependencySelector, when: str | dict[str, str] | None = None, **kwargs) None#

Require that test arg run before this test.

Usage#

.pyt:

import canary
canary.directives.depends_on(name, when=...)
canary.directives.depends_on({"job": name, "when": ..., "expects": ...}, when=...)
canary.directives.depends_on([{"job": name, "when": ..., "expects": ...}], when=...)

.vvt:

#VVT: depends on (result=..., expect=..., options=..., platforms=..., testname=...) : arg

Parameters#

  • arg: The test that should run before this test. Wildcards are allowed.

  • when: Restrict processing of the directive to this condition

VVT Parameters#

  • result: Control whether or not this test runs based on the result of the dependent test. By default, a test will run if its dependencies pass or diff.

  • expect: How many dependencies to expect.

The when expression is limited to the following conditions:

  • testname: Restrict processing of the directive to this test name

  • platforms: Restrict processing of the directive to certain platform or platforms

  • options: Restrict processing of the directive to command line -o options

  • parameters: Restrict processing of the directive to certain parameter names and values

Examples#

Run spam if baz passes or diffs.

.pyt:

# spam.pyt
import canary
canary.directives.depends_on("baz")

def test():
    self = canary.testinstance
    baz = self.dependencies[0]
    print(f"baz's results can be found in {baz.working directory}")

.vvt:

# spam.vvt
# VVT: depends on: baz
import vvtest_util as vvt

def test():
    working directory = vvt.DEPDIRS[0]
    print(f"baz's results can be found in {working directory}")

Run spam regardless of baz’s result:

.pyt:

# spam.pyt
import canary
canary.directives.depends_on({"job": "baz", "when": "always"})

def test():
    self = canary.testinstance
    baz = self.dependencies[0]
    print(f"baz's results can be found in {baz.working directory}")

.vvt:

# spam.vvt
# VVT: depends on (result=*) : baz
import vvtest_util as vvt

def test():
    working directory = vvt.DEPDIRS[0]
    print(f"baz's results can be found in {working directory}")

spam depends only on the serial baz test:

.pyt:

# spam.pyt
import canary
canary.directives.depends_on("baz.cpus=1")

def test():
    self = canary.testinstance
    baz = self.dependencies[0]
    print(f"baz's results can be found in {baz.working directory}")

.vvt:

# spam.vvt
# VVT: depends on: baz.np=1
import vvtest_util as vvt

def test():
    working directory = vvt.DEPDIRS[0]
    print(f"baz's results can be found in {working directory}")