fix(logging): handle global subscriber conflict in test

The init_creates_log_directory_and_file test called init() which sets a
global tracing subscriber. When tests run in parallel, other tests may
have already set the subscriber, causing init() to return an error and
the test to fail. Now the test tolerates the 'already set' error while
still asserting the log file is created.
This commit is contained in:
2026-06-12 04:29:28 +00:00
parent f9d7b8112b
commit 667495cf43

View File

@@ -105,8 +105,13 @@ mod tests {
log_file_path: Some(log_path.to_string_lossy().to_string()), log_file_path: Some(log_path.to_string_lossy().to_string()),
}; };
let result = init(&config); if let Err(e) = init(&config) {
assert!(result.is_ok(), "init failed: {:?}", result.err()); let msg = format!("{e}");
assert!(
msg.contains("global default trace dispatcher") || msg.contains("already been set"),
"unexpected init error: {e}"
);
}
assert!(log_path.exists(), "log file should be created"); assert!(log_path.exists(), "log file should be created");
} }
} }