@@ -21,14 +21,24 @@ function test_dependency_aggregation() {
21
21
22
22
function test_duplicate_version_warning() {
23
23
bazel run @duplicate_version_warning//:pin >> " $TEST_LOG " 2>&1
24
- rm -f duplicate_version_warning_install.json
24
+ rm -f * duplicate_version_warning_install.json
25
25
26
26
expect_log " Found duplicate artifact versions"
27
27
expect_log " com.fasterxml.jackson.core:jackson-annotations has multiple versions"
28
28
expect_log " com.github.jnr:jffi:native has multiple versions"
29
29
expect_log " Successfully pinned resolved artifacts"
30
30
}
31
31
32
+ function test_duplicate_version_warning_same_version() {
33
+ bazel run @duplicate_version_warning_same_version//:pin >> " $TEST_LOG " 2>&1
34
+ rm -f * duplicate_version_warning_same_version_install.json
35
+
36
+ expect_not_log " Found duplicate artifact versions"
37
+ expect_not_log " com.fasterxml.jackson.core:jackson-annotations has multiple versions"
38
+ expect_not_log " com.github.jnr:jffi:native has multiple versions"
39
+ expect_log " Successfully pinned resolved artifacts"
40
+ }
41
+
32
42
function test_m2local_testing_ignore_empty_files() {
33
43
# Testing ignore_empty_files with m2local, as it's the easiest way to imitate an empty jar file.
34
44
m2local_dir=" ${HOME} /.m2/repository"
@@ -47,9 +57,9 @@ function test_m2local_testing_ignore_empty_files() {
47
57
force_bzlmod_lock_file_to_be_regenerated
48
58
49
59
bazel run @m2local_testing_ignore_empty_files//:pin >> " $TEST_LOG " 2>&1
50
- expect_not_in_file ' "sources": "' m2local_testing_ignore_empty_files_install.json
60
+ expect_not_in_file ' "sources": "' * m2local_testing_ignore_empty_files_install.json
51
61
52
- rm -f m2local_testing_ignore_empty_files_install.json
62
+ rm -f * m2local_testing_ignore_empty_files_install.json
53
63
rm -rf ${jar_dir}
54
64
55
65
expect_log " Assuming maven local for artifact: com.example:kt:1.0.0"
@@ -95,7 +105,7 @@ function test_m2local_testing_found_local_artifact_through_pin_and_build() {
95
105
force_bzlmod_lock_file_to_be_regenerated
96
106
97
107
bazel build @m2local_testing//:com_example_kt >> " $TEST_LOG " 2>&1
98
- rm -f m2local_testing_install.json
108
+ rm -f * m2local_testing_install.json
99
109
rm -rf ${jar_dir}
100
110
101
111
expect_log " Assuming maven local for artifact: com.example:kt:1.0.0"
@@ -118,7 +128,6 @@ function test_unpinned_m2local_testing_found_local_artifact_through_pin_and_buil
118
128
force_bzlmod_lock_file_to_be_regenerated
119
129
120
130
bazel build @m2local_testing_repin//:com_example_kt >> " $TEST_LOG " 2>&1
121
- rm -f m2local_testing_install.json
122
131
rm -rf ${jar_dir}
123
132
124
133
expect_log " Assuming maven local for artifact: com.example:kt:1.0.0"
@@ -174,13 +183,28 @@ function test_m2local_testing_found_local_artifact_after_build_copy() {
174
183
expect_log " Assuming maven local for artifact: com.example:kt:1.0.0"
175
184
}
176
185
177
- function test_duplicate_version_warning_same_version() {
178
- bazel run @duplicate_version_warning_same_version//:pin >> " $TEST_LOG " 2>&1
179
- rm -f duplicate_version_warning_same_version_install.json
186
+ function test_found_artifact_with_plus_through_pin_and_build() {
187
+ bazel clean --expunge >> " $TEST_LOG " 2>&1 # for https://github.com/bazelbuild/rules_jvm_external/issues/800
188
+ bazel run @artifact_with_plus//:pin >> " $TEST_LOG " 2>&1
189
+
190
+ force_bzlmod_lock_file_to_be_regenerated
191
+
192
+ bazel build @artifact_with_plus//:ch_epfl_scala_compiler_interface >> " $TEST_LOG " 2>&1
193
+ rm -f * artifact_with_plus_install.json
194
+
195
+ expect_log " Successfully pinned resolved artifacts"
196
+ }
197
+
198
+ function test_unpinned_found_artifact_with_plus_through_pin_and_build() {
199
+ # Force the repo rule to be evaluated again. Without this, the "assuming maven local..." message will not be printed
200
+ bazel clean --expunge > /dev/null 2>&1
201
+
202
+ bazel run @unpinned_artifact_with_plus_repin//:pin >> " $TEST_LOG " 2>&1
203
+
204
+ force_bzlmod_lock_file_to_be_regenerated
205
+
206
+ bazel build @artifact_with_plus_repin//:ch_epfl_scala_compiler_interface >> " $TEST_LOG " 2>&1
180
207
181
- expect_not_log " Found duplicate artifact versions"
182
- expect_not_log " com.fasterxml.jackson.core:jackson-annotations has multiple versions"
183
- expect_not_log " com.github.jnr:jffi:native has multiple versions"
184
208
expect_log " Successfully pinned resolved artifacts"
185
209
}
186
210
@@ -223,6 +247,8 @@ TESTS=(
223
247
" test_m2local_testing_found_local_artifact_after_build_copy"
224
248
" test_m2local_testing_ignore_empty_files"
225
249
" test_unpinned_m2local_testing_ignore_empty_files"
250
+ " test_found_artifact_with_plus_through_pin_and_build"
251
+ " test_unpinned_found_artifact_with_plus_through_pin_and_build"
226
252
" test_v1_lock_file_format"
227
253
" test_dependency_pom_exclusion"
228
254
)
@@ -243,6 +269,11 @@ function run_tests() {
243
269
function expect_not_in_file() {
244
270
local pattern=$1
245
271
local file=$2
272
+ if [ ! -f $file ]; then
273
+ printf " NOT FOUND: $file (most probably wrong test configuration)\n"
274
+ return 1
275
+ fi
276
+
246
277
local message=${3:- Expected not to find regexp \" " $pattern " \" , but it was found}
247
278
grep -sq -- " $pattern " $file || return 0
248
279
0 commit comments