
- Create unit test and integration tests for logs in separate tests - Centralize temporary log file creation in common.rs - Remove redundant logging initialization code from common.rs - Update all test files to handle their own logging initialization - Add detailed debug logging throughout test execution - Add log file content display for better test debugging - Standardize error handling across test files Changes: - Create setup_test_log_file() helper in common.rs - Remove setup_test_logging() and setup_temp_log() functions - Update test files to use common setup_test_log_file(): - test_log_detail_macro.rs - test_log_timed_macro.rs - test_different_log_levels.rs - test_init_logging_with_file.rs - test_init_logging_append_mode.rs This change improves test maintainability by: 1. Reducing code duplication 2. Making test behavior more explicit 3. Improving test output for debugging 4. Following single responsibility principle
13 lines
469 B
Rust
13 lines
469 B
Rust
use std::path::PathBuf;
|
|
use tempfile::TempDir;
|
|
|
|
/// Sets up a temporary directory and log file for testing
|
|
/// Returns:
|
|
/// - TempDir: The temporary directory (keep this in scope to prevent cleanup)
|
|
/// - PathBuf: Path to the log file
|
|
pub fn setup_test_log_file() -> (TempDir, PathBuf) {
|
|
let temp_dir = tempfile::TempDir::new().expect("Failed to create temporary directory for test");
|
|
let log_path = temp_dir.path().join("test.log");
|
|
(temp_dir, log_path)
|
|
}
|