blob: f3c96a9e1f77b7e172635c6ad3ab827fddf5bb27 [file] [log] [blame]
#!/bin/bash
# Copyright 2021 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/..
readonly REPO_ROOT="${REPO_ROOT}"
readonly TEST_SUITES=("//src/tests")
help() {
echo
echo "Script used to run the Bazel tests"
echo
echo "Usage:"
echo " $(basename "$0") [<options>]"
echo
echo "Options:"
echo
echo " -o <output_user_root>"
echo " This is a bazel parameter. More about it can be found in"
echo " https://docs.bazel.build/versions/main/command-line-reference.html#flag--output_user_root"
echo
}
show_run_test_message() {
local test_suite=$1
echo "Run test suite:"
echo
echo " ${test_suite}"
echo
}
run_bazel() {
local bazel="${REPO_ROOT}/tools/bazel"
if [[ -z "$output_user_root" ]]; then
"$bazel" "$@"
else
"$bazel" --output_user_root "${output_user_root}" "$@"
fi
}
validate_tests_for_tools() {
for suite in "${TEST_SUITES[@]}"; do
(
cd "${REPO_ROOT}"
show_run_test_message "${suite}"
run_bazel test --test_output=all "${suite}"
) || exit 1
done
}
main() {
while getopts ":o:h" opt; do
case ${opt} in
'o') output_user_root=$OPTARG ;;
'h' | '?')
help
exit 1
;;
esac
done
validate_tests_for_tools
}
main "$@"