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

Function __test_ignore_project_2

test/cli/other_test.py:2177–2204  ·  view source on GitHub ↗
(tmpdir, extra_args, append=False, inject_path=False)

Source from the content-addressed store, hash-verified

2175
2176
2177def __test_ignore_project_2(tmpdir, extra_args, append=False, inject_path=False):
2178 os.mkdir(os.path.join(tmpdir, 'src'))
2179 test_file = os.path.join(tmpdir, 'src', 'test.cpp')
2180 with open(test_file, 'wt'):
2181 pass
2182
2183 lines_exp = [
2184 'ignored path: {}'.format(str(test_file).replace('\\', '/')),
2185 'cppcheck: error: no C or C++ source files found.',
2186 'cppcheck: all paths were ignored'
2187 ]
2188 project_file = __write_compdb(tmpdir, test_file)
2189 args = [
2190 '--debug-ignore',
2191 '--project={}'.format(project_file)
2192 ]
2193
2194 if inject_path:
2195 extra_args = [ extra_args[0].replace('$path', str(test_file)) ]
2196 if append:
2197 args += extra_args
2198 else:
2199 args = extra_args + args
2200 print(args)
2201
2202 exitcode, stdout, stderr = cppcheck(args, cwd=tmpdir)
2203 assert exitcode == 1, stdout if stdout else stderr
2204 assert stdout.splitlines() == lines_exp
2205
2206
2207def test_ignore_project_2_file(tmpdir):

Calls 6

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

Tested by

no test coverage detected