|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright 2018, OpenCensus Authors |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# presubmit: |
| 18 | +# Run a slow but complete check of the code to make sure: |
| 19 | +# - Everything builds. |
| 20 | +# - Tests pass. |
| 21 | +# - Sanitizers pass. |
| 22 | +# |
| 23 | +# This is intended to be run manually and locally, not as part of |
| 24 | +# continuous integration. |
| 25 | + |
| 26 | +readonly R="=======================================" |
| 27 | +readonly BOLD="\\033[1m" |
| 28 | +readonly ERR="\\033[31;1m" |
| 29 | +readonly NORMAL="\\033[0m" |
| 30 | + |
| 31 | +function run() { |
| 32 | + echo "" |
| 33 | + echo -e "${BOLD}${R}${R}" |
| 34 | + echo "Running: $@" |
| 35 | + echo -e "${R}${R}${NORMAL}" |
| 36 | + $@ |
| 37 | + ret="$?" |
| 38 | + if [[ "${ret}" -ne 0 ]]; then |
| 39 | + echo "" |
| 40 | + echo -e "${ERR}>>> Error: returned code ${ret} <<<${NORMAL}" |
| 41 | + exit ${ret} |
| 42 | + fi |
| 43 | +} |
| 44 | + |
| 45 | +t0="$(date +%s)" |
| 46 | + |
| 47 | +buildables="-- $(bazel query -k --noshow_progress "kind('^cc', //...)")" |
| 48 | + |
| 49 | +tests="-- $(bazel query -k --noshow_progress \ |
| 50 | + "kind(test, //...) \ |
| 51 | + except attr('tags', 'manual', //...)")" |
| 52 | + |
| 53 | +run bazel build $buildables |
| 54 | +run bazel test $tests |
| 55 | + |
| 56 | +run bazel build -c opt $buildables |
| 57 | +run bazel test -c opt $tests |
| 58 | + |
| 59 | +for config in asan ubsan; do |
| 60 | + run bazel test --config=$config $tests |
| 61 | + run bazel test --config=$config -c opt $tests |
| 62 | +done |
| 63 | + |
| 64 | +t1="$(date +%s)" |
| 65 | +echo "" |
| 66 | +echo "Succeeded after $((t1 - t0)) secs." |
0 commit comments