1#!/bin/bash -eu 2 3# This file tests the creation of bazel commands for b usage 4set -o pipefail 5source "$(dirname "$0")/../../bazel/lib.sh" 6 7BES_UUID="blank" 8OUT_DIR="arbitrary_out" 9b_args=$(formulate_b_args "build --config=nonsense foo:bar") 10 11if [[ $b_args != "build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=metrics_data --config=nonsense foo:bar" ]]; then 12 echo "b args are malformed" 13 echo "Expected : build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=metrics_data --config=nonsense foo:bar" 14 echo "Actual: $b_args" 15 exit 1 16fi 17 18b_args=$(formulate_b_args "build --config=nonsense --disable_bes --package_path \"my package\" foo:bar") 19 20if [[ $b_args != "build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar" ]]; then 21 echo "b args are malformed" 22 echo "Expected : build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar" 23 echo "Actual: $b_args" 24 exit 1 25fi 26 27# Test with startup option 28b_args=$(formulate_b_args "--batch build --config=nonsense --disable_bes --package_path \"my package\" foo:bar") 29if [[ $b_args != "--batch build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar" ]]; then 30 echo "b args are malformed" 31 echo "Expected : --batch build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar" 32 echo "Actual: $b_args" 33 exit 1 34fi 35 36OUT_DIR="mock_out" 37TEST_PROFILE_OUT=$(get_profile_out_dir) 38if [[ $TEST_PROFILE_OUT != "mock_out" ]]; then 39 echo "Profile Out is malformed." 40 echo "Expected: mock_out" 41 echo "Actual: $TEST_PROFILE_OUT" 42 exit 1 43fi 44