1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Test utilities for AGPM
//!
//! This module provides utilities for writing tests, including helpers for
//! managing test environments, temporary directories, and test isolation.
//!
//! # Test Isolation
//!
//! The utilities in this module help ensure tests don't interfere with each other:
//! - Temporary directory management
//! - Environment variable isolation
//! - Test fixtures for manifests, lockfiles, and markdown files
//! - Complete test environments with mock git repositories
//!
//! # Example
//!
//! ```rust,no_run
//! #[cfg(test)]
//! mod tests {
//!
//! #[test]
//! fn test_with_environment() {
//! let env = TestEnvironment::with_basic_manifest().unwrap();
//!
//! // Use the test environment
//! assert!(env.file_exists("agpm.toml"));
//! }
//! }
//! ```
pub use ;
pub use TestEnvironment;
pub use ;
pub use TestGit;
use Once;
use Level;
use EnvFilter;
/// Global flag to ensure logging is only initialized once in tests
static INIT_LOGGING: Once = new;
/// Initialize logging for tests.
///
/// This function initializes the tracing subscriber for tests, but only once
/// regardless of how many times it's called. It respects the `RUST_LOG` environment
/// variable if set, or uses the provided log level.
///
/// # Arguments
///
/// * `level` - Optional log level to use. If None, uses `RUST_LOG` environment variable
///
/// # Example
///
/// ```rust,no_run
/// use tracing::Level;
///
/// fn my_test() {
/// // Use environment variable
/// agpm_cli::test_utils::init_test_logging(None);
///
/// // Or set level programmatically
/// agpm_cli::test_utils::init_test_logging(Some(Level::DEBUG));
///
/// // Your test code here - logging will work
/// }
/// ```
///
/// To enable logging in tests via environment variable:
/// ```bash
/// RUST_LOG=debug cargo test
/// ```