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

Function __test_ignore_file

test/cli/other_test.py:1983–2011  ·  view source on GitHub ↗
(tmpdir, ign, append=False, inject_path=False)

Source from the content-addressed store, hash-verified

1981
1982
1983def __test_ignore_file(tmpdir, ign, append=False, inject_path=False):
1984 os.mkdir(os.path.join(tmpdir, 'src'))
1985 test_file = os.path.join(tmpdir, 'src', 'test.cpp')
1986 with open(test_file, 'wt'):
1987 pass
1988
1989 # TODO: this should say that all paths are ignored
1990 lines_exp = [
1991 'ignored path: {}'.format(test_file),
1992 'cppcheck: error: could not find or open any of the paths given.',
1993 'cppcheck: Maybe all paths were ignored?'
1994 ]
1995
1996 args = [
1997 '--debug-ignore',
1998 test_file
1999 ]
2000
2001 if inject_path:
2002 ign = ign.replace('$path', str(test_file))
2003
2004 if append:
2005 args += ['-i{}'.format(ign)]
2006 else:
2007 args = ['-i{}'.format(ign)] + args
2008
2009 exitcode, stdout, stderr = cppcheck(args, cwd=tmpdir)
2010 assert exitcode == 1, stdout if stdout else stderr
2011 assert stdout.splitlines() == lines_exp
2012
2013
2014def test_ignore_file(tmpdir):

Calls 5

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

Tested by

no test coverage detected