1#!/bin/bash 2# 3# Build file to set up and run tests 4set -ex 5 6# Install Bazel 4.0.0. 7use_bazel.sh 4.0.0 8bazel version 9 10# Print bazel testlogs to stdout when tests failed. 11function print_test_logs { 12 # TODO(yannic): Only print logs of failing tests. 13 testlogs_dir=$(bazel info bazel-testlogs) 14 testlogs=$(find "${testlogs_dir}" -name "*.log") 15 for log in $testlogs; do 16 cat "${log}" 17 done 18} 19 20# Change to repo root 21cd $(dirname $0)/../../.. 22 23git submodule update --init --recursive 24 25# Disabled for now, re-enable if appropriate. 26# //:build_files_updated_unittest \ 27 28trap print_test_logs EXIT 29bazel test -k --copt=-Werror --host_copt=-Werror \ 30 //build_defs:all \ 31 //java:tests \ 32 //:protoc \ 33 //:protobuf \ 34 //:protobuf_python \ 35 //:protobuf_test 36trap - EXIT 37 38pushd examples 39bazel build //... 40popd 41 42# Verify that we can build successfully from generated tar files. 43./autogen.sh && ./configure && make -j$(nproc) dist 44DIST=`ls *.tar.gz` 45tar -xf $DIST 46cd ${DIST//.tar.gz} 47bazel build //:protobuf //:protobuf_java 48