File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,49 @@ def test_levels(self):
218
218
219
219
tmp .cleanup ()
220
220
221
+ def test_prune (self ):
222
+ """Check report --prune flag works correctly"""
223
+ # Set up subdirectories for this test
224
+ tmp = tempfile .TemporaryDirectory ()
225
+ path = Path (tmp .name )
226
+ with open (path / "foo.cpp" , mode = "w" ) as f :
227
+ f .write ("void foo();" )
228
+ open (path / "unused.cpp" , mode = "w" ).close ()
229
+
230
+ codebase = CodeBase (path )
231
+ configuration = {
232
+ "X" : [
233
+ {
234
+ "file" : str (path / "foo.cpp" ),
235
+ "defines" : [],
236
+ "include_paths" : [],
237
+ "include_files" : [],
238
+ },
239
+ ],
240
+ }
241
+ state = finder .find (
242
+ path ,
243
+ codebase ,
244
+ configuration ,
245
+ show_progress = False ,
246
+ )
247
+
248
+ # By default, we should see both used and unused files.
249
+ stream = io .StringIO ()
250
+ report .files (codebase , state , stream = stream )
251
+ output = stream .getvalue ()
252
+ self .assertTrue ("foo.cpp" in output )
253
+ self .assertTrue ("unused.cpp" in output )
254
+
255
+ # With prune, we should only see the used files.
256
+ stream = io .StringIO ()
257
+ report .files (codebase , state , stream = stream , prune = True )
258
+ output = stream .getvalue ()
259
+ self .assertTrue ("foo.cpp" in output )
260
+ self .assertFalse ("unused.cpp" in output )
261
+
262
+ tmp .cleanup ()
263
+
221
264
222
265
if __name__ == "__main__" :
223
266
unittest .main ()
You can’t perform that action at this time.
0 commit comments