|
@@ -45,95 +45,96 @@ def _assert_rejects( filter, text ):
|
|
|
_assert_accept_equals( filter, text, False )
|
|
|
|
|
|
|
|
|
-class ConfigPriority_test():
|
|
|
+def _JavaFilter( config ):
|
|
|
+ return { 'filter_diagnostics' : { 'java': config } }
|
|
|
|
|
|
- def ConfigPriority_Global_test( self ):
|
|
|
- opts = { 'quiet_messages': { 'regex': 'taco' } }
|
|
|
- f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
- _assert_rejects( f, 'This is a Taco' )
|
|
|
- _assert_accepts( f, 'This is a Burrito' )
|
|
|
+def RegexFilter_test():
|
|
|
+ opts = _JavaFilter( { 'regex' : 'taco' } )
|
|
|
+ f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
+ _assert_rejects( f, 'This is a Taco' )
|
|
|
+ _assert_accepts( f, 'This is a Burrito' )
|
|
|
|
|
|
- def ConfigPriority_Filetype_test( self ):
|
|
|
- opts = { 'quiet_messages' : {},
|
|
|
- 'java_quiet_messages' : { 'regex': 'taco' } }
|
|
|
- f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
-
|
|
|
- _assert_rejects( f, 'This is a Taco' )
|
|
|
- _assert_accepts( f, 'This is a Burrito' )
|
|
|
|
|
|
+class ListOrSingle_test():
|
|
|
+ # NB: we already test the single config above
|
|
|
|
|
|
- def ConfigPriority_FiletypeOverridesGlobal_test( self ):
|
|
|
+ def ListOrSingle_SingleList_test( self ):
|
|
|
# NB: if the filetype doesn't override the global,
|
|
|
# we would reject burrito and accept taco
|
|
|
- opts = { 'quiet_messages' : { 'regex': 'burrito'},
|
|
|
- 'java_quiet_messages' : { 'regex': 'taco' } }
|
|
|
+ opts = _JavaFilter( { 'regex' : [ 'taco' ] } )
|
|
|
f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
_assert_rejects( f, 'This is a Taco' )
|
|
|
_assert_accepts( f, 'This is a Burrito' )
|
|
|
|
|
|
|
|
|
- def ConfigPriority_FiletypeDisablesGlobal_test( self ):
|
|
|
+ def ListOrSingle_MultiList_test( self ):
|
|
|
# NB: if the filetype doesn't override the global,
|
|
|
# we would reject burrito and accept taco
|
|
|
- opts = { 'quiet_messages' : { 'regex': 'taco'},
|
|
|
- 'java_quiet_messages' : { 'regex': [] } }
|
|
|
+ opts = _JavaFilter( { 'regex' : [ 'taco', 'burrito' ] } )
|
|
|
f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
- _assert_accepts( f, 'This is a Taco' )
|
|
|
- _assert_accepts( f, 'This is a Burrito' )
|
|
|
+ _assert_rejects( f, 'This is a Taco' )
|
|
|
+ _assert_rejects( f, 'This is a Burrito' )
|
|
|
|
|
|
|
|
|
-class ListOrSingle_test():
|
|
|
- # NB: we already test the single config above
|
|
|
+class Level_test():
|
|
|
|
|
|
- def ListOrSingle_SingleList_test( self ):
|
|
|
- # NB: if the filetype doesn't override the global,
|
|
|
- # we would reject burrito and accept taco
|
|
|
- opts = { 'quiet_messages' : { 'regex': [ 'taco' ] } }
|
|
|
+ def Level_warnings_test( self ):
|
|
|
+ opts = _JavaFilter( { 'level' : 'warning' } )
|
|
|
f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
- _assert_rejects( f, 'This is a Taco' )
|
|
|
- _assert_accepts( f, 'This is a Burrito' )
|
|
|
+ _assert_rejects( f, { 'text' : 'This is an unimportant taco',
|
|
|
+ 'kind' : 'WARNING' } )
|
|
|
+ _assert_accepts( f, { 'text' : 'This taco will be shown',
|
|
|
+ 'kind' : 'ERROR' } )
|
|
|
|
|
|
|
|
|
- def ListOrSingle_MultiList_test( self ):
|
|
|
- # NB: if the filetype doesn't override the global,
|
|
|
- # we would reject burrito and accept taco
|
|
|
- opts = { 'quiet_messages' : { 'regex': [ 'taco', 'burrito' ] } }
|
|
|
+ def Level_errors_test( self ):
|
|
|
+ opts = _JavaFilter( { 'level' : 'error' } )
|
|
|
f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
- _assert_rejects( f, 'This is a Taco' )
|
|
|
- _assert_rejects( f, 'This is a Burrito' )
|
|
|
+ _assert_accepts( f, { 'text' : 'This is an IMPORTANT taco',
|
|
|
+ 'kind' : 'WARNING' } )
|
|
|
+ _assert_rejects( f, { 'text' : 'This taco will NOT be shown',
|
|
|
+ 'kind' : 'ERROR' } )
|
|
|
|
|
|
|
|
|
-def Invert_test():
|
|
|
- opts = { 'quiet_messages' : { '!regex': 'taco' } }
|
|
|
- f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
+def MultipleFilterTypesTypeTest_test():
|
|
|
|
|
|
- _assert_accepts( f, 'This is a Taco' )
|
|
|
- _assert_rejects( f, 'This is a Burrito' )
|
|
|
+ opts = _JavaFilter( { 'regex' : '.*taco.*',
|
|
|
+ 'level' : 'warning' } )
|
|
|
+ f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
|
|
|
+ _assert_rejects( f, { 'text' : 'This is an unimportant taco',
|
|
|
+ 'kind' : 'WARNING' } )
|
|
|
+ _assert_rejects( f, { 'text' : 'This taco will NOT be shown',
|
|
|
+ 'kind' : 'ERROR' } )
|
|
|
+ _assert_accepts( f, { 'text' : 'This burrito WILL be shown',
|
|
|
+ 'kind' : 'ERROR' } )
|
|
|
|
|
|
-class Level_test():
|
|
|
|
|
|
- def Level_warnings_test( self ):
|
|
|
- opts = { 'quiet_messages' : { 'level': 'warnings' } }
|
|
|
- f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
+def MergeMultipleFiletypes_test():
|
|
|
|
|
|
- _assert_rejects( f, { 'text': 'This is an unimportant taco',
|
|
|
- 'kind': 'WARNING' } )
|
|
|
- _assert_accepts( f, { 'text': 'This taco will be shown',
|
|
|
- 'kind': 'ERROR' } )
|
|
|
+ opts = { 'filter_diagnostics' : {
|
|
|
+ 'java' : { 'regex' : '.*taco.*' },
|
|
|
+ 'xml' : { 'regex' : '.*burrito.*' } } }
|
|
|
|
|
|
+ f = DiagnosticFilter.from_filetype( opts, [ 'java', 'xml' ] )
|
|
|
|
|
|
- def Level_errors_test( self ):
|
|
|
- opts = { 'quiet_messages' : { 'level': 'errors' } }
|
|
|
- f = DiagnosticFilter.from_filetype( opts, [ 'java' ] )
|
|
|
+ _assert_rejects( f, 'This is a Taco' )
|
|
|
+ _assert_rejects( f, 'This is a Burrito' )
|
|
|
+ _assert_accepts( f, 'This is some Nachos' )
|
|
|
+
|
|
|
+
|
|
|
+def CommaSeparatedFiletypes_test():
|
|
|
+
|
|
|
+ opts = { 'filter_diagnostics' : {
|
|
|
+ 'java,c,cs' : { 'regex' : '.*taco.*' } } }
|
|
|
+
|
|
|
+ f = DiagnosticFilter.from_filetype( opts, [ 'cs' ] )
|
|
|
|
|
|
- _assert_accepts( f, { 'text': 'This is an IMPORTANT taco',
|
|
|
- 'kind': 'WARNING' } )
|
|
|
- _assert_rejects( f, { 'text': 'This taco will NOT be shown',
|
|
|
- 'kind': 'ERROR' } )
|
|
|
+ _assert_rejects( f, 'This is a Taco' )
|
|
|
+ _assert_accepts( f, 'This is a Burrito' )
|