(tmp_path, verbose=False, debug=False)
| 3009 | # TODO: remove interaction with --debug? |
| 3010 | # TODO: test with --xml |
| 3011 | def __test_debug_template(tmp_path, verbose=False, debug=False): |
| 3012 | test_file = tmp_path / 'test.cpp' |
| 3013 | with open(test_file, "w") as f: |
| 3014 | f.write( |
| 3015 | """template<class T> class TemplCl; |
| 3016 | void f() |
| 3017 | { |
| 3018 | (void)(*((int*)nullptr)); |
| 3019 | } |
| 3020 | """) |
| 3021 | |
| 3022 | args = [ |
| 3023 | '-q', |
| 3024 | '--template=simple', |
| 3025 | '--debug-template', |
| 3026 | str(test_file) |
| 3027 | ] |
| 3028 | |
| 3029 | if verbose: |
| 3030 | args += ['--verbose'] |
| 3031 | if debug: |
| 3032 | args += ['--debug'] |
| 3033 | |
| 3034 | exitcode, stdout, stderr = cppcheck(args) |
| 3035 | assert exitcode == 0, stdout |
| 3036 | if debug: |
| 3037 | assert stdout.find('##file ') != -1 |
| 3038 | else: |
| 3039 | assert stdout.find('##file ') == -1 |
| 3040 | if debug: |
| 3041 | assert stdout.find('##Value flow') != -1 |
| 3042 | else: |
| 3043 | assert stdout.find('##Value flow') == -1 |
| 3044 | if debug and verbose: |
| 3045 | assert stdout.find('### Symbol database ###') != -1 |
| 3046 | else: |
| 3047 | assert stdout.find('### Symbol database ###') == -1 |
| 3048 | if debug and verbose: |
| 3049 | assert stdout.find('##AST') != -1 |
| 3050 | else: |
| 3051 | assert stdout.find('##AST') == -1 |
| 3052 | if debug: |
| 3053 | assert stdout.count('### Template Simplifier pass ') == 2 |
| 3054 | else: |
| 3055 | assert stdout.count('### Template Simplifier pass ') == 1 |
| 3056 | assert stderr.splitlines() == [ |
| 3057 | '{}:4:14: error: Null pointer dereference: (int*)nullptr [nullPointer]'.format(test_file) |
| 3058 | ] |
| 3059 | return stdout |
| 3060 | |
| 3061 | |
| 3062 | def test_debug_template(tmp_path): |
no test coverage detected