| 43 | |
| 44 | |
| 45 | def test_json_entry_file_not_found(tmpdir): |
| 46 | compilation_db = [ |
| 47 | {"directory": str(tmpdir), |
| 48 | "command": "c++ -o bug1.o -c bug1.cpp", |
| 49 | "file": "bug1.cpp", |
| 50 | "output": "bug1.o"} |
| 51 | ] |
| 52 | |
| 53 | project_file = os.path.join(tmpdir, "file.json") |
| 54 | missing_file = os.path.join(tmpdir, "bug1.cpp") |
| 55 | missing_file_posix = missing_file |
| 56 | |
| 57 | if sys.platform == "win32": |
| 58 | missing_file_posix = missing_file_posix.replace('\\', '/') |
| 59 | |
| 60 | with open(project_file, 'w') as f: |
| 61 | f.write(json.dumps(compilation_db)) |
| 62 | |
| 63 | ret, _, stderr = cppcheck([ |
| 64 | '--template=simple', |
| 65 | "--project=" + str(project_file) |
| 66 | ]) |
| 67 | assert 0 == ret |
| 68 | assert stderr == f"{missing_file}:0:0: error: File is missing: {missing_file_posix} [missingFile]\n" |
| 69 | |
| 70 | |
| 71 | def test_json_no_arguments(tmpdir): |