-
Notifications
You must be signed in to change notification settings - Fork 2
General test dependencies
A test can be made to "depend" on another test. If testY
depends on testX
then
-
testX
will be executed beforetestY
-
testY
will have the location oftestX
available in its script
A dependency is added to a test in the test header. For example, consider file testY.py
:
#VVT: depends on : testX
import sys, os
...
This test would wait on testX
to complete with a pass or diff result status before running. When it does run, the location of testY
is provided in a list variable in the vvtest_util.py file as
DEPDIRS = ["<path>/testX",]
where <path>/testX is the directory path to the execution of testX
.
By default, if a dependency passes or diffs then the dependent test is run. However, this can be controlled with the "result" attribute in the specification header. For example,
#VVT: depends on (result="pass") : testX
import sys, os
...
This would only run the dependent test if testX
passed. Expressions are allowed, such as "not fail" or "pass or diff". The special value of a single asterisk, "*", means run the dependent test no matter what the result value is of the dependency test.
Test dependencies can be specified with shell-style wild cards, such as
#VVT: depends on : testX*param=*
Tests are matched using the first non-empty list of the following methods:
- <homedir>/pattern
- <homedir>/**/pattern
- pattern
- *pattern
where the <homedir> is the directory containing the test.
Because a dependency pattern may match more than one test, a second variable is placed in the vvtest_util.py file for convenience, called DEPDIRMAP. It maps the pattern given in the header to an alphabetically sorted list of directories (the dependencies).
If no dependency tests are found, then the dependent test will not be run (it will be shown as notrun
with reason "failed 'depends on' matching criteria"). This behavior can be controlled with the "expect" attribute. For example,
#VVT: depends on (expect=2) : foo*bar
import sys, os
...
This test will only run if the number of tests that match "foo*bar" is exactly two. Possible values for "expect" are
-
+
: one or more matches (this is the default) -
?
: zero or one match -
*
: zero or more matches - N : a non-negative integer number of matches
Variable substitutions can be made in the dependency patterns. Use the construct "${parameter_name}". For example, suppose the test file foo.vvt
had this header:
#VVT: parameterize : pet = dog cat
#VVT: depends on : store*pet=${pet}*
Then for the test name foo.pet=dog, the dependency pattern will resolve to "store*pet=dog*", and for name foo.pet=cat the pattern will be "store*pet=cat*".
Currently, the substitution is confined to parameter names, and if a the dollar-brace construct does not match a parameter name, the pattern is left untouched.