-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecute_unit_tests.bash
More file actions
executable file
·63 lines (55 loc) · 3.28 KB
/
execute_unit_tests.bash
File metadata and controls
executable file
·63 lines (55 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
#
# Execute all unit tests
set -euo pipefail
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
source "${SCRIPT_DIR}/common.bash"
check_bazel_build_error() {
# Check bazel build error for a particular target
#
# Args:
# $1: label to check
local label
label=$1
# Before executing `bazel build`, check if the target exists with `bazel query`
bazel query "${label}"
# Check build error
if bazel build "${label}"; then
echo "Target '${label}' must fail to build, but succeeded" >&2
exit 1
else
echo "OK! It has failed as intended."
fi
}
cd "${REPO_ROOT_DIR}"
echo "Executing the test cases which should succeed in straightforward 'bazel test'"
bazel test //...
echo "Executing the test cases which should fail at 'bazel build'"
check_bazel_build_error //tests/unit/cc/cpp_successful_build:plain
check_bazel_build_error //tests/unit/cc/cpp_successful_build:plain.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build:with_basic_regex_matcher
check_bazel_build_error //tests/unit/cc/cpp_successful_build:with_basic_regex_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build:with_extended_regex_matcher
check_bazel_build_error //tests/unit/cc/cpp_successful_build:with_extended_regex_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build:with_substr_matcher
check_bazel_build_error //tests/unit/cc/cpp_successful_build:with_substr_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:plain
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:plain.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:with_basic_regex_matcher
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:with_basic_regex_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:with_extended_regex_matcher
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:with_extended_regex_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:with_substr_matcher
check_bazel_build_error //tests/unit/cc/cpp_successful_build_with_deps:with_substr_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_compile_error:incorrect_matcher
check_bazel_build_error //tests/unit/cc/cpp_compile_error:incorrect_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_inline_src:incorrect_matcher
check_bazel_build_error //tests/unit/cc/cpp_inline_src:incorrect_matcher.test
check_bazel_build_error //tests/unit/cc/cpp_inline_src:incorrect_extension
check_bazel_build_error //tests/unit/cc/cpp_inline_src:incorrect_extension.test
check_bazel_build_error //tests/unit/cc/c_inline_src:incorrect_extension
check_bazel_build_error //tests/unit/cc/c_inline_src:incorrect_extension.test
check_bazel_build_error //tests/unit/cc/c_compile_error_matcher_using_select:incorrect_select_inside_match_condition
check_bazel_build_error //tests/unit/cc/c_compile_error_matcher_using_select:incorrect_select_inside_match_condition.test
check_bazel_build_error //tests/unit/cc/c_compile_error_matcher_using_select:incorrect_select_outside_match_conditions
check_bazel_build_error //tests/unit/cc/c_compile_error_matcher_using_select:incorrect_select_outside_match_conditions.test