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

Function test_config_invalid

test/cli/lookup_test.py:1104–1129  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1102
1103
1104def test_config_invalid(tmpdir):
1105 cppcheck_exe = __lookup_cppcheck_exe()
1106 bin_dir = os.path.dirname(cppcheck_exe)
1107 tmp_cppcheck_exe = shutil.copy2(cppcheck_exe, tmpdir)
1108 if sys.platform == 'win32':
1109 shutil.copy2(os.path.join(bin_dir, 'cppcheck-core.dll'), tmpdir)
1110 shutil.copytree(os.path.join(bin_dir, 'cfg'), os.path.join(tmpdir, 'cfg'))
1111
1112 test_file = os.path.join(tmpdir, 'test.c')
1113 with open(test_file, 'wt'):
1114 pass
1115
1116 config_file = os.path.join(tmpdir, 'cppcheck.cfg')
1117 with open(config_file, 'wt'):
1118 pass
1119
1120 exitcode, stdout, stderr, exe = cppcheck_ex(['--debug-lookup=config', test_file], cwd=tmpdir, cppcheck_exe=tmp_cppcheck_exe)
1121 exepath = os.path.dirname(exe)
1122 exepath_sep = exepath + os.path.sep
1123 exepath_sep = exepath_sep.replace('\\', '/')
1124 assert exitcode == 1, stdout if stdout else stderr
1125 lines = stdout.splitlines()
1126 assert lines == [
1127 "looking for '{}cppcheck.cfg'".format(exepath_sep),
1128 'cppcheck: error: could not load cppcheck.cfg - not a valid JSON - syntax error at line 1 near: '
1129 ]
1130
1131# TODO: test with FILESDIR
1132

Callers

nothing calls this directly

Calls 5

__lookup_cppcheck_exeFunction · 0.90
cppcheck_exFunction · 0.90
formatMethod · 0.80
joinMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected