(tmpdir)
| 1056 | |
| 1057 | |
| 1058 | def 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 | |
| 1086 | def test_config_lookup_notfound(tmpdir): |
nothing calls this directly
no test coverage detected