Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting rule name for analysis tests #331

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/unittest_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ unittest_toolchain(<a href="#unittest_toolchain-name">name</a>, <a href="#unitte

<pre>
analysistest.make(<a href="#analysistest.make-impl">impl</a>, <a href="#analysistest.make-expect_failure">expect_failure</a>, <a href="#analysistest.make-attrs">attrs</a>, <a href="#analysistest.make-fragments">fragments</a>, <a href="#analysistest.make-config_settings">config_settings</a>,
<a href="#analysistest.make-extra_target_under_test_aspects">extra_target_under_test_aspects</a>, <a href="#analysistest.make-doc">doc</a>)
<a href="#analysistest.make-extra_target_under_test_aspects">extra_target_under_test_aspects</a>, <a href="#analysistest.make-doc">doc</a>, <a href="#analysistest.make-name">name</a>)
</pre>

Creates an analysis test rule from its implementation function.
Expand Down Expand Up @@ -79,6 +79,7 @@ Recall that names of test rules must end in `_test`.
| <a id="analysistest.make-config_settings"></a>config_settings | A dictionary of configuration settings to change for the target under test and its dependencies. This may be used to essentially change 'build flags' for the target under test, and may thus be utilized to test multiple targets with different flags in a single build | <code>{}</code> |
| <a id="analysistest.make-extra_target_under_test_aspects"></a>extra_target_under_test_aspects | An optional list of aspects to apply to the target_under_test in addition to those set up by default for the test harness itself. | <code>[]</code> |
| <a id="analysistest.make-doc"></a>doc | A description of the rule that can be extracted by documentation generating tools. | <code>""</code> |
| <a id="analysistest.make-name"></a>name | If set, the rule class will be exported with this name | <code>None</code> |

**RETURNS**

Expand Down
5 changes: 4 additions & 1 deletion lib/unittest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def _make_analysis_test(
fragments = [],
config_settings = {},
extra_target_under_test_aspects = [],
doc = ""):
doc = "",
name = None):
"""Creates an analysis test rule from its implementation function.

An analysis test verifies the behavior of a "real" rule target by examining
Expand Down Expand Up @@ -252,6 +253,7 @@ def _make_analysis_test(
extra_target_under_test_aspects: An optional list of aspects to apply to the target_under_test
in addition to those set up by default for the test harness itself.
doc: A description of the rule that can be extracted by documentation generating tools.
name: If set, the rule class will be exported with this name

Returns:
A rule definition that should be stored in a global whose name ends in
Expand Down Expand Up @@ -285,6 +287,7 @@ def _make_analysis_test(
test = True,
toolchains = [TOOLCHAIN_TYPE],
analysis_test = True,
name = name,
)

def _suite(name, *test_rules):
Expand Down