Remove the overlay hack from Rust conformance test now that we can use the enum directly.

PiperOrigin-RevId: 604226236
pull/15695/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent d67f921f90
commit 4cbe13b5c6
  1. 28
      conformance/conformance_rust.rs
  2. 10
      conformance/conformance_rust_overlay_hack.proto

@ -4,8 +4,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
use conformance_proto::{ConformanceRequest, ConformanceResponse}; use conformance_proto::{ConformanceRequest, ConformanceResponse, WireFormat};
use conformance_rust_overlay_hack_proto::ConformanceRequestRustOverlayHack;
#[cfg(cpp_kernel)] #[cfg(cpp_kernel)]
use protobuf_cpp as kernel; use protobuf_cpp as kernel;
@ -40,21 +39,13 @@ fn read_little_endian_i32_from_stdin() -> Option<i32> {
/// Returns None if we have hit an EOF that suggests the test suite is complete. /// Returns None if we have hit an EOF that suggests the test suite is complete.
/// Panics in any other case (e.g. an EOF in a place that would imply a /// Panics in any other case (e.g. an EOF in a place that would imply a
/// programmer error in the conformance test suite). /// programmer error in the conformance test suite).
fn read_request_from_stdin() -> Option<(ConformanceRequest, ConformanceRequestRustOverlayHack)> { fn read_request_from_stdin() -> Option<ConformanceRequest> {
let msg_len = read_little_endian_i32_from_stdin()?; let msg_len = read_little_endian_i32_from_stdin()?;
let mut serialized = vec![0_u8; msg_len as usize]; let mut serialized = vec![0_u8; msg_len as usize];
io::stdin().read_exact(&mut serialized).unwrap(); io::stdin().read_exact(&mut serialized).unwrap();
let mut req = ConformanceRequest::new(); let mut req = ConformanceRequest::new();
req.deserialize(&serialized).unwrap(); req.deserialize(&serialized).unwrap();
Some(req)
// TODO: b/318373255 - Since enum accessors aren't available yet, we parse an
// overlay with int32 field instead of an enum so that we can check if the
// requested output is binary or not. This will be deleted once enum
// accessors are supported.
let mut req_overlay_hack = ConformanceRequestRustOverlayHack::new();
req_overlay_hack.deserialize(&serialized).unwrap();
Some((req, req_overlay_hack))
} }
fn write_response_to_stdout(resp: &ConformanceResponse) { fn write_response_to_stdout(resp: &ConformanceResponse) {
@ -66,16 +57,11 @@ fn write_response_to_stdout(resp: &ConformanceResponse) {
handle.flush().unwrap(); handle.flush().unwrap();
} }
fn do_test( fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
req: &ConformanceRequest,
req_overlay_hack: &ConformanceRequestRustOverlayHack,
) -> ConformanceResponse {
let mut resp = ConformanceResponse::new(); let mut resp = ConformanceResponse::new();
let message_type = req.message_type(); let message_type = req.message_type();
// TODO: b/318373255 - Use the enum once its supported. if req.requested_output_format() != WireFormat::Protobuf {
// if req.requested_output_format() != WireFormat.PROTOBUF {
if req_overlay_hack.requested_output_format() != 1 {
resp.skipped_mut().set("only wire format output implemented"); resp.skipped_mut().set("only wire format output implemented");
return resp; return resp;
} }
@ -130,8 +116,8 @@ fn do_test(
fn main() { fn main() {
let mut total_runs = 0; let mut total_runs = 0;
while let Some((req, req_overlay_hack)) = read_request_from_stdin() { while let Some(req) = read_request_from_stdin() {
let resp = do_test(&req, &req_overlay_hack); let resp = do_test(&req);
write_response_to_stdout(&resp); write_response_to_stdout(&resp);
total_runs += 1; total_runs += 1;
} }

@ -1,10 +0,0 @@
syntax = "proto3";
package conformance;
// Temporary hack to allow the Rust conformance test to read the requested
// output format as an int32. This will be removed once enums accessors are
// supported. b/318373255
message ConformanceRequestRustOverlayHack {
int32 requested_output_format = 3;
}
Loading…
Cancel
Save