blob: 4be0aaced7dc3857ec1b650ce377573e0d6bae6e [file] [log] [blame]
# Copyright 2023 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Defines the fuchsia_host_test_group builddef."""
load(":common.bzl", "BUILDDEF")
load(":fuchsia_test_group.bzl", "fuchsia_test_group_test")
load(":fuchsia_test_target.bzl", "FUCHSIA_TEST_TARGET")
def fuchsia_host_test_group(
*,
name,
environment_setup = [],
deps = [],
non_test_deps = [],
asan_enabled = False,
hermetic = True,
tags = [],
**kwargs):
"""Defines a collection of tests that can be run purely on the host.
This lets your specify a collection of tests (ordinary host tests) to be
scheduled against a host machine.
The target produced by this rule can be used in `fuchsia_builder_group` to
be included in a builder's CQ/CI test runs.
An infrastructure CQ/CI run can also be simulated by running `bazel test` on
the test group target.
Example usage:
```
load("@fuchsia_infra//:infra.bzl", "fuchsia_host_test_group")
fuchsia_host_test_group(
name = "tests_host_asan",
asan_enabled = True,
deps = [ "//src/foo:host_cc_test" ],
)
// In this example, an infrastructure test execution run can be simulated by
// running `bazel test :tests_host_asan`.
```
Args:
name: The target name.
environment_setup: A list of target actions to run before tests.
Requires `hermetic = False`.
deps: A list of tests to run in this test group.
non_test_deps: Non-test runtime file dependencies to include in the
testing environment.
asan_enabled: Whether to build the `deps` with asan.
hermetic: Controls whether this test group is automatically resharded.
tags: Typical meaning in Bazel.
**kwargs: extra attributes to pass along to the build rule.
"""
fuchsia_test_group_test(
name = name,
test_target = FUCHSIA_TEST_TARGET.HOST,
product_bundle = None,
environment_setup = environment_setup,
deps = deps,
non_test_deps = non_test_deps,
hermetic = hermetic,
asan_enabled = asan_enabled,
tags = tags + BUILDDEF.tags,
**kwargs
)