|
| 1 | +# Copyright 2024 The Bazel Authors. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +"" |
| 16 | + |
| 17 | +load("@rules_testing//lib:truth.bzl", "subjects") |
| 18 | + |
| 19 | +def parse_modules_subject(info, *, meta): |
| 20 | + """Creates a new `parse_modules_subject` for the parse_modules result instance. |
| 21 | +
|
| 22 | + Method: parse_modules_subject.new |
| 23 | +
|
| 24 | + Args: |
| 25 | + info: The parse_modules result object |
| 26 | + meta: ExpectMeta object. |
| 27 | +
|
| 28 | + Returns: |
| 29 | + A `parse_modules_subject` struct |
| 30 | + """ |
| 31 | + |
| 32 | + # buildifier: disable=uninitialized |
| 33 | + public = struct( |
| 34 | + # go/keep-sorted start |
| 35 | + is_reproducible = lambda *a, **k: _subject_is_reproducible(self, *a, **k), |
| 36 | + exposed_packages = lambda *a, **k: _subject_exposed_packages(self, *a, **k), |
| 37 | + hub_group_map = lambda *a, **k: _subject_hub_group_map(self, *a, **k), |
| 38 | + hub_whl_map = lambda *a, **k: _subject_hub_whl_map(self, *a, **k), |
| 39 | + whl_libraries = lambda *a, **k: _subject_whl_libraries(self, *a, **k), |
| 40 | + whl_mods = lambda *a, **k: _subject_whl_mods(self, *a, **k), |
| 41 | + # go/keep-sorted end |
| 42 | + ) |
| 43 | + self = struct( |
| 44 | + actual = info, |
| 45 | + meta = meta, |
| 46 | + ) |
| 47 | + return public |
| 48 | + |
| 49 | +def _subject_is_reproducible(self): |
| 50 | + """Returns a `BoolSubject` for the `is_reproducible` attribute. |
| 51 | +
|
| 52 | + Method: parse_modules_subject.direct_pyc_files |
| 53 | + """ |
| 54 | + return subjects.bool( |
| 55 | + self.actual.is_reproducible, |
| 56 | + meta = self.meta.derive("is_reproducible()"), |
| 57 | + ) |
| 58 | + |
| 59 | +def _subject_exposed_packages(self): |
| 60 | + """Returns a `BoolSubject` for the `exposed_packages` attribute. |
| 61 | +
|
| 62 | + Method: parse_modules_subject.direct_pyc_files |
| 63 | + """ |
| 64 | + return subjects.dict( |
| 65 | + self.actual.exposed_packages, |
| 66 | + meta = self.meta.derive("exposed_packages()"), |
| 67 | + ) |
| 68 | + |
| 69 | +def _subject_hub_group_map(self): |
| 70 | + """Returns a `BoolSubject` for the `hub_group_map` attribute. |
| 71 | +
|
| 72 | + Method: parse_modules_subject.direct_pyc_files |
| 73 | + """ |
| 74 | + return subjects.dict( |
| 75 | + self.actual.hub_group_map, |
| 76 | + meta = self.meta.derive("hub_group_map()"), |
| 77 | + ) |
| 78 | + |
| 79 | +def _subject_hub_whl_map(self): |
| 80 | + """Returns a `BoolSubject` for the `hub_whl_map` attribute. |
| 81 | +
|
| 82 | + Method: parse_modules_subject.direct_pyc_files |
| 83 | + """ |
| 84 | + return subjects.dict( |
| 85 | + self.actual.hub_whl_map, |
| 86 | + meta = self.meta.derive("hub_whl_map()"), |
| 87 | + ) |
| 88 | + |
| 89 | +def _subject_whl_libraries(self): |
| 90 | + """Returns a `BoolSubject` for the `whl_libraries` attribute. |
| 91 | +
|
| 92 | + Method: parse_modules_subject.direct_pyc_files |
| 93 | + """ |
| 94 | + return subjects.dict( |
| 95 | + self.actual.whl_libraries, |
| 96 | + meta = self.meta.derive("whl_libraries()"), |
| 97 | + ) |
| 98 | + |
| 99 | +def _subject_whl_mods(self): |
| 100 | + """Returns a `BoolSubject` for the `whl_mods` attribute. |
| 101 | +
|
| 102 | + Method: parse_modules_subject.direct_pyc_files |
| 103 | + """ |
| 104 | + return subjects.dict( |
| 105 | + self.actual.whl_mods, |
| 106 | + meta = self.meta.derive("whl_mods()"), |
| 107 | + ) |
0 commit comments