@@ -2701,8 +2701,9 @@ def test_debug_verbose_xml(tmp_path):
27012701 assert len (ast_elem ) == 1
27022702
27032703
2704+ # TODO: remove interaction with --debug?
27042705# TODO: test with --xml
2705- def __test_debug_template (tmp_path , verbose ):
2706+ def __test_debug_template (tmp_path , verbose = False , debug = False ):
27062707 test_file = tmp_path / 'test.cpp'
27072708 with open (test_file , "w" ) as f :
27082709 f .write (
@@ -2722,27 +2723,54 @@ def __test_debug_template(tmp_path, verbose):
27222723
27232724 if verbose :
27242725 args += ['--verbose' ]
2726+ if debug :
2727+ args += ['--debug' ]
27252728
27262729 exitcode , stdout , stderr = cppcheck (args )
27272730 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
27332751 assert stderr .splitlines () == [
27342752 '{}:4:13: error: Null pointer dereference: (int*)nullptr [nullPointer]' .format (test_file )
27352753 ]
27362754 return stdout
27372755
27382756
27392757def test_debug_template (tmp_path ):
2740- __test_debug_template (tmp_path , False )
2758+ __test_debug_template (tmp_path , verbose = False )
27412759
27422760
27432761def test_debug_template_verbose_nodiff (tmp_path ):
27442762 # 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 )
27462774
27472775
27482776def test_file_ignore_2 (tmp_path ): # #13570
@@ -3467,7 +3495,6 @@ def test_debug_ast(tmp_path):
34673495 __test_debug_ast (tmp_path , False )
34683496
34693497
3470- @pytest .mark .xfail (strict = True ) # TODO: remove dependency on --verbose
34713498def test_debug_ast_verbose_nodiff (tmp_path ):
34723499 # make sure --verbose does not change the output
34733500 assert __test_debug_ast (tmp_path , False ) == __test_debug_ast (tmp_path , True )
0 commit comments