This turns out to be quite of a yak shave to be able to perfectly test both kernels without having to pass extra Blaze flags. PiperOrigin-RevId: 521850709pull/12404/head
parent
db7c7349ea
commit
f7a2f4acea
12 changed files with 280 additions and 48 deletions
@ -0,0 +1,46 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2023 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//! Rust Protobuf Runtime
|
||||
//!
|
||||
//! This file forwards to the kernel specific implementation. Rust Protobuf
|
||||
//! gencode actually depends directly on kernel specific crates. The only reason
|
||||
//! this crate exists is to be able to use `protobuf` as a crate name for both
|
||||
//! cpp and upb kernels from user code.
|
||||
|
||||
#[cfg(cpp_kernel)] |
||||
pub use protobuf_cpp::__runtime; |
||||
#[cfg(cpp_kernel)] |
||||
pub use protobuf_cpp::*; |
||||
|
||||
#[cfg(upb_kernel)] |
||||
pub use protobuf_upb::__runtime; |
||||
#[cfg(upb_kernel)] |
||||
pub use protobuf_upb::*; |
@ -0,0 +1,11 @@ |
||||
# Tests specific to cpp kernel. |
||||
# |
||||
# Only add tests that are cpp kernel specific and it is not possible to make them work for upb ( |
||||
# for example tests exercising ABI compatibility with C++ Protobuf API). |
||||
# |
||||
# All the tests under this package should ignore |
||||
# `//rust:rust_proto_library_kernel` flag and should always select `cpp`. |
||||
# |
||||
# To do that use: |
||||
# * `rust_cc_proto_library` instead of `rust_proto_library`. |
||||
# * `//rust:protobuf_cpp` instead of `//rust:protobuf``. |
@ -0,0 +1,79 @@ |
||||
# Tests that are exercising and should pass with both kernels. |
||||
# |
||||
# All the tests under this package should ignore |
||||
# `//rust:rust_proto_library_kernel` flag and should always cover both |
||||
# kernels. |
||||
# |
||||
# To do that: |
||||
# * Declare 2 rust_test targets and share the same sources from both. |
||||
# * First copy will only depend on `rust_cc_proto_library` Rust proto targets, and if needed will |
||||
# only depend on `//rust:protobuf_cpp. |
||||
# * Second copy will only depend on `rust_upb_proto_library` Rust proto targets, and if needed will |
||||
# only depend on `//rust:protobuf_upb |
||||
# |
||||
# Once we have a couple of these tests we will investigate ways to remove boilerplate (for example |
||||
# by introducing a build macro that registers 2 rust_test targets). |
||||
|
||||
load("@rules_rust//rust:defs.bzl", "rust_test") |
||||
|
||||
rust_test( |
||||
name = "unittest_proto_upb_test", |
||||
srcs = ["unittest_proto_test.rs"], |
||||
tags = [ |
||||
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. |
||||
"not_build:arm", |
||||
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust. |
||||
"notsan", |
||||
# TODO(b/243126140): Enable msan once we support sanitizers with Rust. |
||||
"nomsan", |
||||
], |
||||
deps = ["//rust/test:unittest_upb_rust_proto"], |
||||
) |
||||
|
||||
rust_test( |
||||
name = "unittest_proto_cpp_test", |
||||
srcs = ["unittest_proto_test.rs"], |
||||
tags = [ |
||||
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. |
||||
"not_build:arm", |
||||
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust. |
||||
"notsan", |
||||
# TODO(b/243126140): Enable msan once we support sanitizers with Rust. |
||||
"nomsan", |
||||
], |
||||
deps = ["//rust/test:unittest_cc_rust_proto"], |
||||
) |
||||
|
||||
rust_test( |
||||
name = "child_parent_upb_test", |
||||
srcs = ["child_parent_test.rs"], |
||||
tags = [ |
||||
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. |
||||
"not_build:arm", |
||||
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust. |
||||
"notsan", |
||||
# TODO(b/243126140): Enable msan once we support sanitizers with Rust. |
||||
"nomsan", |
||||
], |
||||
deps = [ |
||||
"//rust/test:child_upb_rust_proto", |
||||
"//rust/test:parent_upb_rust_proto", |
||||
], |
||||
) |
||||
|
||||
rust_test( |
||||
name = "child_parent_cpp_test", |
||||
srcs = ["child_parent_test.rs"], |
||||
tags = [ |
||||
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. |
||||
"not_build:arm", |
||||
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust. |
||||
"notsan", |
||||
# TODO(b/243126140): Enable msan once we support sanitizers with Rust. |
||||
"nomsan", |
||||
], |
||||
deps = [ |
||||
"//rust/test:child_cc_rust_proto", |
||||
"//rust/test:parent_cc_rust_proto", |
||||
], |
||||
) |
@ -0,0 +1,11 @@ |
||||
# Tests specific to upb kernel. |
||||
# |
||||
# Only add tests that are cpp kernel specific and it is not possible to make them work for upb ( |
||||
# for example tests exercising ABI compatibility with other UPB-based Protobuf implementations). |
||||
# |
||||
# All the tests under this package should ignore |
||||
# `//rust:rust_proto_library_kernel` flag and should always select `upb`. |
||||
# |
||||
# To do that use: |
||||
# * `rust_upb_proto_library` instead of `rust_proto_library`. |
||||
# * `//rust:protobuf_upb` instead of `//rust:protobuf``. |
Loading…
Reference in new issue