pw_presubmit: Harden output base handling
Harden the handling of parsing the 'bazel.output.base' file.
Bug: b/332357274
Change-Id: Id649a351377bc0a47c40e0193129eb032f0fa39a
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/206490
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/recipe_modules/pw_presubmit/api.py b/recipe_modules/pw_presubmit/api.py
index afd5ac9..70286b5 100644
--- a/recipe_modules/pw_presubmit/api.py
+++ b/recipe_modules/pw_presubmit/api.py
@@ -285,7 +285,7 @@
bazel_output_base = step.dir / 'bazel.output.base'
self.m.path.mock_add_file(bazel_output_base)
if self.m.path.isfile(bazel_output_base):
- base_dir = self.m.path.abs_to_path(
+ new_base_dir = self.m.path.abs_to_path(
self.m.file.read_text(
f'read {bazel_output_base.name}',
bazel_output_base,
@@ -294,6 +294,9 @@
),
).strip()
)
+ self.m.path.mock_add_directory(new_base_dir)
+ if self.m.path.isdir(new_base_dir):
+ base_dir = new_base_dir
builder_manifest = step.dir / 'builder_manifest.json'
if self.m.path.isfile(builder_manifest):