Skip to content

Commit b2e897d

Browse files
committed
ignore file truncate error
1 parent 3d56a4f commit b2e897d

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

opentelemetry-otlp/tests/integration_test/src/test_utils.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//!
1919
#![cfg(unix)]
2020

21+
use anyhow::Ok;
2122
use anyhow::Result;
2223
use opentelemetry::{otel_debug, otel_info};
2324
use std::fs;
@@ -130,19 +131,11 @@ fn upsert_empty_file(path: &str) -> File {
130131
///
131132
/// This function is meant to cleanup the generated json file before a test starts,
132133
/// preventing entries from previous tests from interfering with the current test's results.
133-
pub fn cleanup_logs_file(file_path: &str) -> Result<()> {
134-
let file = OpenOptions::new()
134+
pub fn cleanup_logs_file(file_path: &str) {
135+
let _ = OpenOptions::new()
135136
.write(true)
136137
.truncate(true)
137-
.open(file_path);
138-
match file {
139-
Ok(_) => Ok(()),
140-
Err(err) => Err(anyhow::anyhow!(
141-
"Failed to clean up file '{}': {:?}",
142-
file_path,
143-
err
144-
)),
145-
}
138+
.open(file_path); // ignore result, as file may not exist
146139
}
147140

148141
///

opentelemetry-otlp/tests/integration_test/tests/logs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod logtests {
7272
#[cfg(not(feature = "reqwest-client"))]
7373
#[serial_test::serial]
7474
pub async fn test_logs() -> Result<()> {
75-
test_utils::cleanup_logs_file("./actual/logs.json")?; // Ensure logs.json is empty before the test
75+
test_utils::cleanup_logs_file("./actual/logs.json"); // Ensure logs.json is empty before the test
7676

7777
// Make sure the container is running
7878
use integration_test_runner::test_utils;
@@ -102,7 +102,7 @@ mod logtests {
102102
#[serial_test::serial]
103103
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
104104
pub fn logs_batch_non_tokio_main() -> Result<()> {
105-
test_utils::cleanup_logs_file("./actual/logs.json")?; // Ensure logs.json is empty before the test
105+
test_utils::cleanup_logs_file("./actual/logs.json"); // Ensure logs.json is empty before the test
106106

107107
// Initialize the logger provider inside a tokio runtime
108108
// as this allows tonic client to capture the runtime,

0 commit comments

Comments
 (0)