@@ -2701,8 +2701,9 @@ def test_debug_verbose_xml(tmp_path):
2701
2701
assert len (ast_elem ) == 1
2702
2702
2703
2703
2704
+ # TODO: remove interaction with --debug?
2704
2705
# TODO: test with --xml
2705
- def __test_debug_template (tmp_path , verbose ):
2706
+ def __test_debug_template (tmp_path , verbose = False , debug = False ):
2706
2707
test_file = tmp_path / 'test.cpp'
2707
2708
with open (test_file , "w" ) as f :
2708
2709
f .write (
@@ -2722,27 +2723,54 @@ def __test_debug_template(tmp_path, verbose):
2722
2723
2723
2724
if verbose :
2724
2725
args += ['--verbose' ]
2726
+ if debug :
2727
+ args += ['--debug' ]
2725
2728
2726
2729
exitcode , stdout , stderr = cppcheck (args )
2727
2730
assert exitcode == 0 , stdout
2728
- assert stdout .find ('##file ' ) == - 1
2729
- assert stdout .find ('##Value flow' ) == - 1
2730
- assert stdout .find ('### Symbol database ###' ) == - 1
2731
- assert stdout .find ('##AST' ) == - 1
2732
- assert stdout .find ('### Template Simplifier pass ' ) != - 1
2731
+ if debug :
2732
+ assert stdout .find ('##file ' ) != - 1
2733
+ else :
2734
+ assert stdout .find ('##file ' ) == - 1
2735
+ if debug :
2736
+ assert stdout .find ('##Value flow' ) != - 1
2737
+ else :
2738
+ assert stdout .find ('##Value flow' ) == - 1
2739
+ if debug and verbose :
2740
+ assert stdout .find ('### Symbol database ###' ) != - 1
2741
+ else :
2742
+ assert stdout .find ('### Symbol database ###' ) == - 1
2743
+ if debug and verbose :
2744
+ assert stdout .find ('##AST' ) != - 1
2745
+ else :
2746
+ assert stdout .find ('##AST' ) == - 1
2747
+ if debug :
2748
+ assert stdout .count ('### Template Simplifier pass ' ) == 2
2749
+ else :
2750
+ assert stdout .count ('### Template Simplifier pass ' ) == 1
2733
2751
assert stderr .splitlines () == [
2734
2752
'{}:4:13: error: Null pointer dereference: (int*)nullptr [nullPointer]' .format (test_file )
2735
2753
]
2736
2754
return stdout
2737
2755
2738
2756
2739
2757
def test_debug_template (tmp_path ):
2740
- __test_debug_template (tmp_path , False )
2758
+ __test_debug_template (tmp_path , verbose = False )
2741
2759
2742
2760
2743
2761
def test_debug_template_verbose_nodiff (tmp_path ):
2744
2762
# make sure --verbose does not change the output
2745
- assert __test_debug_template (tmp_path , False ) == __test_debug_template (tmp_path , True )
2763
+ assert __test_debug_template (tmp_path , verbose = False ) == __test_debug_template (tmp_path , verbose = True )
2764
+
2765
+
2766
+ def test_debug_template_debug (tmp_path ):
2767
+ __test_debug_template (tmp_path , debug = True )
2768
+
2769
+
2770
+ @pytest .mark .xfail (strict = True ) # TODO: remove dependency on --verbose
2771
+ def test_debug_template_debug_verbose_nodiff (tmp_path ):
2772
+ # make sure --verbose does not change the output
2773
+ assert __test_debug_template (tmp_path , debug = True , verbose = False ) == __test_debug_template (tmp_path , debug = True , verbose = True )
2746
2774
2747
2775
2748
2776
def test_file_ignore_2 (tmp_path ): # #13570
0 commit comments