File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,49 @@ def test_levels(self):
165
165
166
166
tmp .cleanup ()
167
167
168
+ def test_prune (self ):
169
+ """Check report --prune flag works correctly"""
170
+ # Set up subdirectories for this test
171
+ tmp = tempfile .TemporaryDirectory ()
172
+ path = Path (tmp .name )
173
+ with open (path / "foo.cpp" , mode = "w" ) as f :
174
+ f .write ("void foo();" )
175
+ open (path / "unused.cpp" , mode = "w" ).close ()
176
+
177
+ codebase = CodeBase (path )
178
+ configuration = {
179
+ "X" : [
180
+ {
181
+ "file" : str (path / "foo.cpp" ),
182
+ "defines" : [],
183
+ "include_paths" : [],
184
+ "include_files" : [],
185
+ },
186
+ ],
187
+ }
188
+ state = finder .find (
189
+ path ,
190
+ codebase ,
191
+ configuration ,
192
+ show_progress = False ,
193
+ )
194
+
195
+ # By default, we should see both used and unused files.
196
+ stream = io .StringIO ()
197
+ report .files (codebase , state , stream = stream )
198
+ output = stream .getvalue ()
199
+ self .assertTrue ("foo.cpp" in output )
200
+ self .assertTrue ("unused.cpp" in output )
201
+
202
+ # With prune, we should only see the used files.
203
+ stream = io .StringIO ()
204
+ report .files (codebase , state , stream = stream , prune = True )
205
+ output = stream .getvalue ()
206
+ self .assertTrue ("foo.cpp" in output )
207
+ self .assertFalse ("unused.cpp" in output )
208
+
209
+ tmp .cleanup ()
210
+
168
211
169
212
if __name__ == "__main__" :
170
213
unittest .main ()
You can’t perform that action at this time.
0 commit comments