(tmpdir)
| 858 | |
| 859 | # TODO: test with -j2 |
| 860 | def test_invalid_addon_py_verbose(tmpdir): |
| 861 | addon_file = os.path.join(tmpdir, 'addon1.py') |
| 862 | with open(addon_file, 'wt') as f: |
| 863 | f.write(""" |
| 864 | raise Exception() |
| 865 | """) |
| 866 | |
| 867 | test_file = os.path.join(tmpdir, 'file.cpp') |
| 868 | with open(test_file, 'wt') as f: |
| 869 | f.write(""" |
| 870 | typedef int MISRA_5_6_VIOLATION; |
| 871 | """) |
| 872 | |
| 873 | args = ['--addon={}'.format(addon_file), '--enable=all', '--disable=unusedFunction', '--verbose', '-j1', test_file] |
| 874 | |
| 875 | exitcode, stdout, stderr = cppcheck(args) |
| 876 | assert exitcode == 0 # TODO: needs to be 1 |
| 877 | lines = __remove_verbose_log(stdout.splitlines()) |
| 878 | assert lines == [ |
| 879 | 'Checking {} ...'.format(test_file) |
| 880 | ] |
| 881 | """ |
| 882 | /tmp/pytest-of-user/pytest-11/test_invalid_addon_py_20/file.cpp:0:0: error: Bailing out from analysis: Checking file failed: Failed to execute addon 'addon1' - exitcode is 1: python3 /home/user/CLionProjects/cppcheck/addons/runaddon.py /tmp/pytest-of-user/pytest-11/test_invalid_addon_py_20/addon1.py --cli /tmp/pytest-of-user/pytest-11/test_invalid_addon_py_20/file.cpp.24762.dump |
| 883 | Output: |
| 884 | Traceback (most recent call last): |
| 885 | File "/home/user/CLionProjects/cppcheck/addons/runaddon.py", line 8, in <module> |
| 886 | runpy.run_path(addon, run_name='__main__') |
| 887 | File "<frozen runpy>", line 291, in run_path |
| 888 | File "<frozen runpy>", line 98, in _run_module_code |
| 889 | File "<frozen runpy>", line 88, in _run_code |
| 890 | File "/tmp/pytest-of-user/pytest-11/test_invalid_addon_py_20/addon1.py", line 2, in <module> |
| 891 | raise Exception() |
| 892 | Exceptio [internalError] |
| 893 | """ |
| 894 | # /tmp/pytest-of-user/pytest-10/test_invalid_addon_py_20/file.cpp:0:0: error: Bailing out from analysis: Checking file failed: Failed to execute addon 'addon1' - exitcode is 256.: python3 /home/user/CLionProjects/cppcheck/addons/runaddon.py /tmp/pytest-of-user/pytest-10/test_invalid_addon_py_20/addon1.py --cli /tmp/pytest-of-user/pytest-10/test_invalid_addon_py_20/file.cpp.24637.dump |
| 895 | assert stderr.startswith("{}:0:0: error: Bailing out from analysis: Checking file failed: Failed to execute addon 'addon1' - exitcode is 1: ".format(test_file)) |
| 896 | assert stderr.count('Output:\nTraceback') |
| 897 | assert stderr.endswith('raise Exception()\nException [internalError]\n\n^\n') |
| 898 | |
| 899 | |
| 900 | def test_addon_result(tmpdir): |
nothing calls this directly
no test coverage detected