| --- |
| title: 'testing' |
| --- |
| |
| Helper methods for Starlark to access testing infrastructure. |
| |
| ## Members |
| |
| * [analysis\_test](#analysis_test) |
| * [ExecutionInfo](#ExecutionInfo) |
| * [TestEnvironment](#TestEnvironment) |
| |
| ## analysis\_test |
| |
| ``` |
| None testing.analysis_test(name, implementation, attrs={}, fragments=[], toolchains=[], attr_values={}) |
| ``` |
| |
| Creates a new analysis test target. |
| |
| The number of transitive dependencies of the test are limited. The limit is controlled by `--analysis_testing_deps_limit` flag. |
| |
| ### Parameters |
| |
| | Parameter | Description | |
| | --- | --- | |
| | `name` | [string](/versions/9.0.0/rules/lib/core/string); required Name of the target. It should be a Starlark identifier, matching pattern '[A-Za-z\_][A-Za-z0-9\_]\*'. | |
| | `implementation` | [function](/versions/9.0.0/rules/lib/core/function); required The Starlark function implementing this analysis test. It must have exactly one parameter: [ctx](/versions/9.0.0/rules/lib/builtins/ctx). The function is called during the analysis phase. It can access the attributes declared by `attrs` and populated via `attr_values`. The implementation function may not register actions. Instead, it must register a pass/fail result via providing [AnalysisTestResultInfo](/versions/9.0.0/rules/lib/providers/AnalysisTestResultInfo). | |
| | `attrs` | [dict](/versions/9.0.0/rules/lib/core/dict); default is `{}` Dictionary declaring the attributes. See the [rule](/versions/9.0.0/rules/lib/globals/bzl#rule) call. Attributes are allowed to use configuration transitions defined using [analysis\_test\_transition](/versions/9.0.0/rules/lib/globals/bzl#analysis_test_transition). | |
| | `fragments` | [sequence](/versions/9.0.0/rules/lib/core/list) of [string](/versions/9.0.0/rules/lib/core/string)s; default is `[]` List of configuration fragments that are available to the implementation of the analysis test. | |
| | `toolchains` | [sequence](/versions/9.0.0/rules/lib/core/list); default is `[]` The set of toolchains the test requires. See the [rule](/versions/9.0.0/rules/lib/globals/bzl#rule) call. | |
| | `attr_values` | [dict](/versions/9.0.0/rules/lib/core/dict) of [string](/versions/9.0.0/rules/lib/core/string)s; default is `{}` Dictionary of attribute values to pass to the implementation. | |
| |
| ## ExecutionInfo |
| |
| ``` |
| ExecutionInfo testing.ExecutionInfo |
| ``` |
| |
| [testing.ExecutionInfo](/versions/9.0.0/rules/lib/providers/ExecutionInfo) provider key/constructor |
| |
| ## TestEnvironment |
| |
| ``` |
| RunEnvironmentInfo testing.TestEnvironment(environment, inherited_environment=[]) |
| ``` |
| |
| **Deprecated: Use RunEnvironmentInfo instead.** Creates a new test environment provider. Use this provider to specify extra environment variables to be made available during test execution. |
| |
| ### Parameters |
| |
| | Parameter | Description | |
| | --- | --- | |
| | `environment` | [dict](/versions/9.0.0/rules/lib/core/dict); required A map of string keys and values that represent environment variables and their values. These will be made available during the test execution. | |
| | `inherited_environment` | [sequence](/versions/9.0.0/rules/lib/core/list) of [string](/versions/9.0.0/rules/lib/core/string)s; default is `[]` A sequence of names of environment variables. These variables are made available during the test execution with their current value taken from the shell environment. If a variable is contained in both `environment` and `inherited_environment`, the value inherited from the shell environment will take precedence if set. | |