-
Notifications
You must be signed in to change notification settings - Fork 30
/
test.sh
executable file
·52 lines (45 loc) · 1.09 KB
/
test.sh
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
#!/bin/bash
set -e
md5_util() {
if [[ "$OSTYPE" == "darwin"* ]]; then
_md5_util="md5"
else
_md5_util="md5sum"
fi
echo "$_md5_util"
}
BAZEL_BIN=$(bazel info bazel-bin)
NC='\033[0m'
GREEN='\033[0;32m'
RED='\033[0;31m'
function run_test() {
set +e
SECONDS=0
TEST_ARG=$@
echo "running test $TEST_ARG"
RES=$($TEST_ARG 2>&1)
RESPONSE_CODE=$?
DURATION=$SECONDS
if [ $RESPONSE_CODE -eq 0 ]; then
echo -e "${GREEN} Test $TEST_ARG successful ($DURATION sec) $NC"
else
echo "$RES"
echo -e "${RED} Test $TEST_ARG failed $NC ($DURATION sec) $NC"
exit $RESPONSE_CODE
fi
}
test_build_is_identical() {
bazel clean
bazel build test/... "$@"
$(md5_util) ${BAZEL_BIN}/test/*.{srcjar,jar} > hash1
bazel clean
bazel build test/... "$@"
$(md5_util) ${BAZEL_BIN}/test/*.{srcjar,jar} > hash2
bazel clean
cat hash1 hash2
diff hash1 hash2
}
run_test bazel build --verbose_failures test/... --noenable_bzlmod
run_test bazel build --verbose_failures test/... --enable_bzlmod
run_test test_build_is_identical --noenable_bzlmod
run_test test_build_is_identical --enable_bzlmod