[roll] Roll fuchsia [bazel] Add `host_test()` rule to wrap Bazel host tests for Fuchsia.

This CL adds a new custom rule named `host_test()` to define a Bazel
host test target that can reference a host binary and call it with
specific test arguments at runtime.

The resulting target is a Bazel host test (that can be run with
`bazel test --config=host <label>`), but is also compatible with
Fuchsia test runners (i.e. `fx test` and `botanist`) which will
be modified in the future to see and run them.

Use the new `fx bazel-tool list_bazel_host_tests` command to
generate a `tests.json` file that contains entries describing
all bazel host tests reachable from //build/bazel/host_tests.

NOTE: It is possible to reference an existing Bazel host test
for the binary, but this will not work if the latter has its
own test arguments (Bazel treats them in a special way, and does
*not* store them in the configured graph, e.g. through providers,
hence it is impossible to record them for Fuchsia test runners).

Referencing a Bazel host test that has no test arguments is
possible, but will result in two test targets that essentially
run the same thing through `bazel test`, which is confusing.
A future CL will introduce a new `wrap_host_bazel_test()`
rule or macro to address this specific use case.

- generate_host_test_wrapper.py: A new script used at build time to
  generate a new test wrapper script and related runtime_dir directory
  plus a runtime_deps.json file that can be referenced later by
  `tests.json`.

- host_test.bzl: The new rule definition.

- FuchsiaHostTestInfo.cquery: A new cquery starlark file that can
  be used to generate a tests.json file. Due to Bazel limitations,
  it can only return paths that are relative to the Bazel execroot
  and thus needs to be processed to create paths relative to the
  Ninja build directory.

- bazel_tests_utils.py: New Python module providing a function that
  can generate a tests.json file listing entries for all host_test()
  targets by performing the right Bazel cquery using the previous
  starlark file as input. In the future, this will be used by
  //build/regenerator.py to generate the final version of `tests.json`
  that contains entries for both GN and Bazel tests.

- bazel_tool.py: Add a new `list_bazel_host_tests` that invokes
  the module above to generate a tests.json file describing
  Bazel host tests. Useful as a debugging tool.

- build/bazel/host_tests/...: Modifications to add host_test()
  wrapper targets (using a `_host` target name suffix). This
  will be replaced in the future in favor of new `host_cc_test()`
  and `host_py_test()` macros.

  Local testing is simple, either build then invoke the tests
  directly as in:

    fx build --host @//build/bazel/host_tests/py_tests:simple_test_host
    bazel-bin/build/bazel/host_tests/py_tests/simple_test_host

  Or build then run `bazel test` directly

    fx bazel test --config=host @//build/bazel/host_tests/py_tests:simple_test_host

- export_host_tests.py, host_test_info.cquery: These files were
  not used by the build yet, and can now be removed.

Original-Bug: 349341932
Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1509517
Original-Revision: 54a3465ad8968a1e46021528d3f2aa4b7bbda559
GitOrigin-RevId: 5db63bc4d7eb7e00869c64770e092c276d56fddb
Change-Id: I8b1493780e629afa0e0e36df50c51f8d6f4dc602
1 file changed
tree: c04b9b8ae77aa337b04be528d360a0d61f564e56
  1. ctf/
  2. git-hooks/
  3. infra/
  4. third_party/
  5. cobalt
  6. flower
  7. jiri.lock
  8. MILESTONE
  9. minimal
  10. prebuilts
  11. README.md
  12. stem
  13. test_durations
README.md

Integration

This repository contains Fuchsia's Global Integration manifest files.

Making changes

All changes should be made to the internal version of this repository. Our infrastructure automatically updates this version when the internal one changes.

Currently all changes must be made by a Google employee. Non-Google employees wishing to make a change can ask for assistance in one of the communication channels documented at get involved.

Obtaining the source

First install Jiri.

Next run:

$ jiri init
$ jiri import minimal https://fuchsia.googlesource.com/integration
$ jiri update

Third party

Third party projects should have their own subdirectory in ./third_party.