(tmpdir)
| 38 | |
| 39 | |
| 40 | def test_misra_c_builtin_style_checks(tmpdir): |
| 41 | test_file = os.path.join(tmpdir, 'test.cpp') |
| 42 | with open(test_file, 'wt') as f: |
| 43 | f.write('void foo() { int x; y = 0; }') |
| 44 | |
| 45 | exe = __copy_cppcheck_premium(tmpdir) |
| 46 | |
| 47 | exitcode, _, stderr = cppcheck(['--premium=autosar', '--xml', test_file], cppcheck_exe=exe) |
| 48 | assert exitcode == 0 |
| 49 | assert 'id="unusedVariable"' in stderr |
| 50 | assert 'id="checkersReport"' in stderr |
| 51 | |
| 52 | exitcode, _, stderr = cppcheck(['--premium=autosar', '--premium=safety-off', '--xml', test_file], cppcheck_exe=exe) |
| 53 | assert exitcode == 0 |
| 54 | assert 'id="unusedVariable"' in stderr |
| 55 | assert 'id="checkersReport"' not in stderr |
| 56 | |
| 57 | exitcode, _, stderr = cppcheck(['--xml-version=3', test_file], cppcheck_exe=exe) |
| 58 | assert exitcode == 0 |
| 59 | assert '<safety/>' in stderr |
| 60 | |
| 61 | exitcode, _, stderr = cppcheck(['--xml-version=3', '--premium=safety-off', test_file], cppcheck_exe=exe) |
| 62 | assert exitcode == 0 |
| 63 | assert '<safety/>' not in stderr |
| 64 | |
| 65 | exitcode, _, stderr = cppcheck(['--xml-version=3', '--inline-suppr', test_file], cppcheck_exe=exe) |
| 66 | assert exitcode == 0 |
| 67 | assert '<inline-suppr/>' in stderr |
| 68 | |
| 69 | exitcode, _, stderr = cppcheck(['--xml-version=3', '--suppress=foo', test_file], cppcheck_exe=exe) |
| 70 | assert exitcode == 0 |
| 71 | assert '<suppression errorId="foo" inline="false" />' in stderr |
| 72 | |
| 73 | |
| 74 | def test_build_dir_hash_cppcheck_product(tmpdir): |
nothing calls this directly
no test coverage detected