MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / test_json_entry_file_not_found

Function test_json_entry_file_not_found

test/cli/project_test.py:45–68  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

43
44
45def 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
71def test_json_no_arguments(tmpdir):

Callers

nothing calls this directly

Calls 5

cppcheckFunction · 0.90
strFunction · 0.85
joinMethod · 0.45
replaceMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected