| # Copyright 2026 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. |
| # |
| # A starlark input file for bazel cquery that prints one line of output |
| # that contains a JSON-encoded FuchsiaHostTestInfo |
| # |
| # All paths are relative to the Bazel execroot. |
| # |
| # Example use: |
| # bazel cquery <config-options> \ |
| # --output=starlark --starlark:file=/path/to/this/file \ |
| # 'deps(//build/bazel/host_tests)' |
| # |
| def format(target): |
| p = providers(target) |
| if not p: |
| return json.encode({ |
| "error": "missing_fuchsia_host_test_info", |
| "label": str(target.label), |
| }) |
| host_test_info = p.get("//build/bazel/host_tests:host_test.bzl%FuchsiaHostTestInfo") |
| if not host_test_info: |
| return json.encode({ |
| "error": "missing_fuchsia_host_test_info", |
| "label": str(target.label), |
| }) |
| result = { |
| # LINT.IfChange(cquery_output_schema) |
| "label": str(host_test_info.test_label), |
| # The two paths below are relative to the Bazel execroot, and must be converted |
| # by the caller into paths relative to the Ninja build directory. |
| "launcher_execroot_path": host_test_info.test_launcher.path, |
| "runtime_deps_json_execroot_path": host_test_info.test_runtime_deps_json.path, |
| "os": host_test_info.os, |
| "cpu": host_test_info.cpu, |
| "list_cases_argument": host_test_info.list_cases_argument, |
| # LINT.ThenChange(//build/bazel/scripts/bazel_tests_utils.py:cquery_output_schema) |
| } |
| return json.encode(result) |