Resolve a path through Bazel Rlocation if the given path does not exist on disk. When running under Bazel, paths from ctx.expand_location are relative to the execroot (e.g. 'external/+ext+repo/binary') which may not resolve from the test process CWD. Rlocation maps them to their absolut
(path)
| 195 | |
| 196 | |
| 197 | def _resolve_bazel_path(path): |
| 198 | """Resolve a path through Bazel Rlocation if the given path does not exist on disk. |
| 199 | |
| 200 | When running under Bazel, paths from ctx.expand_location are relative to |
| 201 | the execroot (e.g. 'external/+ext+repo/binary') which may not resolve from |
| 202 | the test process CWD. Rlocation maps them to their absolute runfiles location. |
| 203 | """ |
| 204 | if not path: |
| 205 | return path |
| 206 | cleaned = path.strip("'") |
| 207 | if Path(cleaned).exists(): |
| 208 | return path |
| 209 | if Runfiles is not None and cleaned.startswith("external/"): |
| 210 | r = Runfiles.Create() |
| 211 | resolved = r.Rlocation(cleaned.removeprefix("external/")) |
| 212 | if resolved: |
| 213 | return resolved |
| 214 | return path |
| 215 | |
| 216 | |
| 217 | # Maps the test driver name to its (browserName, vendor options key). |
no test coverage detected