@@ -47,10 +47,10 @@ def test_is_included_glob_file(self):
47
47
excludes = {'*.txt' : 'test ignore' }
48
48
assert not is_included (location , excludes = excludes )
49
49
50
- def check_ProcessIgnore (self , test_dir , expected , ignore ):
50
+ def check_ProcessIgnore (self , test_dir , expected , ignore , include = () ):
51
51
codebase = Codebase (test_dir , strip_root = True )
52
52
test_plugin = ProcessIgnore ()
53
- test_plugin .process_codebase (codebase , ignore = ignore )
53
+ test_plugin .process_codebase (codebase , ignore = ignore , include = include )
54
54
resources = [res .path for res in codebase .walk (skip_root = True )]
55
55
assert sorted (resources ) == expected
56
56
@@ -91,12 +91,13 @@ def test_ProcessIgnore_with_glob_for_extension(self):
91
91
92
92
def test_ProcessIgnore_with_glob_for_path (self ):
93
93
test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
94
- ignore = ('*/src/test' ,)
94
+ ignore = ('*/src/test/* ' ,)
95
95
expected = [
96
96
'user' ,
97
97
'user/ignore.doc' ,
98
98
'user/src' ,
99
- 'user/src/ignore.doc'
99
+ 'user/src/ignore.doc' ,
100
+ 'user/src/test' # test is included, but no file inside
100
101
]
101
102
self .check_ProcessIgnore (test_dir , expected , ignore )
102
103
@@ -110,6 +111,19 @@ def test_ProcessIgnore_with_multiple_ignores(self):
110
111
]
111
112
self .check_ProcessIgnore (test_dir , expected , ignore )
112
113
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
+
113
127
def test_ProcessIgnore_process_codebase_does_not_fail_to_access_an_ignored_resourced_cached_to_disk (self ):
114
128
test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
115
129
codebase = Codebase (test_dir , max_in_memory = 1 )
@@ -217,12 +231,12 @@ def test_scancode_ignore_glob_path(self):
217
231
def test_scancode_multiple_ignores (self ):
218
232
test_dir = self .extract_test_tar ('plugin_ignore/user.tgz' )
219
233
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 ]
221
235
run_scan_click (args )
222
236
scan_result = load_json_result (result_file )
223
237
assert scan_result ['headers' ][0 ]['extra_data' ]['files_count' ] == 0
224
238
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' ]
226
240
227
241
def test_scancode_codebase_attempt_to_access_an_ignored_resourced_cached_to_disk (self ):
228
242
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
237
251
u'user/ignore.doc' ,
238
252
u'user/src' ,
239
253
u'user/src/ignore.doc' ,
254
+ u'user/src/test' ,
240
255
]
241
256
assert scan_locs == expected
0 commit comments