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

Function __test_ignore_project

test/cli/other_test.py:2087–2116  ·  view source on GitHub ↗
(tmpdir, ign_proj, ign_cli=None, append_cli=False, inject_path_proj=False)

Source from the content-addressed store, hash-verified

2085
2086
2087def __test_ignore_project(tmpdir, ign_proj, ign_cli=None, append_cli=False, inject_path_proj=False):
2088 os.mkdir(os.path.join(tmpdir, 'src'))
2089 test_file = os.path.join(tmpdir, 'src', 'test.cpp')
2090 with open(test_file, 'wt'):
2091 pass
2092
2093 # TODO: this should say that all paths were ignored
2094 lines_exp = [
2095 'ignored path: {}'.format(test_file),
2096 'cppcheck: error: could not find or open any of the paths given.',
2097 'cppcheck: Maybe all paths were ignored?'
2098 ]
2099
2100 if inject_path_proj:
2101 ign_proj = ign_proj.replace('$path', str(test_file))
2102
2103 project_file = __write_gui_project(tmpdir, test_file, ign_proj)
2104 args = [
2105 '--debug-ignore',
2106 '--project={}'.format(project_file)
2107 ]
2108
2109 if append_cli:
2110 args += ['-i{}'.format(ign_cli)]
2111 else:
2112 args = ['-i{}'.format(ign_cli)] + args
2113
2114 exitcode, stdout, _ = cppcheck(args, cwd=tmpdir)
2115 assert exitcode == 1, stdout
2116 assert stdout.splitlines() == lines_exp
2117
2118
2119def test_ignore_project_file(tmpdir):

Calls 6

cppcheckFunction · 0.90
strFunction · 0.85
__write_gui_projectFunction · 0.85
formatMethod · 0.80
joinMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected