From eb4b2c6429770cbcebd0e4b462081f4dd7938b5b Mon Sep 17 00:00:00 2001 From: Casper Meijn Date: Fri, 15 Nov 2024 10:26:56 +0100 Subject: [PATCH] test: Rename `invalid_doctest` to `disable_comments` (#1183) This test uses a invalid doctest to confirm `disable_comments` works as expected. Rename the test to what is tested. --- tests/build.rs | 12 ++++-------- ...{invalid_doctest.proto => disable_comments.proto} | 2 +- tests/src/disable_comments.rs | 3 +++ tests/src/lib.rs | 9 +++------ 4 files changed, 11 insertions(+), 15 deletions(-) rename tests/src/{invalid_doctest.proto => disable_comments.proto} (76%) create mode 100644 tests/src/disable_comments.rs diff --git a/tests/build.rs b/tests/build.rs index f90d36588..167be8f11 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -132,14 +132,10 @@ fn main() { .compile_protos(&[src.join("proto3_presence.proto")], includes) .unwrap(); - { - let mut config = prost_build::Config::new(); - config.disable_comments(["."]); - - config - .compile_protos(&[src.join("invalid_doctest.proto")], includes) - .unwrap(); - } + prost_build::Config::new() + .disable_comments(["."]) + .compile_protos(&[src.join("disable_comments.proto")], includes) + .unwrap(); config .bytes(["."]) diff --git a/tests/src/invalid_doctest.proto b/tests/src/disable_comments.proto similarity index 76% rename from tests/src/invalid_doctest.proto rename to tests/src/disable_comments.proto index 9cf0b0829..52adb2093 100644 --- a/tests/src/invalid_doctest.proto +++ b/tests/src/disable_comments.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package invalid.doctest; +package disable_comments; // ``` // invalid diff --git a/tests/src/disable_comments.rs b/tests/src/disable_comments.rs new file mode 100644 index 000000000..7d294163a --- /dev/null +++ b/tests/src/disable_comments.rs @@ -0,0 +1,3 @@ +//! MessageWithInvalidDoctest would generate a invalid doc test if +//! `Config::disable_comments` doesn't work correctly. +include!(concat!(env!("OUT_DIR"), "/disable_comments.rs")); diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 37347eacc..c5dd29ff0 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -59,6 +59,9 @@ mod boxed_field; #[cfg(test)] mod custom_debug; +// Must be `pub` as doc tests are only executed on public types. +pub mod disable_comments; + mod test_enum_named_option_value { include!(concat!(env!("OUT_DIR"), "/myenum.optionn.rs")); } @@ -126,12 +129,6 @@ pub mod proto3 { } } -pub mod invalid { - pub mod doctest { - include!(concat!(env!("OUT_DIR"), "/invalid.doctest.rs")); - } -} - pub mod default_string_escape { include!(concat!(env!("OUT_DIR"), "/default_string_escape.rs")); }