|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | +"""Analysis test: units listed directly in dependable_element.components are linked in a toctree.""" |
| 14 | + |
| 15 | +load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") |
| 16 | + |
| 17 | +def _toplevel_unit_linked_test_impl(ctx): |
| 18 | + env = analysistest.begin(ctx) |
| 19 | + |
| 20 | + actions = [ |
| 21 | + a |
| 22 | + for a in analysistest.target_actions(env) |
| 23 | + if a.mnemonic == "TemplateExpand" and a.outputs.to_list()[0].basename == "components.rst" |
| 24 | + ] |
| 25 | + asserts.equals(env, 1, len(actions)) |
| 26 | + if len(actions) == 1: |
| 27 | + entries = {s: v for s, v in actions[0].substitutions.items()}["{entries}"] |
| 28 | + asserts.true( |
| 29 | + env, |
| 30 | + "units/" + ctx.attr.unit_name in entries, |
| 31 | + "top-level unit page missing from components toctree: " + entries, |
| 32 | + ) |
| 33 | + return analysistest.end(env) |
| 34 | + |
| 35 | +toplevel_unit_linked_test = analysistest.make( |
| 36 | + _toplevel_unit_linked_test_impl, |
| 37 | + attrs = {"unit_name": attr.string(mandatory = True)}, |
| 38 | +) |
0 commit comments