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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//! BUG-010: Warnings Shown as Errors - RED Phase Tests
//!
//! These tests verify that warnings are properly displayed:
//! 1. Complete messages (not truncated)
//! 2. Displayed at end (not interleaved with progress)
//! 3. Properly formatted (clear distinction from errors)
//!
//! Current Status: 🔴 RED - These tests will FAIL until warning buffering is implemented
//!
//! Test Strategy (Extreme TDD):
//! 1. RED: Write failing tests for proper warning display
//! 2. GREEN: Implement warning buffering and end-of-analysis display
//! 3. REFACTOR: Clean implementation
//! 4. COMMIT: Single atomic commit with fix
// Note: This is a DOCUMENTATION-BASED test since the actual behavior requires
// running pmat context on large projects with problematic files.
// The fix will be verified manually with the Ceph project.
#[test]
#[ignore = "BUG-010: RED test - documents expected behavior"]
fn test_warnings_should_not_be_truncated() {
// This test documents that warning messages should be complete, not truncated
// Current behavior (BROKEN):
// "Warning: Error processing file ./file.py: Parameter validation failed: l"
// ^- TRUNCATED!
// Expected behavior (FIXED):
// "Warning: Error processing file ./file.py: Parameter validation failed: line - Line too long (>10000 characters)"
// The fix should ensure complete error messages are shown
assert!(
true,
"GREEN phase should buffer warnings and display complete messages at end"
);
}
#[test]
#[ignore = "BUG-010: RED test - documents expected behavior"]
fn test_warnings_should_display_at_end() {
// This test documents that warnings should be displayed AFTER progress completes
// Current behavior (BROKEN):
// ⠙ Running parallel analyses...
// Warning: Error processing file ... <-- INTERLEAVED!
// ⠙ Running parallel analyses...
// ✅ Context written to: output.txt
// Expected behavior (FIXED):
// ⠙ Running parallel analyses...
// ✅ Context written to: output.txt
//
// ⚠️ 2 files skipped due to parsing errors: <-- AT END!
// - ./file1.py (line too long)
// - ./file2.h (line too long)
assert!(
true,
"GREEN phase should buffer warnings during analysis and display at end"
);
}
#[test]
#[ignore = "BUG-010: RED test - documents expected behavior"]
fn test_warnings_should_be_clearly_formatted() {
// This test documents that warnings should be clearly distinguished from errors
// Current behavior (BROKEN):
// "Warning: Error processing file ..." <-- CONTRADICTORY! Warning or Error?
// Expected behavior (FIXED):
// "⚠️ Skipping file: ./file.py"
// " Reason: Parameter validation failed - line too long (>10000 characters)"
// Clear hierarchy:
// - Symbol: ⚠️ (warning) vs ❌ (error)
// - Verb: "Skipping" (warning) vs "Failed" (error)
// - Formatting: Indented reason on next line
assert!(
true,
"GREEN phase should use clear warning formatting (⚠️ Skipping file:...)"
);
}
#[test]
#[ignore = "BUG-010: RED test - documents expected behavior"]
fn test_warnings_should_group_similar_errors() {
// This test documents that similar warnings should be grouped
// Current behavior (BROKEN):
// Warning: Error processing file ./file1.py: Parameter validation failed: l
// Warning: Error processing file ./file2.h: Parameter validation failed: line
// Warning: Error processing file ./file3.cc: Parameter validation failed: line too
// Expected behavior (FIXED):
// ⚠️ 3 files skipped due to parsing errors:
// - ./file1.py (line too long: 12,045 characters)
// - ./file2.h (line too long: 15,230 characters)
// - ./file3.cc (line too long: 11,892 characters)
assert!(
true,
"GREEN phase should group warnings by error type with summary"
);
}
#[test]
#[ignore = "BUG-010: RED test - documents expected behavior"]
fn test_warnings_should_use_stderr_not_stdout() {
// This test documents that warnings should go to stderr, not stdout
// Current behavior: Uses eprintln!() which goes to stderr (CORRECT)
// But interleaved with progress indicators (WRONG)
// Expected behavior:
// - Buffer warnings during analysis
// - After progress completes, write buffered warnings to stderr
// - This prevents interleaving with progress indicators
assert!(
true,
"GREEN phase should buffer warnings and write to stderr at end"
);
}
// =============================================================================
// Implementation Notes for GREEN Phase
// =============================================================================
// The fix should implement a WarningCollector that:
//
// 1. Collects warnings during analysis instead of printing immediately
// 2. Stores complete error messages (no truncation)
// 3. Groups warnings by type (line too long, parse error, etc.)
// 4. Displays at end of analysis with clear formatting
//
// Example implementation:
//
// ```rust
// pub struct WarningCollector {
// warnings: Arc<Mutex<Vec<FileWarning>>>,
// }
//
// pub struct FileWarning {
// file_path: PathBuf,
// error_type: WarningType,
// message: String,
// }
//
// pub enum WarningType {
// LineTooLong { length: usize },
// ParseError { reason: String },
// // ... other types
// }
//
// impl WarningCollector {
// pub fn add_warning(&self, file: PathBuf, error: &dyn Error) {
// // Parse error and categorize
// // Store in warnings vec
// }
//
// pub fn display_warnings(&self) {
// // Group by type
// // Format clearly
// // Write to stderr
// }
// }
// ```
//
// Modifications needed:
// - satd_detector.rs:728,902 - Use collector instead of eprintln!()
// - Pass collector through analysis pipeline
// - Call display_warnings() at end in context.rs handler