|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
| 3 | +set -euo pipefail |
| 4 | + |
3 | 5 | dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
4 |
| -NC='\033[0m' |
5 |
| -GREEN='\033[0;32m' |
6 |
| -RED='\033[0;31m' |
7 |
| - |
8 |
| -run_test_local() { |
9 |
| - # runs the tests locally |
10 |
| - set +e |
11 |
| - SECONDS=0 |
12 |
| - TEST_ARG=$@ |
13 |
| - echo "running test $TEST_ARG" |
14 |
| - RES=$($TEST_ARG 2>&1) |
15 |
| - RESPONSE_CODE=$? |
16 |
| - DURATION=$SECONDS |
17 |
| - if [ $RESPONSE_CODE -eq 0 ]; then |
18 |
| - echo -e "${GREEN} Test \"$TEST_ARG\" successful ($DURATION sec) $NC" |
19 |
| - else |
20 |
| - echo $RES |
21 |
| - echo -e "${RED} Test \"$TEST_ARG\" failed $NC ($DURATION sec) $NC" |
22 |
| - return $RESPONSE_CODE |
23 |
| - fi |
24 |
| -} |
| 6 | +# shellcheck source=./test_runner.sh |
| 7 | +. "${dir}"/../test/shell/test_runner.sh |
| 8 | +. "${dir}"/../test/shell/test_helper.sh |
| 9 | +runner="$(get_test_runner "${1:-local}")" |
25 | 10 |
|
26 | 11 | run_in_test_repo() {
|
27 |
| - local test_command=$1 |
28 |
| - local test_repo=$2 |
| 12 | + local test_repo="$1" |
| 13 | + local test_command=("${@:2}") |
| 14 | + local response_code=0 |
29 | 15 |
|
30 |
| - cd "${dir}/${test_repo}" || exit 1 |
31 |
| - ${test_command} |
32 |
| - RESPONSE_CODE=$? |
| 16 | + cd "${dir}/${test_repo}" || return 1 |
| 17 | + "${test_command[@]}" || response_code=$? |
33 | 18 |
|
34 | 19 | bazel shutdown
|
35 |
| - |
36 | 20 | cd ../..
|
37 |
| - |
38 |
| - return $RESPONSE_CODE |
| 21 | + return $response_code |
39 | 22 | }
|
40 | 23 |
|
41 | 24 | test_compiler_patch() {
|
42 | 25 | local SCALA_VERSION="$1"
|
43 | 26 |
|
44 |
| - run_in_test_repo "bazel build //... --repo_env=SCALA_VERSION=${SCALA_VERSION} //..." "test_dt_patches" |
| 27 | + run_in_test_repo \ |
| 28 | + test_dt_patches \ |
| 29 | + bazel build "--repo_env=SCALA_VERSION=${SCALA_VERSION}" //... |
45 | 30 | }
|
46 | 31 |
|
47 | 32 | test_compiler_srcjar() {
|
48 | 33 | set -o pipefail
|
49 | 34 | local SCALA_VERSION="$1"
|
50 | 35 |
|
51 |
| - run_in_test_repo "bazel build //... --repo_env=SCALA_VERSION=${SCALA_VERSION} //..." "test_dt_patches_user_srcjar" 2>&1 | (! grep "canonical reproducible") |
| 36 | + run_in_test_repo \ |
| 37 | + test_dt_patches_user_srcjar \ |
| 38 | + bazel build "--repo_env=SCALA_VERSION=${SCALA_VERSION}" //... 2>&1 | |
| 39 | + (! grep "canonical reproducible") |
52 | 40 | }
|
53 | 41 |
|
54 | 42 | test_compiler_srcjar_nonhermetic() {
|
55 | 43 | set -o pipefail
|
56 | 44 | local SCALA_VERSION="$1"
|
57 | 45 |
|
58 |
| - run_in_test_repo "bazel build //... --repo_env=SCALA_VERSION=${SCALA_VERSION} //..." "test_dt_patches_user_srcjar" 2>&1 | grep "canonical reproducible" |
| 46 | + run_in_test_repo \ |
| 47 | + test_dt_patches_user_srcjar \ |
| 48 | + bazel build "--repo_env=SCALA_VERSION=${SCALA_VERSION}" //... 2>&1 | |
| 49 | + grep 'canonical reproducible' |
59 | 50 | }
|
60 | 51 |
|
61 | 52 | test_compiler_srcjar_error() {
|
62 | 53 | local SCALA_VERSION="$1"
|
63 |
| - local EXPECTED_ERROR="scala_compiler_srcjar invalid" |
64 | 54 |
|
65 |
| - run_in_test_repo "bazel build //... --repo_env=SCALA_VERSION=${SCALA_VERSION} //..." "test_dt_patches_user_srcjar" 2>&1 | grep "$EXPECTED_ERROR" |
| 55 | + run_in_test_repo \ |
| 56 | + test_dt_patches_user_srcjar \ |
| 57 | + action_should_fail_with_message \ |
| 58 | + 'scala_compiler_srcjar invalid' \ |
| 59 | + build "--repo_env=SCALA_VERSION=${SCALA_VERSION}" //... |
66 | 60 | }
|
67 | 61 |
|
68 |
| -#run_test_local test_compiler_patch 2.11.0 |
69 |
| -#run_test_local test_compiler_patch 2.11.1 |
70 |
| -#run_test_local test_compiler_patch 2.11.2 |
71 |
| -#run_test_local test_compiler_patch 2.11.3 |
72 |
| -#run_test_local test_compiler_patch 2.11.4 |
73 |
| -#run_test_local test_compiler_patch 2.11.5 |
74 |
| -#run_test_local test_compiler_patch 2.11.6 |
75 |
| -#run_test_local test_compiler_patch 2.11.7 |
76 |
| -#run_test_local test_compiler_patch 2.11.8 |
77 |
| -#run_test_local test_compiler_patch 2.11.9 |
78 |
| -#run_test_local test_compiler_patch 2.11.10 |
79 |
| -#run_test_local test_compiler_patch 2.11.11 |
80 |
| -run_test_local test_compiler_patch 2.11.12 |
81 |
| - |
82 |
| -#run_test_local test_compiler_patch 2.12.0 |
83 |
| -run_test_local test_compiler_patch 2.12.1 |
84 |
| -run_test_local test_compiler_patch 2.12.2 |
85 |
| -run_test_local test_compiler_patch 2.12.3 |
86 |
| -run_test_local test_compiler_patch 2.12.4 |
87 |
| -run_test_local test_compiler_patch 2.12.5 |
88 |
| -run_test_local test_compiler_patch 2.12.6 |
89 |
| -run_test_local test_compiler_patch 2.12.7 |
90 |
| -run_test_local test_compiler_patch 2.12.8 |
91 |
| -run_test_local test_compiler_patch 2.12.9 |
92 |
| -run_test_local test_compiler_patch 2.12.10 |
93 |
| -run_test_local test_compiler_patch 2.12.11 |
94 |
| -run_test_local test_compiler_patch 2.12.12 |
95 |
| -run_test_local test_compiler_patch 2.12.13 |
96 |
| -run_test_local test_compiler_patch 2.12.14 |
97 |
| -run_test_local test_compiler_patch 2.12.15 |
98 |
| -run_test_local test_compiler_patch 2.12.16 |
99 |
| -run_test_local test_compiler_patch 2.12.17 |
100 |
| -run_test_local test_compiler_patch 2.12.18 |
101 |
| -run_test_local test_compiler_patch 2.12.19 |
102 |
| -run_test_local test_compiler_patch 2.12.20 |
103 |
| - |
104 |
| -run_test_local test_compiler_patch 2.13.0 |
105 |
| -run_test_local test_compiler_patch 2.13.1 |
106 |
| -run_test_local test_compiler_patch 2.13.2 |
107 |
| -run_test_local test_compiler_patch 2.13.3 |
108 |
| -run_test_local test_compiler_patch 2.13.4 |
109 |
| -run_test_local test_compiler_patch 2.13.5 |
110 |
| -run_test_local test_compiler_patch 2.13.6 |
111 |
| -run_test_local test_compiler_patch 2.13.7 |
112 |
| -run_test_local test_compiler_patch 2.13.8 |
113 |
| -run_test_local test_compiler_patch 2.13.10 |
114 |
| -run_test_local test_compiler_patch 2.13.11 |
115 |
| -run_test_local test_compiler_patch 2.13.12 |
116 |
| -run_test_local test_compiler_patch 2.13.14 |
117 |
| -run_test_local test_compiler_patch 2.13.15 |
118 |
| -run_test_local test_compiler_patch 2.13.16 |
119 |
| - |
120 |
| -run_test_local test_compiler_patch 3.1.0 # Minimal supported version |
121 |
| -run_test_local test_compiler_patch 3.1.3 |
122 |
| -run_test_local test_compiler_patch 3.2.2 |
123 |
| -run_test_local test_compiler_patch 3.3.6 |
124 |
| -run_test_local test_compiler_patch 3.4.3 |
125 |
| -run_test_local test_compiler_patch 3.5.2 |
126 |
| -run_test_local test_compiler_patch 3.6.4 |
127 |
| -run_test_local test_compiler_patch 3.7.0 |
128 |
| - |
129 |
| -run_test_local test_compiler_srcjar_error 2.12.11 |
130 |
| -run_test_local test_compiler_srcjar_error 2.12.12 |
131 |
| -run_test_local test_compiler_srcjar_error 2.12.13 |
| 62 | +#$runner test_compiler_patch 2.11.0 |
| 63 | +#$runner test_compiler_patch 2.11.1 |
| 64 | +#$runner test_compiler_patch 2.11.2 |
| 65 | +#$runner test_compiler_patch 2.11.3 |
| 66 | +#$runner test_compiler_patch 2.11.4 |
| 67 | +#$runner test_compiler_patch 2.11.5 |
| 68 | +#$runner test_compiler_patch 2.11.6 |
| 69 | +#$runner test_compiler_patch 2.11.7 |
| 70 | +#$runner test_compiler_patch 2.11.8 |
| 71 | +#$runner test_compiler_patch 2.11.9 |
| 72 | +#$runner test_compiler_patch 2.11.10 |
| 73 | +#$runner test_compiler_patch 2.11.11 |
| 74 | +$runner test_compiler_patch 2.11.12 |
| 75 | + |
| 76 | +#$runner test_compiler_patch 2.12.0 |
| 77 | +$runner test_compiler_patch 2.12.1 |
| 78 | +$runner test_compiler_patch 2.12.2 |
| 79 | +$runner test_compiler_patch 2.12.3 |
| 80 | +$runner test_compiler_patch 2.12.4 |
| 81 | +$runner test_compiler_patch 2.12.5 |
| 82 | +$runner test_compiler_patch 2.12.6 |
| 83 | +$runner test_compiler_patch 2.12.7 |
| 84 | +$runner test_compiler_patch 2.12.8 |
| 85 | +$runner test_compiler_patch 2.12.9 |
| 86 | +$runner test_compiler_patch 2.12.10 |
| 87 | +$runner test_compiler_patch 2.12.11 |
| 88 | +$runner test_compiler_patch 2.12.12 |
| 89 | +$runner test_compiler_patch 2.12.13 |
| 90 | +$runner test_compiler_patch 2.12.14 |
| 91 | +$runner test_compiler_patch 2.12.15 |
| 92 | +$runner test_compiler_patch 2.12.16 |
| 93 | +$runner test_compiler_patch 2.12.17 |
| 94 | +$runner test_compiler_patch 2.12.18 |
| 95 | +$runner test_compiler_patch 2.12.19 |
| 96 | +$runner test_compiler_patch 2.12.20 |
| 97 | + |
| 98 | +$runner test_compiler_patch 2.13.0 |
| 99 | +$runner test_compiler_patch 2.13.1 |
| 100 | +$runner test_compiler_patch 2.13.2 |
| 101 | +$runner test_compiler_patch 2.13.3 |
| 102 | +$runner test_compiler_patch 2.13.4 |
| 103 | +$runner test_compiler_patch 2.13.5 |
| 104 | +$runner test_compiler_patch 2.13.6 |
| 105 | +$runner test_compiler_patch 2.13.7 |
| 106 | +$runner test_compiler_patch 2.13.8 |
| 107 | +$runner test_compiler_patch 2.13.10 |
| 108 | +$runner test_compiler_patch 2.13.11 |
| 109 | +$runner test_compiler_patch 2.13.12 |
| 110 | +$runner test_compiler_patch 2.13.14 |
| 111 | +$runner test_compiler_patch 2.13.15 |
| 112 | +$runner test_compiler_patch 2.13.16 |
| 113 | + |
| 114 | +$runner test_compiler_patch 3.1.0 # Minimal supported version |
| 115 | +$runner test_compiler_patch 3.1.3 |
| 116 | +$runner test_compiler_patch 3.2.2 |
| 117 | +$runner test_compiler_patch 3.3.6 |
| 118 | +$runner test_compiler_patch 3.4.3 |
| 119 | +$runner test_compiler_patch 3.5.2 |
| 120 | +$runner test_compiler_patch 3.6.4 |
| 121 | +$runner test_compiler_patch 3.7.0 |
| 122 | + |
| 123 | +$runner test_compiler_srcjar_error 2.12.11 |
| 124 | +$runner test_compiler_srcjar_error 2.12.12 |
| 125 | +$runner test_compiler_srcjar_error 2.12.13 |
132 | 126 |
|
133 | 127 | # These tests are semi-stateful, if two tests are run sequentially with the
|
134 | 128 | # same Scala version, the DEBUG message about a canonical reproducible form
|
135 | 129 | # that we grep for will only be outputted the first time (on Bazel >= 6).
|
136 | 130 | # So we clean the repo first to ensure consistency.
|
137 | 131 |
|
138 |
| -run_in_test_repo "bazel clean --expunge" "test_dt_patches_user_srcjar" |
139 |
| - |
140 |
| -run_test_local test_compiler_srcjar 2.12.14 |
141 |
| -run_test_local test_compiler_srcjar 2.12.15 |
142 |
| -run_test_local test_compiler_srcjar 2.12.16 |
143 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.12.17 |
144 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.12.18 |
145 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.12.19 |
146 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.12.20 |
147 |
| - |
148 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.13.11 |
149 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.13.12 |
150 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.13.14 |
151 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.13.15 |
152 |
| -run_test_local test_compiler_srcjar_nonhermetic 2.13.16 |
153 |
| - |
154 |
| -run_test_local test_compiler_srcjar 3.1.3 |
155 |
| -run_test_local test_compiler_srcjar 3.2.2 |
156 |
| -run_test_local test_compiler_srcjar_nonhermetic 3.3.6 |
157 |
| -run_test_local test_compiler_srcjar 3.4.3 |
158 |
| -run_test_local test_compiler_srcjar_nonhermetic 3.5.2 |
159 |
| -run_test_local test_compiler_srcjar_nonhermetic 3.6.4 |
160 |
| -run_test_local test_compiler_srcjar_nonhermetic 3.7.0 |
| 132 | +run_in_test_repo 'test_dt_patches_user_srcjar' bazel clean --expunge |
| 133 | + |
| 134 | +$runner test_compiler_srcjar 2.12.14 |
| 135 | +$runner test_compiler_srcjar 2.12.15 |
| 136 | +$runner test_compiler_srcjar 2.12.16 |
| 137 | +$runner test_compiler_srcjar_nonhermetic 2.12.17 |
| 138 | +$runner test_compiler_srcjar_nonhermetic 2.12.18 |
| 139 | +$runner test_compiler_srcjar_nonhermetic 2.12.19 |
| 140 | +$runner test_compiler_srcjar_nonhermetic 2.12.20 |
| 141 | + |
| 142 | +$runner test_compiler_srcjar_nonhermetic 2.13.11 |
| 143 | +$runner test_compiler_srcjar_nonhermetic 2.13.12 |
| 144 | +$runner test_compiler_srcjar_nonhermetic 2.13.14 |
| 145 | +$runner test_compiler_srcjar_nonhermetic 2.13.15 |
| 146 | +$runner test_compiler_srcjar_nonhermetic 2.13.16 |
| 147 | + |
| 148 | +$runner test_compiler_srcjar 3.1.3 |
| 149 | +$runner test_compiler_srcjar 3.2.2 |
| 150 | +$runner test_compiler_srcjar_nonhermetic 3.3.6 |
| 151 | +$runner test_compiler_srcjar 3.4.3 |
| 152 | +$runner test_compiler_srcjar_nonhermetic 3.5.2 |
| 153 | +$runner test_compiler_srcjar_nonhermetic 3.6.4 |
| 154 | +$runner test_compiler_srcjar_nonhermetic 3.7.0 |
0 commit comments