blob: ac7cf274b455a774fd9170559094c76b20a98c65 [file] [edit]
#!/bin/bash
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
# This script checks the content of a fake_resultstore dump file
# to verify that it contains a FAILED BES sequence.
DUMP_FILE=""
JQ_BIN=""
while [[ "$#" -gt 0 ]]; do
case $1 in
--dump_file) DUMP_FILE="$2"; shift ;;
--jq) JQ_BIN="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [[ -z "${DUMP_FILE}" || -z "${JQ_BIN}" ]]; then
echo "Usage: $0 --dump_file <path> --jq <path>"
exit 1
fi
# Reuse basic existence checks.
./scripts/bazel_tests/testdata/verify_bes_invocation_exists.sh --dump_file "${DUMP_FILE}" --jq "${JQ_BIN}"
# Verify that the build summary indicates a failure.
# Bazel sends a 'Finished' event with an exit_code.
HAS_FAILURE=$( "${JQ_BIN}" -r '[.bes_requests[].ordered_build_event.event.finished | select(.exit_code.name != "SUCCESS")] | any' "${DUMP_FILE}")
if [[ "${HAS_FAILURE}" != "true" ]]; then
echo "FAIL: BES stream does not indicate a failed build status." >&2
exit 1
fi
echo "Confirmed build failure reflected in BES stream."
echo "PASS: Bazel BES failure validation successful."
exit 0