Skip to content

Commit d20c192

Browse files
committed
Add revised end-to-end test
1 parent 2af2efe commit d20c192

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/cli/project_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ def test_empty_project(tmpdir, project_ext, expected):
4141
__test_project_error(tmpdir, project_ext, None, expected)
4242

4343

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

0 commit comments

Comments
 (0)