From 4cbe13b5c6abf7062d60d7fcc968a34b7a750ee4 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 5 Feb 2024 00:07:06 -0800 Subject: [PATCH] Remove the overlay hack from Rust conformance test now that we can use the enum directly. PiperOrigin-RevId: 604226236 --- conformance/conformance_rust.rs | 28 +++++-------------- .../conformance_rust_overlay_hack.proto | 10 ------- 2 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 conformance/conformance_rust_overlay_hack.proto diff --git a/conformance/conformance_rust.rs b/conformance/conformance_rust.rs index fdf8252e51..537868490b 100644 --- a/conformance/conformance_rust.rs +++ b/conformance/conformance_rust.rs @@ -4,8 +4,7 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -use conformance_proto::{ConformanceRequest, ConformanceResponse}; -use conformance_rust_overlay_hack_proto::ConformanceRequestRustOverlayHack; +use conformance_proto::{ConformanceRequest, ConformanceResponse, WireFormat}; #[cfg(cpp_kernel)] use protobuf_cpp as kernel; @@ -40,21 +39,13 @@ fn read_little_endian_i32_from_stdin() -> Option { /// 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 /// programmer error in the conformance test suite). -fn read_request_from_stdin() -> Option<(ConformanceRequest, ConformanceRequestRustOverlayHack)> { +fn read_request_from_stdin() -> Option { let msg_len = read_little_endian_i32_from_stdin()?; let mut serialized = vec![0_u8; msg_len as usize]; io::stdin().read_exact(&mut serialized).unwrap(); let mut req = ConformanceRequest::new(); req.deserialize(&serialized).unwrap(); - - // 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)) + Some(req) } fn write_response_to_stdout(resp: &ConformanceResponse) { @@ -66,16 +57,11 @@ fn write_response_to_stdout(resp: &ConformanceResponse) { handle.flush().unwrap(); } -fn do_test( - req: &ConformanceRequest, - req_overlay_hack: &ConformanceRequestRustOverlayHack, -) -> ConformanceResponse { +fn do_test(req: &ConformanceRequest) -> ConformanceResponse { let mut resp = ConformanceResponse::new(); let message_type = req.message_type(); - // TODO: b/318373255 - Use the enum once its supported. - // if req.requested_output_format() != WireFormat.PROTOBUF { - if req_overlay_hack.requested_output_format() != 1 { + if req.requested_output_format() != WireFormat::Protobuf { resp.skipped_mut().set("only wire format output implemented"); return resp; } @@ -130,8 +116,8 @@ fn do_test( fn main() { let mut total_runs = 0; - while let Some((req, req_overlay_hack)) = read_request_from_stdin() { - let resp = do_test(&req, &req_overlay_hack); + while let Some(req) = read_request_from_stdin() { + let resp = do_test(&req); write_response_to_stdout(&resp); total_runs += 1; } diff --git a/conformance/conformance_rust_overlay_hack.proto b/conformance/conformance_rust_overlay_hack.proto deleted file mode 100644 index a897a16fc8..0000000000 --- a/conformance/conformance_rust_overlay_hack.proto +++ /dev/null @@ -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; -}