Skip to content

Commit

Permalink
chore(test): Refactor debug implementation for output
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Sep 4, 2024
1 parent 77b8223 commit c16ec31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 0 additions & 16 deletions tests/skip_debug/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,4 @@ fn main() {
.build_server(true)
.compile_protos_with_config(config, &["proto/test.proto"], &["proto"])
.unwrap();

// Add a dummy impl Debug to the skipped debug implementations to avoid missing impl Debug errors
let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
let file_path = out.join("test.rs");
let mut file_contents = std::fs::read_to_string(&file_path).unwrap();
let debug_impl = r#"
impl std::fmt::Debug for Output {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Output").finish()
}
}
"#;
file_contents.push_str(debug_impl);

// Replace the original file with the modified content
std::fs::write(&file_path, file_contents).unwrap();
}
8 changes: 8 additions & 0 deletions tests/skip_debug/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
pub mod pb {
tonic::include_proto!("test");

// Add a dummy impl Debug to the skipped debug implementations to avoid
// missing impl Debug errors and check debug is not implemented for Output.
impl std::fmt::Debug for Output {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Output").finish()
}
}
}

0 comments on commit c16ec31

Please sign in to comment.