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

Function test_config_lookup

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

Source from the content-addressed store, hash-verified

1056
1057
1058def test_config_lookup(tmpdir):
1059 cppcheck_exe = __lookup_cppcheck_exe()
1060 bin_dir = os.path.dirname(cppcheck_exe)
1061 tmp_cppcheck_exe = shutil.copy2(cppcheck_exe, tmpdir)
1062 if sys.platform == 'win32':
1063 shutil.copy2(os.path.join(bin_dir, 'cppcheck-core.dll'), tmpdir)
1064 shutil.copytree(os.path.join(bin_dir, 'cfg'), os.path.join(tmpdir, 'cfg'))
1065
1066 test_file = os.path.join(tmpdir, 'test.c')
1067 with open(test_file, 'wt'):
1068 pass
1069
1070 config_file = os.path.join(tmpdir, 'cppcheck.cfg')
1071 with open(config_file, 'wt') as f:
1072 f.write('{}')
1073
1074 exitcode, stdout, stderr, exe = cppcheck_ex(['--debug-lookup=config', test_file], cwd=tmpdir, cppcheck_exe=tmp_cppcheck_exe)
1075 exepath = os.path.dirname(exe)
1076 exepath_sep = exepath + os.path.sep
1077 exepath_sep = exepath_sep.replace('\\', '/')
1078 assert exitcode == 0, stdout if stdout else stderr
1079 lines = stdout.splitlines()
1080 assert lines == [
1081 "looking for '{}cppcheck.cfg'".format(exepath_sep),
1082 'Checking {} ...'.format(test_file)
1083 ]
1084
1085
1086def test_config_lookup_notfound(tmpdir):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected