@@ -47,10 +47,10 @@ def test_is_included_glob_file(self):
4747 excludes = {'*.txt' : 'test ignore' }
4848 assert not is_included (location , excludes = excludes )
4949
50- def check_ProcessIgnore (self , test_dir , expected , ignore ):
50+ def check_ProcessIgnore (self , test_dir , expected , ignore , include = () ):
5151 codebase = Codebase (test_dir , strip_root = True )
5252 test_plugin = ProcessIgnore ()
53- test_plugin .process_codebase (codebase , ignore = ignore )
53+ test_plugin .process_codebase (codebase , ignore = ignore , include = include )
5454 resources = [res .path for res in codebase .walk (skip_root = True )]
5555 assert sorted (resources ) == expected
5656
@@ -91,12 +91,13 @@ def test_ProcessIgnore_with_glob_for_extension(self):
9191
9292 def test_ProcessIgnore_with_glob_for_path (self ):
9393 test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
94- ignore = ('*/src/test' ,)
94+ ignore = ('*/src/test/* ' ,)
9595 expected = [
9696 'user' ,
9797 'user/ignore.doc' ,
9898 'user/src' ,
99- 'user/src/ignore.doc'
99+ 'user/src/ignore.doc' ,
100+ 'user/src/test' # test is included, but no file inside
100101 ]
101102 self .check_ProcessIgnore (test_dir , expected , ignore )
102103
@@ -110,6 +111,19 @@ def test_ProcessIgnore_with_multiple_ignores(self):
110111 ]
111112 self .check_ProcessIgnore (test_dir , expected , ignore )
112113
114+ def test_ProcessIgnore_include_with_glob_for_extension (self ):
115+ test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
116+ include = ('*.doc' ,)
117+ expected = [
118+ 'user' ,
119+ 'user/ignore.doc' ,
120+ 'user/src' ,
121+ 'user/src/ignore.doc' ,
122+ 'user/src/test' ,
123+ 'user/src/test/sample.doc' ,
124+ ]
125+ self .check_ProcessIgnore (test_dir , expected , ignore = (), include = include )
126+
113127 def test_ProcessIgnore_process_codebase_does_not_fail_to_access_an_ignored_resourced_cached_to_disk (self ):
114128 test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
115129 codebase = Codebase (test_dir , max_in_memory = 1 )
@@ -217,12 +231,12 @@ def test_scancode_ignore_glob_path(self):
217231 def test_scancode_multiple_ignores (self ):
218232 test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
219233 result_file = self .get_temp_file ('json' )
220- args = ['--copyright' , '--strip-root' , '--ignore' , '*/src/test' , '--ignore' , '*.doc' , test_dir , '--json' , result_file ]
234+ args = ['--copyright' , '--strip-root' , '--ignore' , '*/src/test/* ' , '--ignore' , '*.doc' , test_dir , '--json' , result_file ]
221235 run_scan_click (args )
222236 scan_result = load_json_result (result_file )
223237 assert scan_result ['headers' ][0 ]['extra_data' ]['files_count' ] == 0
224238 scan_locs = [x ['path' ] for x in scan_result ['files' ]]
225- assert scan_locs == [u'user' , u'user/src' ]
239+ assert scan_locs == [u'user' , u'user/src' , u'user/src/test' ]
226240
227241 def test_scancode_codebase_attempt_to_access_an_ignored_resourced_cached_to_disk (self ):
228242 test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
@@ -237,5 +251,6 @@ def test_scancode_codebase_attempt_to_access_an_ignored_resourced_cached_to_disk
237251 u'user/ignore.doc' ,
238252 u'user/src' ,
239253 u'user/src/ignore.doc' ,
254+ u'user/src/test' ,
240255 ]
241256 assert scan_locs == expected
0 commit comments