-
Notifications
You must be signed in to change notification settings - Fork 278
/
test_version.sh
executable file
·148 lines (111 loc) · 5.69 KB
/
test_version.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
set -e
scala_2_11_version="2.11.12"
scala_2_12_version="2.12.20"
scala_2_13_version="2.13.15"
scala_3_version="3.3.4"
SCALA_VERSION_DEFAULT=$scala_2_11_version
diagnostics_reporter_toolchain="//:diagnostics_reporter_toolchain"
diagnostics_reporter_and_semanticdb_toolchain="//:diagnostics_reporter_and_semanticdb_toolchain"
no_diagnostics_reporter_toolchain="//:no_diagnostics_reporter_toolchain"
compilation_should_fail() {
# runs the tests locally
set +e
TEST_ARG=$@
DUMMY=$(bazel $TEST_ARG)
RESPONSE_CODE=$?
if [ $RESPONSE_CODE -eq 0 ]; then
echo -e "${RED} \"bazel $TEST_ARG\" should have failed but passed. $NC"
return -1
else
return 0
fi
}
run_in_test_repo() {
local SCALA_VERSION=${SCALA_VERSION:-$SCALA_VERSION_DEFAULT}
local test_command=$1
local test_dir_prefix=$2
local test_target=$3
cd "${dir}"/test_version
local timestamp=$(date +%s)
NEW_TEST_DIR="test_${test_dir_prefix}_${timestamp}"
cp -r $test_target $NEW_TEST_DIR
local scrooge_ws=""
if [[ -n "$TWITTER_SCROOGE_VERSION" ]]; then
local version_param="version = \"$TWITTER_SCROOGE_VERSION\""
scrooge_ws="scrooge_repositories($version_param)"
fi
sed -e "s%\${twitter_scrooge_repositories}%${scrooge_ws}\n%" \
WORKSPACE.template >> $NEW_TEST_DIR/WORKSPACE
cp ../.bazel{rc,version} $NEW_TEST_DIR/
cd $NEW_TEST_DIR
${test_command}
RESPONSE_CODE=$?
#make sure bazel still not running for this workspace
bazel shutdown
cd ..
rm -rf $NEW_TEST_DIR
exit $RESPONSE_CODE
}
test_scala_version() {
local SCALA_VERSION="$1"
run_in_test_repo "bazel test //... --repo_env=SCALA_VERSION=${SCALA_VERSION}" "scala_version" "version_specific_tests_dir/"
}
test_reporter() {
local SCALA_VERSION="$1"
local SCALA_TOOLCHAIN="$2"
run_in_test_repo "compilation_should_fail build //... --repo_env=SCALA_VERSION=${SCALA_VERSION} --extra_toolchains=${SCALA_TOOLCHAIN}" "reporter" "test_reporter/"
}
test_diagnostic_proto_files() {
local SCALA_VERSION="$1"
local SCALA_TOOLCHAIN="$2"
compilation_should_fail build --build_event_publish_all_actions -k --repo_env=SCALA_VERSION=${SCALA_VERSION} --extra_toolchains=${SCALA_TOOLCHAIN} //test_expect_failure/diagnostics_reporter:all
diagnostics_output="$(bazel info bazel-bin)/test_expect_failure/diagnostics_reporter"
bazel run --repo_env=SCALA_VERSION=${SCALA_VERSION} //test/diagnostics_reporter:diagnostics_reporter_test "$diagnostics_output"
}
test_twitter_scrooge_versions() {
local TWITTER_SCROOGE_VERSION="$1"
case "$TWITTER_SCROOGE_VERSION" in
18.6.0|20.9.0)
;;
*)
echo "Unknown Twitter Scrooge version given $TWITTER_SCROOGE_VERSION"
;;
esac
run_in_test_repo \
"bazel test //twitter_scrooge/... --test_arg=${TWITTER_SCROOGE_VERSION}" \
"scrooge_version" \
"version_specific_tests_dir/"
}
if ! bazel_loc="$(type -p 'bazel')" || [[ -z "$bazel_loc" ]]; then
export PATH="$(cd "$(dirname "$0")"; pwd)"/tools:$PATH
echo 'Using ./tools/bazel directly for bazel calls'
fi
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# shellcheck source=./test_runner.sh
. "${dir}"/test/shell/test_runner.sh
runner=$(get_test_runner "${1:-local}")
export USE_BAZEL_VERSION=${USE_BAZEL_VERSION:-$(cat $dir/.bazelversion)}
TEST_TIMEOUT=15 $runner test_scala_version "${scala_2_11_version}"
TEST_TIMEOUT=15 $runner test_scala_version "${scala_2_12_version}"
TEST_TIMEOUT=15 $runner test_scala_version "${scala_2_13_version}"
TEST_TIMEOUT=15 $runner test_twitter_scrooge_versions "18.6.0"
TEST_TIMEOUT=15 $runner test_twitter_scrooge_versions "21.2.0"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_11_version}" "${no_diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_12_version}" "${no_diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_13_version}" "${no_diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_3_version}" "${no_diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_11_version}" "${diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_12_version}" "${diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_13_version}" "${diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_3_version}" "${diagnostics_reporter_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_11_version}" "${diagnostics_reporter_and_semanticdb_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_12_version}" "${diagnostics_reporter_and_semanticdb_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_2_13_version}" "${diagnostics_reporter_and_semanticdb_toolchain}"
TEST_TIMEOUT=15 $runner test_reporter "${scala_3_version}" "${diagnostics_reporter_and_semanticdb_toolchain}"
TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_12_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain
TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_13_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain
TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_3_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain
TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_12_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_and_semanticdb_toolchain
TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_13_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_and_semanticdb_toolchain
TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_3_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_and_semanticdb_toolchain