| 1 |
# Conformance testing for Protobuf. |
| 2 |
|
| 3 |
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "objc_library") |
| 4 |
load("@rules_ruby//ruby:defs.bzl", "ruby_binary") |
| 5 |
load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library") |
| 6 |
load("//build_defs:internal_shell.bzl", "inline_sh_binary") |
| 7 |
load( |
| 8 |
"@rules_pkg//:mappings.bzl", |
| 9 |
"pkg_filegroup", |
| 10 |
"pkg_files", |
| 11 |
"strip_prefix", |
| 12 |
) |
| 13 |
|
| 14 |
exports_files([ |
| 15 |
"bazel_conformance_test_runner.sh", |
| 16 |
"failure_list_cpp.txt", |
| 17 |
"failure_list_csharp.txt", |
| 18 |
"failure_list_java.txt", |
| 19 |
"failure_list_java_lite.txt", |
| 20 |
"failure_list_objc.txt", |
| 21 |
"failure_list_php.txt", |
| 22 |
"failure_list_php_c.txt", |
| 23 |
"failure_list_python.txt", |
| 24 |
"failure_list_python_cpp.txt", |
| 25 |
"failure_list_ruby.txt", |
| 26 |
"failure_list_jruby.txt", |
| 27 |
"text_format_failure_list_cpp.txt", |
| 28 |
"text_format_failure_list_csharp.txt", |
| 29 |
"text_format_failure_list_java.txt", |
| 30 |
"text_format_failure_list_java_lite.txt", |
| 31 |
"text_format_failure_list_php.txt", |
| 32 |
"text_format_failure_list_php_c.txt", |
| 33 |
"text_format_failure_list_python.txt", |
| 34 |
"text_format_failure_list_python_cpp.txt", |
| 35 |
"text_format_failure_list_ruby.txt", |
| 36 |
"text_format_failure_list_jruby.txt", |
| 37 |
]) |
| 38 |
|
| 39 |
cc_proto_library( |
| 40 |
name = "test_messages_proto2_proto_cc", |
| 41 |
deps = ["//src/google/protobuf:test_messages_proto2_proto"], |
| 42 |
) |
| 43 |
|
| 44 |
cc_proto_library( |
| 45 |
name = "test_messages_proto3_proto_cc", |
| 46 |
deps = ["//src/google/protobuf:test_messages_proto3_proto"], |
| 47 |
) |
| 48 |
|
| 49 |
proto_library( |
| 50 |
name = "conformance_proto", |
| 51 |
srcs = ["conformance.proto"], |
| 52 |
visibility = ["//visibility:public"], |
| 53 |
) |
| 54 |
|
| 55 |
cc_proto_library( |
| 56 |
name = "conformance_cc_proto", |
| 57 |
deps = [":conformance_proto"], |
| 58 |
) |
| 59 |
|
| 60 |
internal_csharp_proto_library( |
| 61 |
name = "conformance_csharp_proto", |
| 62 |
srcs = ["conformance.proto"], |
| 63 |
visibility = [ |
| 64 |
"//csharp:__subpackages__", |
| 65 |
], |
| 66 |
) |
| 67 |
|
| 68 |
java_proto_library( |
| 69 |
name = "conformance_java_proto", |
| 70 |
visibility = [ |
| 71 |
"//java:__subpackages__", |
| 72 |
], |
| 73 |
deps = [":conformance_proto"], |
| 74 |
) |
| 75 |
|
| 76 |
java_lite_proto_library( |
| 77 |
name = "conformance_java_proto_lite", |
| 78 |
visibility = [ |
| 79 |
"//java:__subpackages__", |
| 80 |
], |
| 81 |
deps = [":conformance_proto"], |
| 82 |
) |
| 83 |
|
| 84 |
internal_objc_proto_library( |
| 85 |
name = "conformance_objc_proto", |
| 86 |
srcs = ["conformance.proto"], |
| 87 |
visibility = [ |
| 88 |
"//conformance:__pkg__", |
| 89 |
"//objc:__pkg__", |
| 90 |
], |
| 91 |
) |
| 92 |
|
| 93 |
internal_py_proto_library( |
| 94 |
name = "conformance_py_proto", |
| 95 |
srcs = ["conformance.proto"], |
| 96 |
srcs_version = "PY2AND3", |
| 97 |
visibility = [ |
| 98 |
"//python:__subpackages__", |
| 99 |
], |
| 100 |
) |
| 101 |
|
| 102 |
internal_php_proto_library( |
| 103 |
name = "conformance_php_proto", |
| 104 |
srcs = ["conformance.proto"], |
| 105 |
outs = [ |
| 106 |
"Conformance/ConformanceRequest.php", |
| 107 |
"Conformance/ConformanceResponse.php", |
| 108 |
"Conformance/FailureSet.php", |
| 109 |
"Conformance/JspbEncodingConfig.php", |
| 110 |
"Conformance/TestCategory.php", |
| 111 |
"Conformance/WireFormat.php", |
| 112 |
"GPBMetadata/Conformance.php", |
| 113 |
], |
| 114 |
visibility = [ |
| 115 |
"//conformance:__pkg__", |
| 116 |
"//php:__pkg__", |
| 117 |
], |
| 118 |
) |
| 119 |
|
| 120 |
internal_ruby_proto_library( |
| 121 |
name = "conformance_ruby_proto", |
| 122 |
srcs = ["conformance.proto"], |
| 123 |
visibility = [ |
| 124 |
"//conformance:__pkg__", |
| 125 |
"//ruby:__pkg__", |
| 126 |
], |
| 127 |
) |
| 128 |
|
| 129 |
cc_library( |
| 130 |
name = "conformance_test", |
| 131 |
srcs = [ |
| 132 |
"conformance_test.cc", |
| 133 |
"conformance_test_runner.cc", |
| 134 |
], |
| 135 |
hdrs = [ |
| 136 |
"conformance_test.h", |
| 137 |
], |
| 138 |
includes = ["."], |
| 139 |
deps = [ |
| 140 |
":conformance_cc_proto", |
| 141 |
"//src/google/protobuf:descriptor_legacy", |
| 142 |
"//src/google/protobuf/util:differencer", |
| 143 |
"//src/google/protobuf/util:json_util", |
| 144 |
"//src/google/protobuf/util:type_resolver_util", |
| 145 |
"@com_google_absl//absl/strings", |
| 146 |
"@com_google_absl//absl/strings:str_format", |
| 147 |
], |
| 148 |
) |
| 149 |
|
| 150 |
cc_library( |
| 151 |
name = "binary_json_conformance_suite", |
| 152 |
srcs = ["binary_json_conformance_suite.cc"], |
| 153 |
hdrs = ["binary_json_conformance_suite.h"], |
| 154 |
deps = [ |
| 155 |
":conformance_test", |
| 156 |
":test_messages_proto2_proto_cc", |
| 157 |
":test_messages_proto3_proto_cc", |
| 158 |
"@com_google_absl//absl/status", |
| 159 |
"@jsoncpp", |
| 160 |
], |
| 161 |
) |
| 162 |
|
| 163 |
cc_library( |
| 164 |
name = "text_format_conformance_suite", |
| 165 |
srcs = ["text_format_conformance_suite.cc"], |
| 166 |
hdrs = ["text_format_conformance_suite.h"], |
| 167 |
deps = [ |
| 168 |
":conformance_test", |
| 169 |
":test_messages_proto2_proto_cc", |
| 170 |
":test_messages_proto3_proto_cc", |
| 171 |
], |
| 172 |
) |
| 173 |
|
| 174 |
cc_binary( |
| 175 |
name = "conformance_test_runner", |
| 176 |
srcs = ["conformance_test_main.cc"], |
| 177 |
visibility = ["//visibility:public"], |
| 178 |
deps = [ |
| 179 |
":binary_json_conformance_suite", |
| 180 |
":conformance_test", |
| 181 |
":text_format_conformance_suite", |
| 182 |
"@com_google_absl//absl/strings:str_format", |
| 183 |
], |
| 184 |
) |
| 185 |
|
| 186 |
cc_binary( |
| 187 |
name = "conformance_cpp", |
| 188 |
testonly = 1, |
| 189 |
srcs = ["conformance_cpp.cc"], |
| 190 |
visibility = ["//src:__subpackages__"], |
| 191 |
deps = [ |
| 192 |
":conformance_cc_proto", |
| 193 |
"//:protobuf", |
| 194 |
"//:test_messages_proto2_cc_proto", |
| 195 |
"//:test_messages_proto3_cc_proto", |
| 196 |
"@com_google_absl//absl/status", |
| 197 |
"@com_google_absl//absl/status:statusor", |
| 198 |
], |
| 199 |
) |
| 200 |
|
| 201 |
java_binary( |
| 202 |
name = "conformance_java", |
| 203 |
testonly = 1, |
| 204 |
srcs = ["ConformanceJava.java"], |
| 205 |
main_class = "ConformanceJava", |
| 206 |
visibility = [ |
| 207 |
"//java:__subpackages__", |
| 208 |
], |
| 209 |
deps = [ |
| 210 |
":conformance_java_proto", |
| 211 |
"//:protobuf_java", |
| 212 |
"//:protobuf_java_util", |
| 213 |
"//:test_messages_proto2_java_proto", |
| 214 |
"//:test_messages_proto3_java_proto", |
| 215 |
], |
| 216 |
) |
| 217 |
|
| 218 |
java_binary( |
| 219 |
name = "conformance_java_lite", |
| 220 |
testonly = 1, |
| 221 |
srcs = ["ConformanceJavaLite.java"], |
| 222 |
main_class = "ConformanceJavaLite", |
| 223 |
visibility = [ |
| 224 |
"//java:__subpackages__", |
| 225 |
], |
| 226 |
deps = [ |
| 227 |
":conformance_java_proto_lite", |
| 228 |
"//:protobuf_java_util", |
| 229 |
"//:protobuf_javalite", |
| 230 |
"//:test_messages_proto2_java_proto_lite", |
| 231 |
"//:test_messages_proto3_java_proto_lite", |
| 232 |
], |
| 233 |
) |
| 234 |
|
| 235 |
py_binary( |
| 236 |
name = "conformance_python", |
| 237 |
testonly = 1, |
| 238 |
srcs = ["conformance_python.py"], |
| 239 |
imports = [ |
| 240 |
"..", |
| 241 |
"../python", |
| 242 |
], |
| 243 |
srcs_version = "PY2AND3", |
| 244 |
visibility = ["//python:__subpackages__"], |
| 245 |
deps = [ |
| 246 |
":conformance_py_proto", |
| 247 |
"//:protobuf_python", |
| 248 |
"//python:test_messages_proto2_py_proto", |
| 249 |
"//python:test_messages_proto3_py_proto", |
| 250 |
], |
| 251 |
) |
| 252 |
|
| 253 |
inline_sh_binary( |
| 254 |
name = "conformance_php", |
| 255 |
testonly = 1, |
| 256 |
srcs = [ |
| 257 |
"autoload.php", |
| 258 |
"conformance_php.php", |
| 259 |
], |
| 260 |
cmd = """ |
| 261 |
php -d include_path=conformance:src/google/protobuf \\ |
| 262 |
-d auto_prepend_file=$(rootpath autoload.php) \\ |
| 263 |
$(rootpath conformance_php.php) |
| 264 |
""", |
| 265 |
visibility = ["//php:__subpackages__"], |
| 266 |
deps = [ |
| 267 |
":conformance_php_proto", |
| 268 |
"//:test_messages_proto3_php_proto", |
| 269 |
"//php:source_files", |
| 270 |
], |
| 271 |
) |
| 272 |
|
| 273 |
inline_sh_binary( |
| 274 |
name = "conformance_php_c", |
| 275 |
testonly = 1, |
| 276 |
srcs = [ |
| 277 |
"conformance_php.php", |
| 278 |
"//php:extension", |
| 279 |
], |
| 280 |
cmd = """ |
| 281 |
php -dextension=$(rootpath //php:extension) \\ |
| 282 |
-d include_path=conformance:src/google/protobuf \\ |
| 283 |
$(rootpath conformance_php.php) |
| 284 |
""", |
| 285 |
visibility = ["//php:__subpackages__"], |
| 286 |
deps = [ |
| 287 |
":conformance_php_proto", |
| 288 |
"//:test_messages_proto3_php_proto", |
| 289 |
], |
| 290 |
) |
| 291 |
|
| 292 |
inline_sh_binary( |
| 293 |
name = "conformance_csharp", |
| 294 |
testonly = 1, |
| 295 |
srcs = ["//csharp/src/Google.Protobuf.Conformance:conformance_dll"], |
| 296 |
cmd = "dotnet $(rootpath //csharp/src/Google.Protobuf.Conformance:conformance_dll)", |
| 297 |
visibility = ["//csharp:__subpackages__"], |
| 298 |
deps = [ |
| 299 |
"//csharp/src/Google.Protobuf.Conformance:conformance_runfiles", |
| 300 |
], |
| 301 |
) |
| 302 |
|
| 303 |
objc_library( |
| 304 |
name = "conformance_objc_lib", |
| 305 |
testonly = 1, |
| 306 |
non_arc_srcs = ["conformance_objc.m"], |
| 307 |
# See https://github.com/bazelbuild/bazel/issues/12897. |
| 308 |
tags = ["manual"], |
| 309 |
deps = [ |
| 310 |
":conformance_objc_proto", |
| 311 |
"//:test_messages_proto2_objc_proto", |
| 312 |
"//:test_messages_proto3_objc_proto", |
| 313 |
], |
| 314 |
) |
| 315 |
|
| 316 |
cc_binary( |
| 317 |
name = "conformance_objc", |
| 318 |
testonly = 1, |
| 319 |
# See https://github.com/bazelbuild/bazel/issues/12897. |
| 320 |
tags = ["manual"], |
| 321 |
visibility = ["//objectivec:__subpackages__"], |
| 322 |
deps = [":conformance_objc_lib"], |
| 323 |
) |
| 324 |
|
| 325 |
ruby_binary( |
| 326 |
name = "conformance_ruby", |
| 327 |
testonly = True, |
| 328 |
srcs = ["conformance_ruby.rb"], |
| 329 |
deps = [ |
| 330 |
":conformance_ruby_proto", |
| 331 |
"//:test_messages_proto2_ruby_proto", |
| 332 |
"//:test_messages_proto3_ruby_proto", |
| 333 |
], |
| 334 |
visibility = ["//ruby:__subpackages__"], |
| 335 |
) |
| 336 |
|
| 337 |
################################################################################ |
| 338 |
# Distribution files |
| 339 |
################################################################################ |
| 340 |
|
| 341 |
filegroup( |
| 342 |
name = "all_files", |
| 343 |
srcs = glob(["**/*"]), |
| 344 |
visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"], |
| 345 |
) |
| 346 |
|
| 347 |
pkg_files( |
| 348 |
name = "dist_files", |
| 349 |
srcs = glob( |
| 350 |
["**/*"], |
| 351 |
exclude = [ |
| 352 |
# Handled by dist_scripts: |
| 353 |
"bazel_conformance_test_runner.sh", |
| 354 |
|
| 355 |
# The following are not in autotools dist: |
| 356 |
"autoload.php", |
| 357 |
"failure_list_jruby.txt", |
| 358 |
"update_failure_list.py", |
| 359 |
], |
| 360 |
), |
| 361 |
strip_prefix = strip_prefix.from_root(""), |
| 362 |
visibility = ["//pkg:__pkg__"], |
| 363 |
) |
| 364 |
|
| 365 |
pkg_filegroup( |
| 366 |
name = "all_dist_files", |
| 367 |
srcs = [ |
| 368 |
":dist_files", |
| 369 |
], |
| 370 |
visibility = ["//pkg:__pkg__"], |
| 371 |
) |